Selaa lähdekoodia

修改用户订单列表

qmj 1 kuukausi sitten
vanhempi
sitoutus
ddcf69bad9

+ 17 - 3
ruoyi-admin/src/main/java/com/ruoyi/app/order/PosOrderQsOprateController.java

@@ -38,6 +38,7 @@ import org.springframework.web.bind.annotation.*;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
+import com.ruoyi.app.order.dto.PickupOrderInput;
 
 @RestController
 @RequestMapping("/system/orderQsOprate")
@@ -90,13 +91,13 @@ public class PosOrderQsOprateController extends BaseController {
      */
     @Anonymous
     @Auth
-    @GetMapping("/pickupOrder")
+    @PostMapping("/pickupOrder")
     @Transactional(rollbackFor = Exception.class)
-    public AjaxResult pickupOrder(@RequestHeader String token, @RequestParam Long id) {
+    public AjaxResult pickupOrder(@RequestHeader String token, @RequestBody PickupOrderInput input) {
         JwtUtil jwtUtil = new JwtUtil();
         PayPush push = new PayPush();
         String qsId = jwtUtil.getusid(token);
-        PosOrder order = posOrderService.getOne(new LambdaQueryWrapper<PosOrder>().eq(PosOrder::getId, id));
+        PosOrder order = posOrderService.getOne(new LambdaQueryWrapper<PosOrder>().eq(PosOrder::getId, input.getId()));
         if (order == null) {
             throw new ServiceException(MessageUtils.message("no.order.not.found"));
         }
@@ -106,6 +107,7 @@ public class PosOrderQsOprateController extends BaseController {
         PosOrder posOrder = new PosOrder();
         posOrder.setId(order.getId());
         posOrder.setDeliveryStatus(2L);
+        posOrder.setQsImg(input.getQsImg());
         return setOrderQsState(posOrder, qsId, push);
     }
 
@@ -309,6 +311,17 @@ public class PosOrderQsOprateController extends BaseController {
                 posStoreService.listByIds(mdIds).stream().collect(Collectors.toMap(PosStore::getId, s -> s));
         JSONArray arr=new JSONArray();
         for (PosOrder order : result.getRecords()) {
+            // 计算距离(km)
+            if (order.getLongitude() != null && order.getLatitude() != null && longitude != null && latitude != null) {
+                double lat1 = Math.toRadians(order.getLatitude().doubleValue());
+                double lat2 = Math.toRadians(latitude.doubleValue());
+                double dlat = lat2 - lat1;
+                double dlng = Math.toRadians(longitude.doubleValue() - order.getLongitude().doubleValue());
+                double a = Math.sin(dlat / 2) * Math.sin(dlat / 2)
+                        + Math.cos(lat1) * Math.cos(lat2) * Math.sin(dlng / 2) * Math.sin(dlng / 2);
+                double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
+                order.setJuli(Math.round(6371 * c * 100.0) / 100.0);
+            }
             // 自动序列化所有PosOrder字段,新增字段无需手动添加
             JSONObject org = JSON.parseObject(
                     JSON.toJSONStringWithDateFormat(order, "yyyy-MM-dd HH:mm:ss")
@@ -316,6 +329,7 @@ public class PosOrderQsOprateController extends BaseController {
             // 以下为非PosOrder字段或需要特殊处理的字段
 
             org.put("store", storeMap.get(order.getMdId().intValue()));
+
             arr.add(org);
         }
         JSONObject org=new JSONObject();