下单获取用户收获地址
This commit is contained in:
parent
bd12554d42
commit
a110127415
@ -1,5 +1,7 @@
|
|||||||
package net.jieyuu.utils;
|
package net.jieyuu.utils;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.TypeReference;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
@ -26,8 +28,18 @@ public class JsonData {
|
|||||||
private String msg;
|
private String msg;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取远程调用数据对象
|
||||||
|
* 注意 支持多单词下划线转驼峰(序列化和反序列化)
|
||||||
|
* 空对象不序列化
|
||||||
|
*/
|
||||||
|
public <T> T getData(TypeReference<T> typeReference) {
|
||||||
|
return JSON.parseObject(JSON.toJSONString(data), typeReference);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 成功,传入数据
|
* 成功,传入数据
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static JsonData buildSuccess() {
|
public static JsonData buildSuccess() {
|
||||||
@ -35,7 +47,8 @@ public class JsonData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 成功,传入数据
|
* 成功,传入数据
|
||||||
|
*
|
||||||
* @param data
|
* @param data
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -45,6 +58,7 @@ public class JsonData {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 失败,传入描述信息
|
* 失败,传入描述信息
|
||||||
|
*
|
||||||
* @param msg
|
* @param msg
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -55,6 +69,7 @@ public class JsonData {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义状态码和错误信息
|
* 自定义状态码和错误信息
|
||||||
|
*
|
||||||
* @param code
|
* @param code
|
||||||
* @param msg
|
* @param msg
|
||||||
* @return
|
* @return
|
||||||
@ -65,10 +80,11 @@ public class JsonData {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 传入枚举,返回信息
|
* 传入枚举,返回信息
|
||||||
|
*
|
||||||
* @param codeEnum
|
* @param codeEnum
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static JsonData buildResult(BizCodeEnum codeEnum){
|
public static JsonData buildResult(BizCodeEnum codeEnum) {
|
||||||
return JsonData.buildCodeAndMsg(codeEnum.getCode(),codeEnum.getMessage());
|
return JsonData.buildCodeAndMsg(codeEnum.getCode(), codeEnum.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -26,7 +26,7 @@ import java.io.IOException;
|
|||||||
* @author jieyuu
|
* @author jieyuu
|
||||||
* @since 2024-08-17
|
* @since 2024-08-17
|
||||||
*/
|
*/
|
||||||
@Api("订单模块")
|
@Api(tags = "订单模块")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/order/v1")
|
@RequestMapping("/api/order/v1")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -39,7 +39,7 @@ public class ProductOrderController {
|
|||||||
@PostMapping("confirm")
|
@PostMapping("confirm")
|
||||||
public void confirmOrder(@ApiParam("订单对象") @RequestBody ConfirmOrderRequest confirmOrderRequest, HttpServletResponse response) {
|
public void confirmOrder(@ApiParam("订单对象") @RequestBody ConfirmOrderRequest confirmOrderRequest, HttpServletResponse response) {
|
||||||
|
|
||||||
JsonData jsonData = orderService.confirmOrder(orderService);
|
JsonData jsonData = orderService.confirmOrder(confirmOrderRequest);
|
||||||
if (jsonData.getCode() == 0) {
|
if (jsonData.getCode() == 0) {
|
||||||
//根据端类型选择返回类型
|
//根据端类型选择返回类型
|
||||||
String client = confirmOrderRequest.getClientType();
|
String client = confirmOrderRequest.getClientType();
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package net.jieyuu.feign;
|
||||||
|
|
||||||
|
|
||||||
|
import net.jieyuu.utils.JsonData;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
|
||||||
|
|
||||||
|
@FeignClient(name = "xdclass-user-service")
|
||||||
|
public interface UserFeignService {
|
||||||
|
/**
|
||||||
|
* 查看地址详情,接口本身已经防止了水平越权
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/api/address/v1/find/{address_id}")
|
||||||
|
public JsonData detail(@PathVariable("address_id") long id);
|
||||||
|
|
||||||
|
}
|
@ -2,6 +2,7 @@ package net.jieyuu.service;
|
|||||||
|
|
||||||
import net.jieyuu.model.ProductOrderDO;
|
import net.jieyuu.model.ProductOrderDO;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import net.jieyuu.request.ConfirmOrderRequest;
|
||||||
import net.jieyuu.utils.JsonData;
|
import net.jieyuu.utils.JsonData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,10 +18,10 @@ public interface ProductOrderService extends IService<ProductOrderDO> {
|
|||||||
/**
|
/**
|
||||||
* 创建订单
|
* 创建订单
|
||||||
*
|
*
|
||||||
* @param orderService
|
* @param orderRequest
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
JsonData confirmOrder(ProductOrderService orderService);
|
JsonData confirmOrder(ConfirmOrderRequest orderRequest);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,11 +1,21 @@
|
|||||||
package net.jieyuu.service.impl;
|
package net.jieyuu.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.TypeReference;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.jieyuu.enums.BizCodeEnum;
|
||||||
|
import net.jieyuu.exception.BizException;
|
||||||
|
import net.jieyuu.feign.UserFeignService;
|
||||||
|
import net.jieyuu.interceptor.LoginInterceptor;
|
||||||
|
import net.jieyuu.model.LoginUser;
|
||||||
import net.jieyuu.model.ProductOrderDO;
|
import net.jieyuu.model.ProductOrderDO;
|
||||||
import net.jieyuu.mapper.ProductOrderMapper;
|
import net.jieyuu.mapper.ProductOrderMapper;
|
||||||
|
import net.jieyuu.request.ConfirmOrderRequest;
|
||||||
import net.jieyuu.service.ProductOrderService;
|
import net.jieyuu.service.ProductOrderService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import net.jieyuu.utils.CommonUtil;
|
||||||
import net.jieyuu.utils.JsonData;
|
import net.jieyuu.utils.JsonData;
|
||||||
|
import net.jieyuu.vo.ProductOrderAddressVO;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -18,11 +28,15 @@ import org.springframework.stereotype.Service;
|
|||||||
* @since 2024-08-17
|
* @since 2024-08-17
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Slf4j
|
||||||
public class ProductOrderServiceImpl extends ServiceImpl<ProductOrderMapper, ProductOrderDO> implements ProductOrderService {
|
public class ProductOrderServiceImpl extends ServiceImpl<ProductOrderMapper, ProductOrderDO> implements ProductOrderService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProductOrderMapper productOrderMapper;
|
private ProductOrderMapper productOrderMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserFeignService userFeignService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 防重提交
|
* * 防重提交
|
||||||
* * 用户微服务-确认收货地址
|
* * 用户微服务-确认收货地址
|
||||||
@ -37,15 +51,43 @@ public class ProductOrderServiceImpl extends ServiceImpl<ProductOrderMapper, Pro
|
|||||||
* * 发送延迟消息-用于自动关单
|
* * 发送延迟消息-用于自动关单
|
||||||
* * 创建支付信息-对接三方支付
|
* * 创建支付信息-对接三方支付
|
||||||
*
|
*
|
||||||
* @param orderService
|
* @param orderRequest
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public JsonData confirmOrder(ProductOrderService orderService) {
|
public JsonData confirmOrder(ConfirmOrderRequest orderRequest) {
|
||||||
|
LoginUser loginUser = LoginInterceptor.threadLocal.get();
|
||||||
|
// 32位uuid订单号
|
||||||
|
String orderOutTradeNo = CommonUtil.getStringNumRandom(32);
|
||||||
|
// 获取收货地址
|
||||||
|
ProductOrderAddressVO addressVO = this.getUserAddress(orderRequest.getAddressId());
|
||||||
|
log.info("收货地址信息:{}", addressVO);
|
||||||
|
// 获取商品最新信息
|
||||||
|
// JsonData productJsonData = productFeignService.getProductList(orderRequest.getProductList());
|
||||||
|
//
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取收货地址详情
|
||||||
|
*
|
||||||
|
* @param addressId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private ProductOrderAddressVO getUserAddress(Long addressId) {
|
||||||
|
JsonData jsonData = userFeignService.detail(addressId);
|
||||||
|
|
||||||
|
if (jsonData.getCode() != 0) {
|
||||||
|
log.error("获取地址详情失败,msg:{}", jsonData);
|
||||||
|
throw new BizException(BizCodeEnum.ADDRESS_NO_EXITS);
|
||||||
|
}
|
||||||
|
ProductOrderAddressVO productOrderAddressVO = jsonData.getData(new TypeReference<ProductOrderAddressVO>() {
|
||||||
|
});
|
||||||
|
|
||||||
|
return productOrderAddressVO;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询订单状态
|
* 查询订单状态
|
||||||
*
|
*
|
||||||
|
@ -0,0 +1,68 @@
|
|||||||
|
package net.jieyuu.vo;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 电商-公司收发货地址表
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author jieyuu
|
||||||
|
* @since 2024-02-12
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("address")
|
||||||
|
public class ProductOrderAddressVO implements Serializable {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否默认收货地址:0->否;1->是
|
||||||
|
*/
|
||||||
|
private Integer defaultStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收发货人姓名
|
||||||
|
*/
|
||||||
|
private String receiveName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收货人电话
|
||||||
|
*/
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 省/直辖市
|
||||||
|
*/
|
||||||
|
private String province;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 市
|
||||||
|
*/
|
||||||
|
private String city;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 区
|
||||||
|
*/
|
||||||
|
private String region;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 详细地址
|
||||||
|
*/
|
||||||
|
private String detailAddress;
|
||||||
|
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -20,7 +20,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
* @since 2024-08-07
|
* @since 2024-08-07
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Api("轮播图模块")
|
@Api(tags = "轮播图模块")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/banner/v1")
|
@RequestMapping("/api/banner/v1")
|
||||||
public class BannerController {
|
public class BannerController {
|
||||||
|
@ -25,7 +25,7 @@ import java.util.Map;
|
|||||||
* @since 2024-08-07
|
* @since 2024-08-07
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Api("购物车")
|
@Api(tags = "购物车")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/cart/v1/")
|
@RequestMapping("/api/cart/v1/")
|
||||||
public class CartController {
|
public class CartController {
|
||||||
|
@ -21,7 +21,7 @@ import java.util.Map;
|
|||||||
* @author jieyuu
|
* @author jieyuu
|
||||||
* @since 2024-08-07
|
* @since 2024-08-07
|
||||||
*/
|
*/
|
||||||
@Api("商品模块")
|
@Api(tags = "商品模块")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/product/v1")
|
@RequestMapping("/api/product/v1")
|
||||||
public class ProductController {
|
public class ProductController {
|
||||||
|
Loading…
Reference in New Issue
Block a user