# Conflicts:
#	pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardOrderController.java
This commit is contained in:
zjf committed 2026-04-13 05:51:44 +08:00
commit 6cdc873a02
55 files changed
+1229 -85

No files matched your search

@@ -0,0 +1,18 @@
package com.bsd.pjcloud.hard.api.dto.hard;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
@Data
public class HandCancelActCodeDto {
@Schema(description = "用户id不能为空")
@NotNull(message = "核销活动子id不能为空")
private Long actItemId;
@Schema(description = "用户id")
@NotNull(message = "用户id不能为空")
private Long userId;
}
@@ -4,7 +4,6 @@ import com.bsd.pjcloud.hard.api.constant.HardTypeEnum;
import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum;
import com.bsd.pjcloud.hard.api.constant.order.HardPayTypeEnum;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
@@ -56,7 +55,10 @@ public class HardAppCreateOrderDto {
private Long apptId;
// 地址
private HardAppTakeOutAddress address;
private HardAppTakeOutAddressDto address;
// 预约时间信息
private HardAppTakeOutApptDto appt;
@Schema(description = "IMMEDIATE立即送 | SCHEDULED预约时段")
private String expectDeliveryType;
@@ -26,7 +26,13 @@ public class HardAppCreateTakeOutOrderDto {
* 外卖地址
*/
@NotNull(message = "外卖地址不能为空")
private HardAppTakeOutAddress address;
private HardAppTakeOutAddressDto address;
/**
* 外卖预约信息
*/
@NotNull(message = "预约时间信息不能为空")
private HardAppTakeOutApptDto appt;
@Schema(description = "IMMEDIATE立即送(默认)| SCHEDULED预约时段")
private String expectDeliveryType;
@@ -1,11 +1,10 @@
package com.bsd.pjcloud.hard.api.dto.order.app;
import cn.hutool.core.util.ObjectUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class HardAppTakeOutAddress {
public class HardAppTakeOutAddressDto {
/**
* 地址id
@@ -0,0 +1,46 @@
package com.bsd.pjcloud.hard.api.dto.order.app;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
@Data
public class HardAppTakeOutApptDto {
/**
* IMMEDIATE:立即送;SCHEDULED:预约时段;
*/
@Schema(description = "IMMEDIATE:立即送;SCHEDULED:预约时段;")
private String expectDeliveryType;
/**
* 预约送达日历日(仅SCHEDULED使用)
*/
@Schema(description = "预约送达日历日(仅SCHEDULED使用)")
private LocalDate expectDeliveryDate;
/**
* 预约时段开始时间
*/
@Schema(description = "预约时段开始时间")
@JsonFormat(pattern = "HH:mm:ss")
private LocalTime expectDeliveryStart;
/**
* 预约时段结束时间
*/
@Schema(description = "预约时段结束时间")
@JsonFormat(pattern = "HH:mm:ss")
private LocalTime expectDeliveryEnd;
/**
* 立即送时预计送达时间点可选
*/
@Schema(description = "立即送时预计送达时间点可选")
private LocalDateTime expectArriveTime;
}
@@ -0,0 +1,115 @@
package com.bsd.pjcloud.hard.api.entity.order;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.bsd.pjcloud.common.core.util.TenantTable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
/**
* 外卖送达时间
*/
@Data
@TenantTable
@TableName("hard_take_out_appt")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "外卖送达时间")
public class HardTakeOutApptEntity extends Model<HardTakeOutApptEntity> {
/**
* 编号
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "编号")
private Long id;
/**
* 用户id
*/
@Schema(description = "用户id")
private Long userId;
/**
* 订单id
*/
@Schema(description = "订单id")
private Long orderId;
/**
* IMMEDIATE:立即送;SCHEDULED:预约时段;
*/
@Schema(description = "IMMEDIATE:立即送;SCHEDULED:预约时段;")
private String expectDeliveryType;
/**
* 预约送达日历日(仅SCHEDULED使用)
*/
@Schema(description = "预约送达日历日(仅SCHEDULED使用)")
private LocalDate expectDeliveryDate;
/**
* 预约时段开始时间
*/
@Schema(description = "预约时段开始时间")
private LocalTime expectDeliveryStart;
/**
* 预约时段结束时间
*/
@Schema(description = "预约时段结束时间")
private LocalTime expectDeliveryEnd;
/**
* 立即送时预计送达时间点可选
*/
@Schema(description = "立即送时预计送达时间点可选")
private LocalDateTime expectArriveTime;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description = "创建人")
private String createBy;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description = "创建时间")
private LocalDateTime createTime;
/**
* 修改人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description = "修改人")
private String updateBy;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description = "修改时间")
private LocalDateTime updateTime;
/**
* 删除标记
*/
@TableLogic
@TableField(fill = FieldFill.INSERT)
@Schema(description = "删除标记")
private String delFlag;
/**
* 租户ID
*/
@Schema(description = "租户ID")
private Long tenantId;
}
@@ -9,10 +9,7 @@ import com.bsd.pjcloud.hard.api.constant.HardProductNatureEnum;
import com.bsd.pjcloud.hard.api.constant.HardTypeEnum;
import com.bsd.pjcloud.hard.api.constant.order.HardPayTypeEnum;
import com.bsd.pjcloud.hard.api.dto.async.SyncOfflineReqVo;
import com.bsd.pjcloud.hard.api.dto.hard.HandCancelCodeDto;
import com.bsd.pjcloud.hard.api.dto.hard.HardBindDto;
import com.bsd.pjcloud.hard.api.dto.hard.HardCreateOrderDto;
import com.bsd.pjcloud.hard.api.dto.hard.HardDoneHardQrCodeScanOrderDto;
import com.bsd.pjcloud.hard.api.dto.hard.*;
import com.bsd.pjcloud.hard.api.dto.order.HardChartLatitudeVo;
import com.bsd.pjcloud.hard.api.dto.order.HardCreateCarDto;
import com.bsd.pjcloud.hard.api.vo.HardInvoiceVo;
@@ -129,6 +126,13 @@ public class HardApiController {
return R.ok(hardwareOrderService.handCancelCode(dto));
}
@PostMapping("/cancel-act-code")
@Operation(summary = "核销二维码")
@Idempotent(expireTime = 10, key = "'/hard-api/ad/cancel-act-code' + #dto.getActItemId() ", info = "正在核销中,请勿重复操作")
public R<Boolean> handCancelActCode(@Validated @RequestBody HandCancelActCodeDto dto) {
return R.ok(hardwareOrderService.handCancelActCode(dto));
}
@GetMapping("/generate-invoice")
@Operation(summary = "生成发票")
@Idempotent(expireTime = 10, info = "正在生成中,请勿重复操作")
@@ -221,11 +221,7 @@ public class HardOrderController {
.apptId(null)
.address(dto.getAddress())
.deliveryPrice(dto.getDeliveryPrice())
.expectDeliveryType(dto.getExpectDeliveryType())
.expectDeliveryDate(dto.getExpectDeliveryDate())
.expectDeliveryStart(dto.getExpectDeliveryStart())
.expectDeliveryEnd(dto.getExpectDeliveryEnd())
.expectArriveTime(dto.getExpectArriveTime())
.appt(dto.getAppt())
.build();
return R.ok(hardwareOrderService.appCreateTakeOutOrder(createOrderDto));
}
@@ -0,0 +1,10 @@
package com.bsd.pjcloud.hard.mapper.order;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.hard.api.entity.order.HardTakeOutApptEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface HardTakeOutApptMapper extends PjcloudBaseMapper<HardTakeOutApptEntity> {
}
@@ -10,6 +10,7 @@ import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum;
import com.bsd.pjcloud.hard.api.constant.order.HardPayTypeEnum;
import com.bsd.pjcloud.hard.api.dto.hard.HandCancelActCodeDto;
import com.bsd.pjcloud.hard.api.dto.hard.HandCancelCodeDto;
import com.bsd.pjcloud.hard.api.dto.hard.HardCreateOrderDto;
import com.bsd.pjcloud.hard.api.dto.hard.HardDoneHardQrCodeScanOrderDto;
@@ -159,6 +160,11 @@ public interface HardOrderService extends IService<HardOrderEntity> {
*/
Boolean handCancelCode(HandCancelCodeDto dto);
/**
* 核销二维码
*/
Boolean handCancelActCode(HandCancelActCodeDto dto);
/**
* 创建订单后发送mq消息
*/
@@ -0,0 +1,8 @@
package com.bsd.pjcloud.hard.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.hard.api.entity.order.HardTakeOutApptEntity;
public interface HardTakeOutApptService extends IService<HardTakeOutApptEntity> {
}
@@ -45,6 +45,7 @@ import com.bsd.pjcloud.hard.api.constant.order.HardPayTypeEnum;
import com.bsd.pjcloud.hard.api.constant.xfj.HardXfjTypeEnum;
import com.bsd.pjcloud.hard.api.dto.ali.AliMicropayDto;
import com.bsd.pjcloud.hard.api.dto.ali.AliReverseDto;
import com.bsd.pjcloud.hard.api.dto.hard.HandCancelActCodeDto;
import com.bsd.pjcloud.hard.api.dto.hard.HardDoneHardQrCodeScanOrderDto;
import com.bsd.pjcloud.hard.api.dto.manager.HardManagerDto;
import com.bsd.pjcloud.hard.api.dto.hard.HandCancelCodeDto;
@@ -62,10 +63,7 @@ import com.bsd.pjcloud.hard.api.dto.wechat.WechatMicropayDto;
import com.bsd.pjcloud.hard.api.entity.HardApptEntity;
import com.bsd.pjcloud.hard.api.entity.HardThirdMiOrderEntity;
import com.bsd.pjcloud.hard.api.entity.manager.HardManagerEntity;
import com.bsd.pjcloud.hard.api.entity.order.HardCarEntity;
import com.bsd.pjcloud.hard.api.entity.order.HardOrderAddressEntity;
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
import com.bsd.pjcloud.hard.api.entity.order.HardParentCarEntity;
import com.bsd.pjcloud.hard.api.entity.order.*;
import com.bsd.pjcloud.hard.api.entity.spu.HardSpuEntity;
import com.bsd.pjcloud.hard.api.utils.HardUtil;
import com.bsd.pjcloud.hard.api.vo.HardDoorFlowVo;
@@ -93,6 +91,7 @@ import com.bsd.pjcloud.wallet.api.constant.mch.WalletMchRulePriceTypeEnum;
import com.bsd.pjcloud.wallet.api.constant.mch.WalletMchSupType;
import com.bsd.pjcloud.wallet.api.dto.WalletBalanceTransactionDto;
import com.bsd.pjcloud.wallet.api.dto.act.ActCancelItemDto;
import com.bsd.pjcloud.wallet.api.dto.act.ActComCancelDto;
import com.bsd.pjcloud.wallet.api.entity.WalletCodeUseEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity;
@@ -102,6 +101,7 @@ import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo;
import com.bsd.pjcloud.wallet.api.vo.act.ActCancelItemVo;
import com.bsd.pjcloud.wallet.api.vo.act.ActComItemVo;
import com.bsd.pjcloud.wallet.api.vo.mch.MchPickUpVo;
import com.bsd.pjcloud.wallet.api.vo.mch.MchRuleJoinDtoVo;
import jakarta.validation.Valid;
@@ -148,6 +148,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
private final AlipayService alipayService;
private final MiniAlipayService miniAlipayService;
private final HardOrderAddressService hardOrderAddressService;
private final HardTakeOutApptService hardTakeOutApptService;
private final RemoteOnlineCanteenSpuService remoteOnlineCanteenSpuService;
private final RemoteMchService remoteMchService;
@@ -165,6 +166,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
private final RemoteShopSkuService remoteShopSkuService;
private final RemoteActCancelService remoteActCancelService;
private final RemoteMallProductService remoteMallProductService;
private final RemoteComActService remoteComActService;
private final HardManagerMapper hardManagerMapper;
@@ -618,7 +620,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
//效验是否有选择必选品
R<OnlineSpuChoiceGroupsVO> choiceGroups = remoteOnlineCanteenSpuService.getChoiceGroups(String.valueOf(parentCar.getMerchantId()));
if (!choiceGroups.isOk()){
if (!choiceGroups.isOk()) {
throw new RuntimeException("未选择必选菜品");
}
@@ -702,6 +704,18 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
addressEntity.setFullAddress(dto.getAddress().getFullAddress());
hardOrderAddressService.save(addressEntity);
}
// 添加预约时间信息
if (ObjectUtil.isNotEmpty(dto.getAppt())) {
HardTakeOutApptEntity apptEntity = new HardTakeOutApptEntity();
apptEntity.setUserId(orderObj.getUserId());
apptEntity.setOrderId(orderObj.getId());
apptEntity.setExpectDeliveryType(dto.getAppt().getExpectDeliveryType());
apptEntity.setExpectDeliveryDate(dto.getAppt().getExpectDeliveryDate());
apptEntity.setExpectDeliveryStart(dto.getAppt().getExpectDeliveryStart());
apptEntity.setExpectDeliveryEnd(dto.getAppt().getExpectDeliveryEnd());
apptEntity.setExpectArriveTime(dto.getAppt().getExpectArriveTime());
hardTakeOutApptService.save(apptEntity);
}
//调用外卖下单
CanteenDeliveryOrderSyncDTO canteenDeliveryOrderSyncDTO = new CanteenDeliveryOrderSyncDTO();
canteenDeliveryOrderSyncDTO.setBuyerUserId(dto.getUserId());
@@ -1411,6 +1425,88 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
return baseMapper.updateById(updateObj) > 0;
}
/**
* 核销二维码
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean handCancelActCode(HandCancelActCodeDto dto) {
// 1. 查看活动是否存在
ActComItemVo detail = remoteComActService.remoteGetComAct(dto.getActItemId(), dto.getUserId()).getData();
if (ObjectUtil.isEmpty(detail)) {
throw new RuntimeException("活动不存在");
}
// 2. 参加活动人员
UserInfo userInfo = userService.getInnerByUserId(detail.getUserId()).getData();
if (ObjectUtil.isEmpty(userInfo)) {
throw new RuntimeException("参加活动用户不存在");
}
SysUser sysUser = userInfo.getSysUser();
// 3. 查询商户
MchManageVo mch = remoteMchService.getById(detail.getMchId()).getData();
if (ObjectUtil.isEmpty(mch)) {
throw new RuntimeException("商户不存在");
}
// 4. 是否已经核销过
String errorMsg = remoteComActService.remoteIsCanCancel(dto.getActItemId(), dto.getUserId()).getData();
if (ObjectUtil.isNotEmpty(errorMsg)) {
throw new RuntimeException(errorMsg);
}
// 5. 钱包(默认饭卡钱包)
WalletManageEntity wallet = remoteWalletService.getWallet(dto.getUserId(), WalletTypeEnum.EAT).getData();
// 6. 创建订单
// 是否需要支付
boolean isPay = true;
// 门槛金额
// 减免金额
// 商品描述
// 优惠金额
int useAmountPrice = 0;
String orderDesc = "浦江活动商品 x *";
// 总金额,额外金额,支付金额
int totalPrice = 0, extraPrice = 0, payPrice = 0;
// 添加硬件订单
HardOrderEntity orderObj = HardOrderEntity.builder()
.androidOrderCode(null)
.userId(sysUser.getUserId())
.userDeptId(sysUser.getDeptId())
.walletId(wallet.getId())
.sysType(HardTypeEnum.NONE.getType())
.hourType("-1")
.parentCarId(null)
// .hardId()
.orderStatus(HardOrderStatusEnum.CREATE.getType())
.merchantId(mch.getId())
.merchantType(mch.getTypes())
.merchantDeptId(mch.getDeptId())
.deptId(mch.getDeptId())
.orderType(HardOrderTypeEnum.RESERVE.getType())
.payType(HardPayTypeEnum.ACT_CANCEL.getType())
.orderSourceTypeId(dto.getActItemId())
.totalPrice(totalPrice)
.extraPrice(extraPrice)
.payPrice(totalPrice + extraPrice)
.isOfflineOrder(YesNoEnum.NO.getCode())
.productDesc(orderDesc)
.build();
baseMapper.insert(orderObj);
// 核销
ActComCancelDto cancelDto = new ActComCancelDto();
cancelDto.setActItemId(dto.getActItemId());
cancelDto.setUserId(dto.getUserId());
cancelDto.setOrderId(orderObj.getId());
cancelDto.setUseAmountPrice(useAmountPrice);
Boolean isCancelSuccess = remoteComActService.remoteDoCancel(cancelDto).getData();
if (ObjectUtil.isEmpty(isCancelSuccess) || !isCancelSuccess) {
throw new RuntimeException("核销失败");
}
// 钱包扣款
getSelf().fastReduceBalance(orderObj);
return true;
}
@Override
// @GlobalTransactional
@Transactional(rollbackFor = Exception.class)
@@ -0,0 +1,15 @@
package com.bsd.pjcloud.hard.service.impl.order;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.hard.api.entity.order.HardTakeOutApptEntity;
import com.bsd.pjcloud.hard.mapper.order.HardTakeOutApptMapper;
import com.bsd.pjcloud.hard.service.HardTakeOutApptService;
import org.springframework.stereotype.Service;
/**
* 外卖送达时间
*/
@Service
public class HardTakeOutApptServiceImpl extends ServiceImpl<HardTakeOutApptMapper, HardTakeOutApptEntity> implements HardTakeOutApptService {
}
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bsd.pjcloud.hard.mapper.order.HardTakeOutApptMapper">
<sql id="selectA">
select a.id,
a.user_id,
a.order_id,
a.expect_delivery_type,
a.expect_delivery_date,
a.expect_delivery_start,
a.expect_delivery_end,
a.expect_arrive_time,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
a.del_flag,
a.tenant_id
</sql>
<sql id="whereA">
a.del_flag = '0'
<if test="dto.userId != null">
and a.user_id = #{dto.userId}
</if>
<if test="dto.orderId != null">
and a.order_id = #{dto.orderId}
</if>
</sql>
</mapper>