fix(任务管理):锁粒度调整的更细
This commit is contained in:
+57
@@ -204,6 +204,8 @@ public class OrderController {
|
||||
if (qrCode.getStatus().equals(CommonStatus.UNABLE.getId())){
|
||||
return Result.failed("该二维码已过期");
|
||||
}
|
||||
//设置订单所属tenantId
|
||||
TenantContextHolder.setTenant(qrCode.getTenantId());
|
||||
order.setTourismId(qrCode.getTourismId());
|
||||
order.setDeviceSn(qrCode.getDeviceSn());
|
||||
order.setOrderAmount(qrCode.getPrice());
|
||||
@@ -620,4 +622,59 @@ public class OrderController {
|
||||
// 在最后两位字符前添加小数点
|
||||
return prefix + "." + lastTwo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@Operation(summary = "查询用户订单临时演示")
|
||||
@Parameters({
|
||||
@Parameter(name = "page",description = "分页起始位置",required = true,in=ParameterIn.QUERY),
|
||||
@Parameter(name = "limit",description = "分页结束位置",required = true,in=ParameterIn.QUERY)
|
||||
})
|
||||
@GetMapping("/user/temp")
|
||||
public PageResult<Map> listInfoByUserForTemp(@RequestParam Map<String, Object> params) {
|
||||
params.put("orderNo", "332025051700001");
|
||||
String fileType = MapUtils.getString(params, "fileType");
|
||||
if (StringUtil.isBlank(fileType)) {
|
||||
fileType = "image/jpeg";
|
||||
}
|
||||
|
||||
PageResult<Order> result = orderService.findList(params);
|
||||
if (result.getCount() > 0){
|
||||
List<Map> page = new ArrayList<>();
|
||||
Map<String, String> fileMap = new HashMap<>();
|
||||
fileMap.put("style", fileStyle);
|
||||
for(Order order : result.getData()){
|
||||
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> list = orderFileService.getOrderFileByOrderNoAndFileType(order.getOrderNo(),fileType);
|
||||
List<String> list = fileCenterService.getListFiles("temp/332025051700001/Remote-Control/");
|
||||
List<Map<String,String>> resultList = new ArrayList<>();
|
||||
if (!list.isEmpty()){
|
||||
list.remove(0);
|
||||
for (String orderFile : list){
|
||||
Map<String,String> imgMap = new HashMap<>();
|
||||
String url = fileCenterService.getViewUrlByPath(orderFile);
|
||||
imgMap.put("url", url.replace(cdnOssUrl,cdnUrl));
|
||||
if (orderFile.endsWith(".jpeg") || orderFile.endsWith(".png")){
|
||||
imgMap.put("contentType", "image/jpeg");
|
||||
}
|
||||
if (orderFile.endsWith(".mp4")){
|
||||
imgMap.put("contentType", "video/mp4");
|
||||
}
|
||||
fileMap.put("path",orderFile);
|
||||
imgMap.put("viewUrl", fileCenterService.getViewUrlByPathStyle(fileMap));
|
||||
resultList.add(imgMap);
|
||||
}
|
||||
}
|
||||
orderFileMap.put("imgList", resultList);
|
||||
page.add(orderFileMap);
|
||||
}
|
||||
return PageResult.<Map>builder().data(page).resp_code(0).count(result.getCount()).build();
|
||||
}
|
||||
return new PageResult<>();
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -145,7 +145,7 @@ public class OrderFileController {
|
||||
|
||||
@Operation(summary = "设备回传照片path记录创建")
|
||||
@PostMapping("/path")
|
||||
public void createOrderFileForPath(@RequestBody OrderFile orderFile) {
|
||||
public Result createOrderFileForPath(@RequestBody OrderFile orderFile) {
|
||||
|
||||
if (orderFile != null && orderFile.getOrderNo() != null) {
|
||||
Order order = orderService.getOrderByNumber(orderFile.getOrderNo());
|
||||
@@ -166,9 +166,10 @@ public class OrderFileController {
|
||||
order.setOrderStatus(OrderStatus.UPLOADING.getId());
|
||||
orderService.updateOrder(order);
|
||||
}
|
||||
return Result.succeed(order,"更新成功");
|
||||
}
|
||||
}
|
||||
|
||||
return Result.failed("素材内容为空");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.central.order.feign.fallback.FileCenterServiceFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -43,4 +44,7 @@ public interface FileCenterService {
|
||||
|
||||
@GetMapping("/files/path/style")
|
||||
String getViewUrlByPathStyle(@RequestParam("params") Map<String,String> params) ;
|
||||
|
||||
@GetMapping("/list/files")
|
||||
List<String> getListFiles(@RequestParam("prefix") String prefix) ;
|
||||
}
|
||||
|
||||
+6
@@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -55,6 +56,11 @@ public class FileCenterServiceFallbackFactory implements FallbackFactory<FileCen
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getListFiles(String prefix) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+10
-2
@@ -90,9 +90,17 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
||||
order.setOrderStatus(OrderStatus.UNPAID.getId());
|
||||
String orderNo = generateOrderNumber(order.getTourismId());
|
||||
order.setOrderNo(orderNo);
|
||||
|
||||
// 幂等性校验:同一用户、同一二维码、未完成订单只能有一条
|
||||
String lockKey = "order:create:" + order.getUserId() + ":" + order.getCodeId();
|
||||
try {
|
||||
return super.saveIdempotency(order, lock
|
||||
, ORDER_LOCK+orderNo, new QueryWrapper<Order>().eq("order_no", orderNo), "订单已存在");
|
||||
return super.saveIdempotency(order, lock,
|
||||
lockKey,
|
||||
new QueryWrapper<Order>()
|
||||
.eq("user_id", order.getUserId())
|
||||
.eq("code_id", order.getCodeId())
|
||||
.ne("order_status", OrderStatus.UNPAID.getId()), // 未支付订单
|
||||
"已存在未完成订单");
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ public class WxMiniSubscribeServiceImpl implements WxMiniSubscribeService {
|
||||
dataList.add(new WxMaSubscribeMessage.MsgData("thing4", processDesc)); // 服务阶段
|
||||
dataList.add(new WxMaSubscribeMessage.MsgData("character_string7", orderNo)); // 订单编号
|
||||
dataList.add(new WxMaSubscribeMessage.MsgData("time8", orderTime)); // 已付金额
|
||||
dataList.add(new WxMaSubscribeMessage.MsgData("thing6", result)); // 备注
|
||||
dataList.add(new WxMaSubscribeMessage.MsgData("thing6", processDesc)); // 备注
|
||||
msg.setData(dataList);
|
||||
|
||||
wxMaService.getSubscribeService().sendSubscribeMsg(msg);
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user