licailing 5 年之前
父節點
當前提交
ce65cc2fe7

+ 6 - 9
src/main/java/com/izouma/dingdong/domain/OrderInfo.java

@@ -24,9 +24,6 @@ public class OrderInfo extends BaseEntity {
     @ApiModelProperty(value = "用户ID", name = "userId")
     private Long userId;
 
-//    @ApiModelProperty(value = "用户昵称")
-//    private String nickname;
-
     //经度在前 纬度在后
     @ApiModelProperty(value = "用户地址经纬度", name = "location")
     private String location;
@@ -103,8 +100,8 @@ public class OrderInfo extends BaseEntity {
     @ApiModelProperty(value = "下单时间", name = "orderTime")
     private LocalDateTime orderTime;
 
-    @ApiModelProperty(value = "用户地址Id", name = "addressId")
-    private Long addressId;
+//    @ApiModelProperty(value = "用户地址Id", name = "addressId")
+//    private Long addressId;
 
     @ApiModelProperty(value = "配送地址", name = "userAddress")
     private String userAddress;
@@ -140,10 +137,10 @@ public class OrderInfo extends BaseEntity {
     @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.DETACH)
     @JoinColumn(name = "userId", insertable = false, updatable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
     private User user;
-
-    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.DETACH)
-    @JoinColumn(name = "merchantId", insertable = false, updatable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
-    private Merchant merchant;
+//
+//    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.DETACH)
+//    @JoinColumn(name = "merchantId", insertable = false, updatable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
+//    private Merchant merchant;
 
     @Enumerated(EnumType.STRING)
     @ApiModelProperty(value = "取消订单原因", name = "reason")

+ 44 - 17
src/main/java/com/izouma/dingdong/dto/OrderInfoDTO.java

@@ -19,23 +19,58 @@ public class OrderInfoDTO {
 
     private Long id;
 
-    @ApiModelProperty(value = "用户昵称")
-    private String nickname;
 
     @Enumerated(EnumType.STRING)
     @ApiModelProperty(value = "订单状态", name = "orderStatus")
     private OrderStatus status;
 
     //商家信息
-    @ApiModelProperty(value = "商户名称", name = "merchantShowName")
-    private String merchantShowName;
+    @ApiModelProperty(value = "商家用户Id",name = "mUserId")
+    private Long mUserId;
+
+    @ApiModelProperty(value = "商户名称", name = "merShowName")
+    private String merShowName;
+
+    @ApiModelProperty(value = "商家地址经纬度", name = "merLocation")
+    private String merLocation;
+
+    @ApiModelProperty(value = "商家地址", name = "merAddress")
+    private String merAddress;
 
     @Enumerated(EnumType.STRING)
     @ApiModelProperty(value = "商家状态", name = "merchantStatus")
     private MerchantStatus merchantStatus;
 
-    @ApiModelProperty(value = "备注", name = "remark")
-    private String remark;
+
+    //用户信息
+    @ApiModelProperty(value = "用户Id",name = "userId")
+    private Long userId;
+
+    @ApiModelProperty(value = "用户昵称")
+    private String nickname;
+
+    //经度在前 纬度在后
+    @ApiModelProperty(value = "用户地址经纬度", name = "location")
+    private String location;
+
+    @ApiModelProperty(value = "配送地址", name = "userAddress")
+    private String userAddress;
+
+
+    //骑手信息
+    @ApiModelProperty(value = "骑手用户Id",name = "rUserId")
+    private Long rUserId;
+
+    @ApiModelProperty(value = "骑手工号", name = "jobNumber")
+    private String jobNumber;
+
+    @ApiModelProperty(value = "骑手名称", name = "riderName")
+    private String riderName;
+
+    @Enumerated(EnumType.STRING)
+    @ApiModelProperty(value = "骑手状态", name = "riderStatus")
+    private RiderStatus riderStatus;
+
 
     //价格
     @ApiModelProperty(value = "包装价格", name = "packingPrice")
@@ -69,25 +104,17 @@ public class OrderInfoDTO {
     private Long userCouponId;
 
 
-    //配送信息
-    @ApiModelProperty(value = "骑手工号", name = "jobNumber")
-    private String jobNumber;
-
-    @ApiModelProperty(value = "骑手名称", name = "riderName")
-    private String riderName;
 
-    @Enumerated(EnumType.STRING)
-    @ApiModelProperty(value = "骑手状态", name = "riderStatus")
-    private RiderStatus riderStatus;
 
     //订单信息
+    @ApiModelProperty(value = "订单信息",name = "orderNo")
     private String orderNo;
 
     @ApiModelProperty(value = "下单时间", name = "orderTime")
     private LocalDateTime orderTime;
 
-    @ApiModelProperty(value = "配送地址", name = "userAddress")
-    private String userAddress;
+    @ApiModelProperty(value = "备注", name = "remark")
+    private String remark;
 
     @Enumerated(EnumType.STRING)
     @ApiModelProperty(value = "支付方式", name = "payMethod")

+ 3 - 2
src/main/java/com/izouma/dingdong/service/AppraisalService.java

@@ -39,6 +39,7 @@ public class AppraisalService {
     private MerchantRepo       merchantRepo;
     private FastAppraisalRepo  fastAppraisalRepo;
     private RiderRepo          riderRepo;
+    private UserRepo           userRepo;
 
     /*
     客户评价
@@ -258,8 +259,8 @@ public class AppraisalService {
     public ApDTO toDTO(Appraisal appraisal) {
         ApDTO dto = new ApDTO();
         BeanUtil.copyProperties(appraisal, dto);
-        BeanUtil.copyProperties(this.toMerDTO(appraisal),dto);
-        BeanUtil.copyProperties(this.toRidDTO(appraisal),dto);
+        BeanUtil.copyProperties(this.toMerDTO(appraisal), dto);
+        BeanUtil.copyProperties(this.toRidDTO(appraisal), dto);
         //查找骑手信息
         Rider rider = riderRepo.findById(appraisal.getRiderId()).orElseThrow(new BusinessException("无骑手"));
         User user = rider.getUser();

+ 1 - 1
src/main/java/com/izouma/dingdong/service/ConsumptionService.java

@@ -124,7 +124,7 @@ public class ConsumptionService {
             channel = "alipay";
         }
 
-        String subOpenid = null;
+        String subOpenid;
         if (orderInfo.getUser().getOpenId() != null) {
             subOpenid = orderInfo.getUser().getOpenId();
         } else {

+ 16 - 10
src/main/java/com/izouma/dingdong/service/OrderInfoService.java

@@ -278,7 +278,8 @@ public class OrderInfoService {
                     throw new BusinessException("订单状态错误");
                 }
                 //判断是否到达商家位置
-                Merchant merchant = orderInfo.getMerchant();
+                Merchant merchant = merchantRepo.findById(orderInfo.getMerchantId())
+                        .orElseThrow(new BusinessException("无商家"));
                 Double latitude1 = merchant.getLatitude();
                 Double longitude1 = merchant.getLongitude();
                 if (MapUtils.distance(longitude, latitude, longitude1, latitude1) > 5.0) {
@@ -305,10 +306,10 @@ public class OrderInfoService {
                     throw new BusinessException("订单状态错误");
                 }
                 //确认是否到达用户地址位置
-                Address address = addressRepo.findById(orderInfo.getAddressId())
-                        .orElseThrow(new BusinessException("地址不存在"));
-                Double latitude2 = address.getLatitude();
-                Double longitude2 = address.getLongitude();
+                String location = orderInfo.getLocation();
+                String[] split = location.split(",");
+                Double latitude2 = Double.valueOf(split[0]);
+                Double longitude2 = Double.valueOf(split[1]);
                 if (MapUtils.distance(longitude, latitude, longitude2, latitude2) > 5) {
                     throw new BusinessException("未到用户地点");
                 }
@@ -495,15 +496,20 @@ public class OrderInfoService {
         OrderInfoDTO dto = new OrderInfoDTO();
         BeanUtil.copyProperties(orderInfo, dto);
         if (orderInfo.getRiderId() != null) {
-            riderRepo.findById(orderInfo.getRiderId()).ifPresent(r -> {
-                dto.setJobNumber(r.getJobNumber());
-                dto.setRiderName(r.getUser().getNickname());
+            riderRepo.findById(orderInfo.getRiderId()).ifPresent(rider -> {
+                dto.setJobNumber(rider.getJobNumber());
+                dto.setRiderName(rider.getUser().getNickname());
+                dto.setRUserId(rider.getUserId());
             });
         }
         dto.setNickname(orderInfo.getUser().getNickname());
 //        userRepo.findById(orderInfo.getUserId()).ifPresent(u -> dto.setNickname(u.getNickname()));
-        dto.setMerchantShowName(orderInfo.getMerchant().getShowName());
-//        merchantRepo.findById(orderInfo.getMerchantId()).ifPresent(m -> dto.setMerchantShowName(m.getShowName()));
+//        dto.setMerchantShowName(orderInfo.getMerchant().getShowName());
+        merchantRepo.findById(orderInfo.getMerchantId()).ifPresent(merchant -> {
+            dto.setMerShowName(merchant.getShowName());
+            dto.setMerLocation(merchant.getLongitude() + "," + merchant.getLatitude());
+            dto.setMerAddress(merchant.getAddress());
+        });
 
         return dto;
     }

+ 3 - 1
src/main/java/com/izouma/dingdong/service/rider/RiderService.java

@@ -15,6 +15,7 @@ import com.izouma.dingdong.repo.MoneyRecordRepo;
 import com.izouma.dingdong.repo.OrderInfoRepo;
 import com.izouma.dingdong.repo.UserRepo;
 import com.izouma.dingdong.repo.VerifiedRepo;
+import com.izouma.dingdong.repo.merchant.MerchantRepo;
 import com.izouma.dingdong.repo.rider.RiderLocationRepo;
 import com.izouma.dingdong.repo.rider.RiderRepo;
 import com.izouma.dingdong.repo.rider.RiderSignRepo;
@@ -43,6 +44,7 @@ public class RiderService {
     private RiderLocationRepo       riderLocationRepo;
     private SysConfigService        sysConfigService;
     private VerifiedRepo            verifiedRepo;
+    private MerchantRepo            merchantRepo;
 
     /*
     骑手注册
@@ -237,7 +239,7 @@ public class RiderService {
                     //是否支持货到付款
                     t = this.canCash(d.getRiderId());
                 }
-                Merchant merchant = orderInfo.getMerchant();
+                Merchant merchant = merchantRepo.findById(orderInfo.getMerchantId()).orElseThrow(new BusinessException("无骑手"));
                 Double distance = MapUtils.distance(merchant.getLongitude(), merchant.getLatitude(), d.getLongitude(), d
                         .getLatitude());
                 //所有附近的骑手的距离

+ 1 - 0
src/main/vue/src/views/merchant/GoodsEdit.vue

@@ -4,6 +4,7 @@
                  style="max-width: 500px;">
             <el-form-item prop="merchantId" label="商户ID">
                 <el-input type="number" v-model="formData.merchantId"></el-input>
+
             </el-form-item>
             <el-form-item prop="name" label="名称">
                 <el-input v-model="formData.name"></el-input>

+ 1 - 1
src/main/vue/src/views/merchant/GoodsList.vue

@@ -100,7 +100,7 @@
                     fixed="right"
                     min-width="150">
                 <template slot-scope="{row}">
-                    <!-- <el-button @click="editRow(row)" type="primary" size="mini" plain>详情</el-button>-->
+                     <el-button @click="editRow(row)" type="primary" size="mini" plain>详情</el-button>
                     <el-button @click="take(row)" type="warning" size="mini" plain v-if="row.status === 'PASS'">
                         {{row.takeOff?'上架':'下架'}}
                     </el-button>