11
This commit is contained in:
1 parent
4edabb8da5
commit
53444853de
10 files changed
+113
-66
No files matched your search
+4
-1
@@ -3,8 +3,8 @@ package com.bsd.pjcloud.hard.api.dto.app;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardCreateCarDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardParentCarEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@@ -38,4 +38,7 @@ public class HardCarSaveOrUpdateDto {
|
||||
|
||||
@Schema(description = "订单类型渠道id")
|
||||
private Long orderSourceTypeId;
|
||||
|
||||
@Schema(description = "外卖配置")
|
||||
private HardParentCarEntity.TakeOutSetting takeOutSetting;
|
||||
}
|
||||
+1
-1
@@ -39,7 +39,7 @@ public class HardAppCreateOrderDto {
|
||||
private Integer customPrice;
|
||||
|
||||
// 配送价格(分)
|
||||
private Integer deliveryPrice;
|
||||
// private Integer deliveryPrice;
|
||||
|
||||
// 商户id
|
||||
private Long merchantId;
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ public class HardAppCreateTakeOutOrderDto {
|
||||
/**
|
||||
* 配送价格(分)
|
||||
*/
|
||||
private Integer deliveryPrice;
|
||||
// private Integer deliveryPrice;
|
||||
|
||||
/**
|
||||
* 外卖地址
|
||||
|
||||
+1
@@ -2,6 +2,7 @@ package com.bsd.pjcloud.hard.api.entity.order;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import com.bsd.pjcloud.common.core.util.TenantTable;
|
||||
|
||||
+79
-52
@@ -2,9 +2,11 @@ package com.bsd.pjcloud.hard.api.entity.order;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import com.bsd.pjcloud.common.core.util.TenantTable;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
@@ -18,83 +20,108 @@ import java.time.LocalDateTime;
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@TenantTable
|
||||
@TableName("hard_parent_car")
|
||||
@TableName(value = "hard_parent_car", autoResultMap = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "父订单表")
|
||||
public class HardParentCarEntity extends Model<HardParentCarEntity> {
|
||||
|
||||
|
||||
/**
|
||||
* 标号
|
||||
*/
|
||||
/**
|
||||
* 标号
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description="标号")
|
||||
@Schema(description = "标号")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@Schema(description="用户id")
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@Schema(description = "用户id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 商户id
|
||||
*/
|
||||
@Schema(description="商户id")
|
||||
/**
|
||||
* 商户id
|
||||
*/
|
||||
@Schema(description = "商户id")
|
||||
private Long merchantId;
|
||||
|
||||
/**
|
||||
* 硬件设备类型
|
||||
*/
|
||||
@Schema(description="硬件设备类型")
|
||||
private String hardType;
|
||||
/**
|
||||
* 硬件设备类型
|
||||
*/
|
||||
@Schema(description = "硬件设备类型")
|
||||
private String hardType;
|
||||
|
||||
|
||||
/**
|
||||
* 订单状态
|
||||
*/
|
||||
@Schema(description="订单状态")
|
||||
/**
|
||||
* 订单状态
|
||||
*/
|
||||
@Schema(description = "订单状态")
|
||||
private String orderStatus;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="创建人")
|
||||
/**
|
||||
* 外卖配置json
|
||||
*/
|
||||
@Schema(description = "外卖配置json")
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private TakeOutSetting takeOutSettingJson;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "创建人")
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="创建时间")
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description="修改人")
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description = "修改人")
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description="修改时间")
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description = "修改时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 删除标记
|
||||
*/
|
||||
/**
|
||||
* 删除标记
|
||||
*/
|
||||
@TableLogic
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="删除标记")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "删除标记")
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@Schema(description="租户ID")
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@Schema(description = "租户ID")
|
||||
private Long tenantId;
|
||||
|
||||
@Data
|
||||
public static class TakeOutSetting {
|
||||
/**
|
||||
* 起送价格(分)
|
||||
*/
|
||||
private Integer minDeliveryAmt;
|
||||
|
||||
/**
|
||||
* 商家配送费(分)
|
||||
*/
|
||||
private Integer mchTakeOutAmt;
|
||||
|
||||
/**
|
||||
* 用户配送费(分)
|
||||
*/
|
||||
private Integer userTakeOutAmt;
|
||||
}
|
||||
|
||||
}
|
||||
+9
@@ -17,10 +17,12 @@ import com.bsd.pjcloud.hard.api.dto.order.HardCarDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardAfterSaleCarEntity;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardCarEntity;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardParentCarEntity;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardCarVo;
|
||||
import com.bsd.pjcloud.hard.service.HardAfterSaleCarService;
|
||||
import com.bsd.pjcloud.hard.service.HardCarService;
|
||||
import com.bsd.pjcloud.hard.service.HardOrderService;
|
||||
import com.bsd.pjcloud.hard.service.HardParentCarService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
@@ -47,10 +49,17 @@ import java.util.List;
|
||||
public class HardCarController {
|
||||
|
||||
private final HardCarService hardCarService;
|
||||
private final HardParentCarService hardParentCarService;
|
||||
private final HardOrderService hardOrderService;
|
||||
private final HardAfterSaleCarService hardAfterSaleCarService;
|
||||
|
||||
/* ************************************* start app start ************************************* */
|
||||
@GetMapping("/app/parent-car")
|
||||
@Operation(summary = "查询父亲购物车")
|
||||
public R<HardParentCarEntity> appGetParentCar(@RequestParam Long id) {
|
||||
return R.ok(hardParentCarService.getById(id));
|
||||
}
|
||||
|
||||
@GetMapping("/app/mch-detail")
|
||||
@Operation(summary = "根据商户id查询当前用户购物车")
|
||||
public R<List<HardCarVo>> appMchDetail(@RequestParam Long merchantId, @RequestParam HardTypeEnum hardType) {
|
||||
|
||||
-1
@@ -239,7 +239,6 @@ public class HardOrderController {
|
||||
.payType(HardPayTypeEnum.WALLET_DEFAULT)
|
||||
.apptId(null)
|
||||
.address(dto.getAddress())
|
||||
.deliveryPrice(dto.getDeliveryPrice())
|
||||
.appt(dto.getAppt())
|
||||
.build();
|
||||
return R.ok(hardwareOrderService.appCreateTakeOutOrder(createOrderDto));
|
||||
|
||||
+7
-1
@@ -138,10 +138,16 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
|
||||
if (ObjectUtil.isNotEmpty(carList)) {
|
||||
getSelf().appCreateCard(parentCar.getId(), dto.getHardType(), dto.getOrderType(), carList);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(dto.getTakeOutSetting())) {
|
||||
HardParentCarEntity updateParentCar = new HardParentCarEntity();
|
||||
updateParentCar.setId(parentCar.getId());
|
||||
updateParentCar.setTakeOutSettingJson(dto.getTakeOutSetting());
|
||||
hardParentCarMapper.updateById(updateParentCar);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// 添加父订单
|
||||
HardParentCarEntity parentCarObj = HardParentCarEntity.builder().userId(dto.getUserId()).merchantId(dto.getMerchantId()).hardType(dto.getHardType().getType()).orderStatus(HardOrderStatusEnum.CREATE.getType()).build();
|
||||
HardParentCarEntity parentCarObj = HardParentCarEntity.builder().userId(dto.getUserId()).merchantId(dto.getMerchantId()).hardType(dto.getHardType().getType()).orderStatus(HardOrderStatusEnum.CREATE.getType()).takeOutSettingJson(dto.getTakeOutSetting()).build();
|
||||
hardParentCarMapper.insert(parentCarObj);
|
||||
// 添加购物车
|
||||
getSelf().appCreateCard(parentCarObj.getId(), dto.getHardType(), dto.getOrderType(), carList);
|
||||
|
||||
+11
-7
@@ -138,7 +138,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
|
||||
private final HardManagerService hardManagerService;
|
||||
private final HardCarService hardCarService;
|
||||
private final HardParentCarServiceImpl hardParentCarServiceImpl;
|
||||
private final HardParentCarService hardParentCarService;
|
||||
@Lazy
|
||||
private final HardInvoiceService hardInvoiceService;
|
||||
@Lazy
|
||||
@@ -632,14 +632,18 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
validateTakeOutApptAgainstMerchantJobTime(hardManager, dto.getAppt());
|
||||
// 查询父购物车
|
||||
List<HardCarEntity> carList = hardCarService.getByParentCarId(dto.getCarParentId());
|
||||
if (ObjectUtil.isEmpty(carList)) throw new RuntimeException("购物车不存在");
|
||||
|
||||
if (ObjectUtil.isEmpty(carList)) {
|
||||
throw new RuntimeException("购物车不存在");
|
||||
}
|
||||
Integer balance = wallet.getBalance();
|
||||
int carPrice = (int) carList.stream().mapToLong(HardCarEntity::getTotalPrice).sum();
|
||||
int totalPrice = carPrice;
|
||||
int deliveryPrice = 0;
|
||||
// 增加配送费
|
||||
if (ObjectUtil.isNotEmpty(dto.getDeliveryPrice())) {
|
||||
totalPrice += dto.getDeliveryPrice();
|
||||
if (ObjectUtil.isNotEmpty(parentCar.getTakeOutSettingJson()) && ObjectUtil.isNotEmpty(parentCar.getTakeOutSettingJson().getUserTakeOutAmt())) {
|
||||
HardParentCarEntity.TakeOutSetting takeOutSetting = parentCar.getTakeOutSettingJson();
|
||||
deliveryPrice = takeOutSetting.getUserTakeOutAmt();
|
||||
totalPrice += deliveryPrice;
|
||||
}
|
||||
if (balance < totalPrice) {
|
||||
throw new RuntimeException("钱包余额不足");
|
||||
@@ -674,7 +678,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
.extraPrice(0)
|
||||
.payPrice(totalPrice)
|
||||
.isOfflineOrder(YesNoEnum.NO.getCode())
|
||||
.deliveryPrice(dto.getDeliveryPrice())
|
||||
.deliveryPrice(deliveryPrice)
|
||||
.productDesc(subject)
|
||||
.build();
|
||||
if (ObjectUtil.isNotEmpty(dto.getAddress())) {
|
||||
@@ -1340,7 +1344,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
// 父购物车订单表订单状态
|
||||
if (ObjectUtil.isNotEmpty(order.getParentCarId())) {
|
||||
HardParentCarEntity updateParentCar = HardParentCarEntity.builder().id(order.getParentCarId()).orderStatus(HardOrderStatusEnum.PAY.getType()).build();
|
||||
hardParentCarServiceImpl.updateById(updateParentCar);
|
||||
hardParentCarService.updateById(updateParentCar);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-2
@@ -7,8 +7,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.bsd.pjcloud.admin.api.dto.UserInfo;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.async.OfflineCar;
|
||||
import com.bsd.pjcloud.hard.api.dto.async.OfflineOrder;
|
||||
|
||||
Reference in new issue
Block a user