fix[订单模块]:任务下发设备后更新任务状态为服务中(Doing)
This commit is contained in:
+9
-4
@@ -13,6 +13,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -29,8 +30,8 @@ import java.util.Map;
|
|||||||
@RestController
|
@RestController
|
||||||
public class ApiDeviceController {
|
public class ApiDeviceController {
|
||||||
|
|
||||||
// @Value("${jetlinks.server.url}")
|
@Value("${jetlinks.server.baseUrl}")
|
||||||
private String baseUrl = "http://119.45.169.13:8848/";
|
private String baseUrl;// = "http://119.45.169.13:8848/";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private HeaderUtils headerUtils;
|
private HeaderUtils headerUtils;
|
||||||
@@ -70,7 +71,7 @@ public class ApiDeviceController {
|
|||||||
JsonObject jsonObject;
|
JsonObject jsonObject;
|
||||||
String property = MapUtil.getStrValue(param, "control");
|
String property = MapUtil.getStrValue(param, "control");
|
||||||
String value = MapUtil.getStrValue(param, "order_no");
|
String value = MapUtil.getStrValue(param, "order_no");
|
||||||
System.out.println("order_no"+value);
|
// System.out.println("order_no"+value);
|
||||||
if (value == null || "".equals(value)) {
|
if (value == null || "".equals(value)) {
|
||||||
return Result.succeed("暂未开放控制权限");
|
return Result.succeed("暂未开放控制权限");
|
||||||
}
|
}
|
||||||
@@ -91,7 +92,11 @@ public class ApiDeviceController {
|
|||||||
return Result.succeed("暂未开放控制权限");
|
return Result.succeed("暂未开放控制权限");
|
||||||
}
|
}
|
||||||
Map<String, String> result = requestUtils.getPostRequestResultMap(url, jsonObject.toString());
|
Map<String, String> result = requestUtils.getPostRequestResultMap(url, jsonObject.toString());
|
||||||
return Result.succeed(result,"设置成功");
|
Result result1 = orderCenterService.updateOrderStatusDoing(value);
|
||||||
|
if (result1.getResp_code() != null && result1.getResp_code() == 1){
|
||||||
|
return Result.succeed(result,"设置成功");
|
||||||
|
}
|
||||||
|
return Result.failed("请重试");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return Result.failed(e.getMessage());
|
return Result.failed(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
+4
@@ -5,6 +5,7 @@ import com.central.common.model.Result;
|
|||||||
import com.central.device.feign.fallback.OrderCenterServiceFallbackFactory;
|
import com.central.device.feign.fallback.OrderCenterServiceFallbackFactory;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PatchMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,4 +21,7 @@ public interface OrderCenterService {
|
|||||||
|
|
||||||
@GetMapping("/status/{orderNo}")
|
@GetMapping("/status/{orderNo}")
|
||||||
Result getOrderExecStatus(@PathVariable("orderNo") String orderNo);
|
Result getOrderExecStatus(@PathVariable("orderNo") String orderNo);
|
||||||
|
|
||||||
|
@PatchMapping("/status/{orderNo}")
|
||||||
|
Result updateOrderStatusDoing(@PathVariable("orderNo") String orderNo);
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -27,6 +27,11 @@ public class OrderCenterServiceFallbackFactory implements FallbackFactory<OrderC
|
|||||||
public Result getOrderExecStatus(String orderNo) {
|
public Result getOrderExecStatus(String orderNo) {
|
||||||
return Result.failed(orderNo);
|
return Result.failed(orderNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result updateOrderStatusDoing(String orderNo) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -19,11 +19,11 @@ import java.util.stream.Collectors;
|
|||||||
@Component
|
@Component
|
||||||
public class HeaderUtils {
|
public class HeaderUtils {
|
||||||
|
|
||||||
// @Value("${jetlinks.clientId}")
|
@Value("${jetlinks.clientId}")
|
||||||
private String xClientId = "WFMfEGS8iHrEPRBH" ;
|
private String xClientId;// = "WFMfEGS8iHrEPRBH" ;
|
||||||
|
|
||||||
// @Value("${jetlinks.secureKey}")
|
@Value("${jetlinks.secureKey}")
|
||||||
private String secureKey = "ihat3zHC6T7xPZYFAEnG3tExQiFANd2n" ;
|
private String secureKey;// = "ihat3zHC6T7xPZYFAEnG3tExQiFANd2n" ;
|
||||||
public Map<String, String> createHeadersOfParams(Map<String, Object> params) {
|
public Map<String, String> createHeadersOfParams(Map<String, Object> params) {
|
||||||
//时间戳
|
//时间戳
|
||||||
String xTimestamp = String.valueOf(System.currentTimeMillis());
|
String xTimestamp = String.valueOf(System.currentTimeMillis());
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ knife4j:
|
|||||||
setting:
|
setting:
|
||||||
swagger-model-name: 设备中心接口文档
|
swagger-model-name: 设备中心接口文档
|
||||||
|
|
||||||
|
jetlinks:
|
||||||
|
clientId: WFMfEGS8iHrEPRBH
|
||||||
|
secureKey: ihat3zHC6T7xPZYFAEnG3tExQiFANd2n
|
||||||
|
server:
|
||||||
|
baseUrl: http://119.45.169.13:8848/
|
||||||
|
|
||||||
#审计日志
|
#审计日志
|
||||||
# audit-log:
|
# audit-log:
|
||||||
|
|||||||
+21
-2
@@ -307,7 +307,7 @@ public class OrderController {
|
|||||||
|
|
||||||
@Operation(summary = "更新订单支付完成状态")
|
@Operation(summary = "更新订单支付完成状态")
|
||||||
@PatchMapping("/update/{orderNo}")
|
@PatchMapping("/update/{orderNo}")
|
||||||
public Result<String> updateOrderStatus(@PathVariable String orderNo) {
|
public Result<String> updateOrderStatusPaid(@PathVariable String orderNo) {
|
||||||
Transaction transaction = queryOrderByOutTradeNo(orderNo);
|
Transaction transaction = queryOrderByOutTradeNo(orderNo);
|
||||||
if (transaction != null && transaction.getTradeState().equals(Transaction.TradeStateEnum.SUCCESS)){
|
if (transaction != null && transaction.getTradeState().equals(Transaction.TradeStateEnum.SUCCESS)){
|
||||||
Order order = orderService.getOrderByNumber(transaction.getOutTradeNo());
|
Order order = orderService.getOrderByNumber(transaction.getOutTradeNo());
|
||||||
@@ -320,9 +320,28 @@ public class OrderController {
|
|||||||
return Result.failed("未查询到订单数据");
|
return Result.failed("未查询到订单数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "更新订单正在服务中状态")
|
||||||
|
@PatchMapping("/status/{orderNo}")
|
||||||
|
public Result<String> updateOrderStatusDoing(@PathVariable String orderNo) {
|
||||||
|
Order order = orderService.getOrderByNumber(orderNo);
|
||||||
|
if (order != null) {
|
||||||
|
if (order.getOrderStatus().equals(OrderStatus.PAID.getId())){
|
||||||
|
order.setOrderStatus(OrderStatus.DOING.getId());
|
||||||
|
boolean res = orderService.updateOrder(order);
|
||||||
|
if (res){
|
||||||
|
return Result.succeed("更新成功");
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
return Result.failed("已更新");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return Result.failed("未查询到订单数据");
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "机库更新订单完成状态")
|
@Operation(summary = "机库更新订单完成状态")
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
public Result<String> updateOrderStatusComplete(@RequestBody Map payload) {
|
public Result<String> updateOrderStatusCompleted(@RequestBody Map payload) {
|
||||||
Order order = orderService.getOrderByNumber(payload.get("orderNo").toString());
|
Order order = orderService.getOrderByNumber(payload.get("orderNo").toString());
|
||||||
if (order != null) {
|
if (order != null) {
|
||||||
if (order.getOrderStatus().equals(OrderStatus.PAID.getId())){
|
if (order.getOrderStatus().equals(OrderStatus.PAID.getId())){
|
||||||
|
|||||||
Reference in New Issue
Block a user