feat:创建共富商城预约订单
This commit is contained in:
1 parent
661e24d0cb
commit
cbd6b72f2f
9 files changed
+170
-9
No files matched your search
+1
@@ -19,6 +19,7 @@ public enum HardOrderTypeEnum {
|
||||
STRIDE_DEPT("4", "跨单位"),
|
||||
ZY("5", "正元公务餐"),
|
||||
LB("6", "宁波银行(美好生活)"),
|
||||
FARMER("7", "共富商城(助农)"),
|
||||
;
|
||||
private final String type;
|
||||
private final String description;
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.bsd.pjcloud.hard.api.dto.order.app;
|
||||
|
||||
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 jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class HardAppCreateFarmerOrderDto {
|
||||
|
||||
@NotNull(message = "购物车id不能为空")
|
||||
private Long carParentId;
|
||||
|
||||
@NotNull(message = "钱包类型不能为空")
|
||||
private WalletTypeEnum walletType;
|
||||
|
||||
@NotNull(message = "自提点id不能为空")
|
||||
private Long pickUpId;
|
||||
|
||||
private HardOrderTypeEnum orderType;
|
||||
|
||||
private HardPayTypeEnum payType;
|
||||
|
||||
private HardTypeEnum hardType;
|
||||
|
||||
private Long userId;
|
||||
|
||||
}
|
||||
+3
-4
@@ -35,16 +35,15 @@ public class HardApptController {
|
||||
|
||||
private final HardApptService hardApptService;
|
||||
|
||||
|
||||
/* ************************************* start app start ************************************* */
|
||||
|
||||
@Operation(summary = "app预约时间列表", description = "app预约时间列表")
|
||||
@GetMapping("/app/list")
|
||||
public R<List<HardApptEntity>> appList() {
|
||||
List<HardApptEntity> list = hardApptService.list(new LambdaQueryWrapper<HardApptEntity>()
|
||||
.eq(HardApptEntity::getStatus, YesNoEnum.YES.getCode())
|
||||
.orderByDesc(HardApptEntity::getSort)
|
||||
);
|
||||
.eq(HardApptEntity::getStatus, YesNoEnum.YES.getCode())
|
||||
.orderByDesc(HardApptEntity::getSort)
|
||||
);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
|
||||
+14
@@ -32,6 +32,7 @@ import com.bsd.pjcloud.hard.api.dto.hard.HardOfflinePayDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderPreferencesDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.act.HardCreateActOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateFarmerOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardOrderVo;
|
||||
@@ -188,6 +189,19 @@ public class HardOrderController {
|
||||
return R.ok(hardwareOrderService.appCreateSupermarketReserveOrder(dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "创建共富商城预约订单", description = "app创建线上超市预定订单")
|
||||
@PostMapping("/app/create-farmer-order")
|
||||
@Idempotent(expireTime = 3, key = "'/app/hard-order/app/create-farmer-order' + #body.getCarParentId() ", info = "正在创建订单中,请勿重复操作")
|
||||
public R<Long> appCreateFarmerReserveOrder(@RequestBody HardAppCreateFarmerOrderDto body) {
|
||||
PjcloudUser user = SecurityUtils.getUser();
|
||||
body.setWalletType(WalletTypeEnum.EAT);
|
||||
body.setHardType(HardTypeEnum.SUPERMARKET);
|
||||
body.setUserId(user.getId());
|
||||
body.setOrderType(HardOrderTypeEnum.FARMER);
|
||||
body.setPayType(HardPayTypeEnum.WALLET_DEFAULT);
|
||||
return R.ok(hardwareOrderService.appCreateFarmerReserveOrder(body));
|
||||
}
|
||||
|
||||
@Operation(summary = "app创建订单扫一扫", description = "app创建订单扫一扫")
|
||||
@PostMapping("/app/create-order-scan-qrcode")
|
||||
@Idempotent(expireTime = 5, info = "正在创建订单中,请勿重复操作")
|
||||
|
||||
+6
@@ -15,6 +15,7 @@ import com.bsd.pjcloud.hard.api.dto.hard.HardDoneHardQrCodeScanOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardCreateCarDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.act.HardCreateActOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateFarmerOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardCarEntity;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
|
||||
@@ -66,6 +67,11 @@ public interface HardOrderService extends IService<HardOrderEntity> {
|
||||
*/
|
||||
Long appCreateSupermarketReserveOrder(HardAppCreateOrderDto dto);
|
||||
|
||||
/**
|
||||
* 创建共富商城预约订单
|
||||
*/
|
||||
Long appCreateFarmerReserveOrder(HardAppCreateFarmerOrderDto dto);
|
||||
|
||||
/**
|
||||
* 创建app订单
|
||||
*/
|
||||
|
||||
+74
@@ -44,6 +44,7 @@ import com.bsd.pjcloud.hard.api.dto.hard.HardCreateOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardCreateCarDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.act.HardCreateActOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateFarmerOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.spu.DeductionSpuStockDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.wechat.WechantReverseDto;
|
||||
@@ -89,6 +90,7 @@ import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
|
||||
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.mch.MchPickUpVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.mch.MchRuleJoinDtoVo;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.Locked;
|
||||
@@ -135,6 +137,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
private final AlipayService alipayService;
|
||||
|
||||
private final RemoteMchService remoteMchService;
|
||||
private final RemoteMchPickUpService remoteMchPickUpService;
|
||||
private final RemoteCodeUseService remoteCodeUseService;
|
||||
private final RemoteWalletService remoteWalletService;
|
||||
private final RemoteWalletTransactionService walletTransactionService;
|
||||
@@ -630,6 +633,77 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
return orderObj.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建共富商城预约订单
|
||||
*/
|
||||
@Override
|
||||
public Long appCreateFarmerReserveOrder(HardAppCreateFarmerOrderDto dto) {
|
||||
// 查询用户
|
||||
UserInfo userDetail = userService.getInnerByUserId(dto.getUserId()).getData();
|
||||
if (ObjectUtil.isEmpty(userDetail)) throw new RuntimeException("用户不存在不存在");
|
||||
// 钱包
|
||||
WalletManageEntity wallet = remoteWalletService.getWallet(dto.getUserId(), dto.getWalletType()).getData();
|
||||
if (ObjectUtil.isEmpty(wallet)) throw new RuntimeException("用户钱包不存在");
|
||||
// 查询父订单
|
||||
HardParentCarEntity parentCar = hardCarService.getParentCarById(dto.getCarParentId());
|
||||
if (ObjectUtil.isEmpty(parentCar)) throw new RuntimeException("购物车不存在");
|
||||
// 查询商户
|
||||
MchManageVo hardManager = remoteMchService.getById(parentCar.getMerchantId()).getData();
|
||||
if (ObjectUtil.isEmpty(hardManager)) throw new RuntimeException("商户不存在");
|
||||
// 查询自提点
|
||||
MchPickUpVo mchPickUp = remoteMchPickUpService.remoteDetail(dto.getPickUpId()).getData();
|
||||
if (ObjectUtil.isEmpty(mchPickUp)) throw new RuntimeException("查询自提点不存在");
|
||||
// 查询父购物车
|
||||
List<HardCarEntity> carList = hardCarService.getByParentCarId(dto.getCarParentId());
|
||||
if (ObjectUtil.isEmpty(carList)) throw new RuntimeException("购物车不存在");
|
||||
Integer balance = wallet.getBalance();
|
||||
int totalPrice = (int) carList.stream().mapToLong(HardCarEntity::getTotalPrice).sum();
|
||||
if (balance < totalPrice) {
|
||||
throw new RuntimeException("钱包余额不足");
|
||||
}
|
||||
// 获取商品描述
|
||||
List<HardCreateCarDto> carListDto = carList.stream().map(v -> {
|
||||
HardCreateCarDto entity = new HardCreateCarDto();
|
||||
entity.setParentCarId(dto.getCarParentId());
|
||||
entity.setProductId(v.getProductId());
|
||||
entity.setProductWeight(v.getProductWeight());
|
||||
entity.setProductCount(v.getProductCount());
|
||||
return entity;
|
||||
}).toList();
|
||||
HardTypeEnum hardType = ObjectUtil.equals(dto.getWalletType(), WalletTypeEnum.EAT) ? HardTypeEnum.CANTEEN : HardTypeEnum.SUPERMARKET;
|
||||
String subject = hardCarService.computerCarSubject(hardType, dto.getOrderType(), carListDto);
|
||||
// 添加硬件订单
|
||||
HardOrderEntity orderObj = HardOrderEntity.builder()
|
||||
.userId(dto.getUserId())
|
||||
.userDeptId(userDetail.getSysUser().getDeptId())
|
||||
.parentCarId(dto.getCarParentId())
|
||||
.sysType(dto.getHardType().getType())
|
||||
.orderStatus(HardOrderStatusEnum.CREATE.getType())
|
||||
.merchantId(parentCar.getMerchantId())
|
||||
.merchantType(hardManager.getTypes())
|
||||
.merchantDeptId(hardManager.getDeptId())
|
||||
.orderType(dto.getOrderType().getType())
|
||||
.payType(dto.getPayType().getType())
|
||||
.orderSourceTypeId(mchPickUp.getId())
|
||||
.totalPrice(totalPrice)
|
||||
.extraPrice(0)
|
||||
.payPrice(totalPrice)
|
||||
.isOfflineOrder(YesNoEnum.NO.getCode())
|
||||
.productDesc(subject)
|
||||
.walletId(wallet.getId())
|
||||
.build();
|
||||
baseMapper.insert(orderObj);
|
||||
// 钱包扣款
|
||||
getSelf().fastReduceBalance(orderObj);
|
||||
// 创建二维码
|
||||
getSelf().generateCode(orderObj);
|
||||
// 发送mq消息
|
||||
getSelf().createOrderAfterSendMqMsg(orderObj.getId(), userDetail);
|
||||
// 扣减库存
|
||||
getSelf().fastenerInventory(orderObj, YesNoEnum.YES);
|
||||
return orderObj.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
// @GlobalTransactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.bsd.pjcloud.wallet.api.feign;
|
||||
|
||||
import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.feign.annotation.NoToken;
|
||||
import com.bsd.pjcloud.wallet.api.vo.mch.MchPickUpVo;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
|
||||
@FeignClient(contextId = "remoteMchPickUpService", value = ServiceNameConstants.WALLET_SERVICE)
|
||||
public interface RemoteMchPickUpService {
|
||||
|
||||
@NoToken
|
||||
@GetMapping("/mch-pick-up/remotedetail")
|
||||
R<MchPickUpVo> remoteDetail(@RequestParam("id") Long id);
|
||||
|
||||
}
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
com.bsd.pjcloud.wallet.api.feign.RemoteActCancelService
|
||||
com.bsd.pjcloud.wallet.api.feign.RemoteWalletService
|
||||
com.bsd.pjcloud.wallet.api.feign.RemoteMchPickUpService
|
||||
com.bsd.pjcloud.wallet.api.feign.RemoteMchRuleJoinService
|
||||
com.bsd.pjcloud.wallet.api.feign.RemoteCodeUseService
|
||||
com.bsd.pjcloud.wallet.api.feign.RemoteWalletRechargeService
|
||||
|
||||
+16
-5
@@ -2,15 +2,16 @@ package com.bsd.pjcloud.wallet.controller.mch;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.common.security.annotation.Inner;
|
||||
import com.bsd.pjcloud.wallet.api.constant.mch.WalletMchPickUpStatusEnum;
|
||||
import com.bsd.pjcloud.wallet.api.dto.mch.MchPickUpDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.mch.MchPickUpEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.mch.MchPickUpVo;
|
||||
import com.bsd.pjcloud.wallet.service.MchPickUpService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
@@ -36,18 +37,28 @@ public class MchPickUpController {
|
||||
|
||||
private final MchPickUpService mchPickUpService;
|
||||
|
||||
/* ************************************* start 远程调用 start ************************************* */
|
||||
|
||||
@Inner
|
||||
@GetMapping("/remotedetail")
|
||||
public R<MchPickUpVo> remoteDetail(@RequestParam("id") Long id) {
|
||||
return R.ok(mchPickUpService.join(id));
|
||||
}
|
||||
|
||||
/* ************************************* end 远程调用 end ************************************* */
|
||||
|
||||
/* ************************************* start app start ************************************* */
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("app/page")
|
||||
public R appPage(@ParameterObject Page page, @ParameterObject MchPickUpDto dto) {
|
||||
@GetMapping("/app/page")
|
||||
public R<Page<MchPickUpVo>> appPage(@ParameterObject Page page, @ParameterObject MchPickUpDto dto) {
|
||||
dto.setStatus(WalletMchPickUpStatusEnum.COOPERATION_SUCCESS.getCode());
|
||||
return R.ok(mchPickUpService.scopPageJoin(page, dto, null));
|
||||
}
|
||||
|
||||
@Operation(summary = "查询详情", description = "查询详情")
|
||||
@GetMapping("app/detail")
|
||||
public R appDetail(@RequestParam("id") Long id) {
|
||||
@GetMapping("/app/detail")
|
||||
public R<MchPickUpVo> appDetail(@RequestParam("id") Long id) {
|
||||
return R.ok(mchPickUpService.join(id));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user