This commit is contained in:
Cauchy
2023-10-25 09:03:11 +08:00
parent 36374dd454
commit 719711c614
9 changed files with 126 additions and 49 deletions

View File

@@ -179,7 +179,7 @@ public class BuyOrderController {
buyOrderService.save(buyOrder);
for (BuyOrderDetail buyOrderDetail : buyOrderDetails) {
buyOrderDetail.setOrderId(buyOrder.getId());
buyOrderDetail.setOrderId(buyOrder.getOrderId());
buyOrderDetail.setUserId(buyOrder.getUserId());
if (Constants.BUY_TYPE_CART.equals(buyOrder.getBuyType())) {
handleBuyCart(buyOrder, buyOrderDetail);
@@ -204,12 +204,12 @@ public class BuyOrderController {
rabbitTemplate.convertAndSend(
DelayQueueConfig.ORDER_TO_BE_PAY_EXCHANGE,
DelayQueueConfig.ORDER_TO_BE_PAY_ROUTING_KEY,
buyOrder.getId(),
buyOrder.getOrderId(),
messagePostProcessor()
);
WechatPaymentInfo paymentInfo = new WechatPaymentInfo();
paymentInfo.setOrderSn(orderSn);
paymentInfo.setBuyOrderId(buyOrder.getId());
paymentInfo.setBuyOrderId(buyOrder.getOrderId());
paymentInfo.setTotalAmount(totalPrice);
wxpayService.prepay(paymentInfo);
}
@@ -261,7 +261,7 @@ public class BuyOrderController {
buyOrderService.save(buyOrder);
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
buyOrderProduct.setOrderId(buyOrder.getId());
buyOrderProduct.setOrderId(buyOrder.getOrderId());
if (Constants.BUY_TYPE_CART.equals(buyOrder.getBuyType())) {
handleBuyCart(buyOrder, buyOrderProduct);
}
@@ -285,12 +285,12 @@ public class BuyOrderController {
rabbitTemplate.convertAndSend(
DelayQueueConfig.ORDER_TO_BE_PAY_EXCHANGE,
DelayQueueConfig.ORDER_TO_BE_PAY_ROUTING_KEY,
buyOrder.getId(),
buyOrder.getOrderId(),
messagePostProcessor()
);
WechatPaymentInfo paymentInfo = new WechatPaymentInfo();
paymentInfo.setOrderSn(orderSn);
paymentInfo.setBuyOrderId(buyOrder.getId());
paymentInfo.setBuyOrderId(buyOrder.getOrderId());
paymentInfo.setTotalAmount(totalPrice);
wxpayService.prepay(paymentInfo);
}
@@ -356,7 +356,7 @@ public class BuyOrderController {
}
// 库存回滚
QueryWrapper<BuyOrderProduct> buyOrderProductQueryWrapper = new QueryWrapper<>();
buyOrderProductQueryWrapper.eq("order_id", buyOrder.getId());
buyOrderProductQueryWrapper.eq("order_id", buyOrder.getOrderId());
List<BuyOrderProduct> buyOrderProductList = buyOrderProductService.list(buyOrderProductQueryWrapper);
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
Integer productId = buyOrderProduct.getProductId();
@@ -364,7 +364,7 @@ public class BuyOrderController {
product.setProductStock(product.getProductStock() + buyOrderProduct.getQuantity());
shopProductService.updateById(product);
}
buyOrderService.removeById(buyOrder.getId());
buyOrderService.removeById(buyOrder.getOrderId());
return R.ok();
}
@@ -410,7 +410,7 @@ public class BuyOrderController {
}
// 库存回滚
List<BuyOrderDetail> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetail>()
.eq("order_id", byId.getId()));
.eq("order_id", byId.getOrderId()));
for (BuyOrderDetail buyOrderDetailEntity : buyOrderDetailEntities) {
Integer productId = buyOrderDetailEntity.getProductId();
ShopProduct product = shopProductService.getById(productId);
@@ -452,7 +452,7 @@ public class BuyOrderController {
@RequestMapping("/getOrderDetail")
public R getOrderDetail(@RequestParam Integer orderId) {
LambdaQueryWrapper<BuyOrder> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(BuyOrder::getId, orderId);
wrapper.eq(BuyOrder::getOrderId, orderId);
BuyOrder one = buyOrderService.getOne(wrapper);
if (one.equals(null)) {
return R.error("order error:order is null");
@@ -565,30 +565,19 @@ public class BuyOrderController {
/**
* 查询订单快递
*
* @param orderSn 单号
* @param expressOrderSn 单号
* @return R
*/
@RequestMapping(value = "/queryExpress", method = RequestMethod.GET)
public R queryExpress(@RequestParam("orderSn") Integer orderSn) {
QueryWrapper<BuyOrder> buyOrderQueryWrapper = new QueryWrapper<>();
buyOrderQueryWrapper.eq("order_sn", orderSn);
BuyOrder buyOrder = buyOrderService.getOne(buyOrderQueryWrapper);
Integer orderId = buyOrder.getId();
public R queryExpress(@RequestParam("expressOrderSn") String expressOrderSn,
@RequestParam("expressCompanyCode") String expressCompanyCode,
@RequestParam("customerName") String customerName) {
QueryWrapper<BuyOrderProduct> buyOrderProductQueryWrapper = new QueryWrapper<>();
buyOrderProductQueryWrapper.eq("order_id", orderId);
List<BuyOrderProduct> buyOrderProductList = buyOrderProductService.list(buyOrderProductQueryWrapper);
List<ExpressQueryResponseVo> result = new ArrayList<>();
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
int expressOrderId = buyOrderProduct.getExpressOrderId();
ExpressOrder expressOrder = expressOrderService.getById(expressOrderId);
ExpressQueryResponseVo vo = new ExpressQueryResponseVo();
ExpressQueryResponse expressQueryResponse = expressOrderService.queryExpressOrder(expressOrder.getExpressCompanyCode(), expressOrder.getExpressOrderSn());
ExpressQueryResponse expressQueryResponse = expressOrderService.queryExpressOrder(expressCompanyCode, expressOrderSn, customerName);
vo.setLogisticCode(expressQueryResponse.getLogisticCode());
vo.setTraces(expressQueryResponse.getTraces());
result.add(vo);
}
return R.ok().put("result", result);
return R.ok().put("result", vo);
}
/**
@@ -689,7 +678,7 @@ public class BuyOrderController {
CouponHistoryEntity couponHistory = couponHistoryService.getById(couponId);
couponHistory.setUseStatus(1);
couponHistory.setUseTime(new Date());
couponHistory.setOrderId(Long.valueOf(buyOrder.getId()));
couponHistory.setOrderId(Long.valueOf(buyOrder.getOrderId()));
couponHistory.setOrderSn(buyOrder.getOrderSn());
CouponEntity coupon = couponService.getById(couponHistory.getCouponId());

View File

@@ -39,6 +39,8 @@ public class ShopProductController {
private ShopProductBookService shopProductBookService;
@Autowired
private ShopProductToLabelService shopProductToLabelService;
@Autowired
private BuyOrderDetailService buyOrderDetailService;
/**
* 精选商品 列表
@@ -87,6 +89,48 @@ public class ShopProductController {
return R.ok().put("page", page);
}
/**
* 未购买书列表
*
* @param userId 用户id
* @return
*/
@RequestMapping("/booklist")
public R booklist(@RequestParam("userId") Integer userId
) {
//查询已购买的书籍
List<BuyOrderDetail> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetail>()
.eq("user_id", userId));
//hashset不重复 且无序
Set<String> purchasedProductIds = new HashSet<>();
ArrayList<Object> list = new ArrayList<>();
Map<String, Object> map = new HashMap<>();
for (BuyOrderDetail buyOrderDetail : buyOrderDetailEntities) {
map.put("ProductId", String.valueOf(buyOrderDetail.getProductId()));
list.add(map);
//去重取出以后买书籍的id
purchasedProductIds.add(String.valueOf(buyOrderDetail.getProductId()));
}
//查询商品表并过滤已购买商品id,根据时间倒叙展示
List<ShopProduct> allProductEntities = shopProductService.getBaseMapper().selectList(new QueryWrapper<ShopProduct>()
.notIn("product_id", purchasedProductIds)
.orderByDesc("create_time")
// .notLike("book_ids",",")
.isNotNull("book_ids")
);
List lists = new ArrayList<>();
for (ShopProduct product : allProductEntities) {
Map<String, Object> productMap = new HashMap<>();
productMap.put("product", product);
lists.add(productMap);
}
return R.ok().put("pages", lists); // 返回未购买的书籍分页
}
/**
* 未购买书列表
@@ -125,8 +169,6 @@ public class ShopProductController {
productMap.put("product", product);
lists.add(productMap);
}
return R.ok().put("pages", lists); // 返回未购买的书籍分页
}

View File

@@ -115,7 +115,7 @@ public class UserFollowUpController {
.eq("order_sn", orderSn).last("LIMIT 1")
);
Integer orderId = buyOrder.getId();
Integer orderId = buyOrder.getOrderId();
Integer bookid = userRecord.getBookid();
Integer userid = userRecord.getUserid();
Integer id1 = userRecord.getId();

View File

@@ -26,6 +26,8 @@ public class UserRecordController {
private BuyOrderProductService buyOrderProductService;
@Autowired
private UserFollowUpService userFollowUpService;
@Autowired
private BuyOrderDetailService buyOrderDetailService;
/**
@@ -176,7 +178,7 @@ public class UserRecordController {
return error("您已评价过了,请勿重复评论");
//
} else {
userRecord.setId(buyOrder.getId());
userRecord.setId(buyOrder.getOrderId());
userRecord.setContent(comment);
//商品评价
userRecord.setBookid(bookid);
@@ -197,11 +199,11 @@ public class UserRecordController {
* @return 生成评论(上传图片,星级评价
*/
@RequestMapping("/UserRecordComment")
public R commodity(@RequestBody UserRecord recordEntity) {
public R comment(@RequestBody UserRecord recordEntity) {
QueryWrapper<BuyOrder> buyOrderQueryWrapper = new QueryWrapper<>();
buyOrderQueryWrapper.eq("order_sn", recordEntity.getOrderSn());
BuyOrder buyOrder = buyOrderService.getOne(buyOrderQueryWrapper);
Integer orderId = buyOrder.getId();
Integer orderId = buyOrder.getOrderId();
QueryWrapper<BuyOrderProduct> buyOrderProductQueryWrapper = new QueryWrapper<>();
buyOrderProductQueryWrapper.eq("order_id", orderId);
buyOrderProductQueryWrapper.eq("product_id", recordEntity.getProductId());
@@ -228,4 +230,45 @@ public class UserRecordController {
buyOrderProductService.saveOrUpdate(buyOrderProduct);
return R.ok("成功").put("userRecordEntity", recordEntity);
}
/*
TODO 老版本接口,新版本上线后要删除
*/
@RequestMapping("/UserRecordcomment")
public R commodity(@RequestBody UserRecord recordEntity) {
//todo 已收货限制字段,只可评价一次
BuyOrder buyOrder = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>()
.eq("order_sn", recordEntity.getOrderSn())
);
Integer orderId = buyOrder.getOrderId();
BuyOrderDetail detailEntity = buyOrderDetailService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderDetail>().eq("Order_id", orderId).eq("product_id", recordEntity.getBookid()));
Integer orderId1 = detailEntity.getOrderId();
UserRecord userRecordEntity = userRecordService.getBaseMapper().selectOne(new QueryWrapper<UserRecord>().eq("orderSn", recordEntity.getOrderSn()).eq("userid", recordEntity.getUserid()).eq("orderdid", orderId1).last("LIMIT 1"));
if (userRecordEntity != null) {
return R.error("您已评价过");
}
if (recordEntity.getImages() != null) {
List<Map<String, String>> imageList = (ArrayList<Map<String, String>>) recordEntity.getImages();
String imageStr = "";
for (Map m : imageList) {
imageStr += m.get("url") + ",";
}
recordEntity.setImages(imageStr);
}
recordEntity.setDelflag(0);
recordEntity.setOrderdId(orderId1);
userRecordService.saveOrUpdate(recordEntity);
detailEntity.setRecordId(1);
buyOrderDetailService.saveOrUpdate(detailEntity);
return R.ok("成功").put("userRecordEntity", recordEntity);
}
}

View File

@@ -22,7 +22,7 @@ public class BuyOrder implements Serializable {
private static final long serialVersionUID = 1L;
@TableId
private Integer id;
private Integer orderId;
/**
* 订单编号
*/

View File

@@ -16,5 +16,5 @@ public interface ExpressOrderService extends IService<ExpressOrder> {
*/
ExpressOrderResponseVo placeExpressOrder(ExpressOrder expressOrder);
ExpressQueryResponse queryExpressOrder(String ShipperCode, String LogisticCode);
ExpressQueryResponse queryExpressOrder(String ShipperCode, String LogisticCode, String customerName);
}

View File

@@ -30,8 +30,6 @@ import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import static org.apache.poi.hemf.hemfplus.record.HemfPlusRecordType.save;
@Service("buyOrderService")
public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> implements BuyOrderService {
@@ -105,7 +103,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
if (!ObjectUtils.isEmpty(myUserEntity)) {
record.setUserName(myUserEntity.getName());
record.setProducts(buyOrderDetailService.list(new QueryWrapper<BuyOrderDetail>()
.eq("order_id", record.getId())));
.eq("order_id", record.getOrderId())));
}
}
@@ -129,7 +127,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
page = this.page(page, queryWrapper);
List<BuyOrder> records = page.getRecords();
for (BuyOrder buyOrder : records) {
Integer orderId = buyOrder.getId();
Integer orderId = buyOrder.getOrderId();
QueryWrapper<BuyOrderDetail> buyOrderDetailQueryWrapper = new QueryWrapper<>();
buyOrderDetailQueryWrapper.eq("order_id", orderId);
List<BuyOrderDetail> buyOrderDetailList = buyOrderDetailService.list(buyOrderDetailQueryWrapper);
@@ -187,14 +185,14 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
);
for (BuyOrder order : buyOrderList) {
order.setProducts(buyOrderDetailService.list(new QueryWrapper<BuyOrderDetail>()
.eq("order_id", order.getId())));
.eq("order_id", order.getOrderId())));
orderList.add(order);
}
// 清洗数据 (与前端传来的id对比后)
List<BuyOrder> washOrderList = new ArrayList<>();
for (BuyOrder order : orderList) {
for (int o : orderIds) {
if (o == order.getId()) {
if (o == order.getOrderId()) {
washOrderList.add(order);
}
}
@@ -276,7 +274,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
);
for (BuyOrder order : buyOrderList.getRecords()) {
order.setProducts(buyOrderDetailService.list(new QueryWrapper<BuyOrderDetail>()
.eq("order_id", order.getId())));
.eq("order_id", order.getOrderId())));
orderList.add(order);
}
// 获取有订单的所有用户
@@ -414,7 +412,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
*/
private BuyOrderResponseVo setBuyOrderInfo(BuyOrder buyOrder) {
BuyOrderResponseVo responseVo = new BuyOrderResponseVo();
responseVo.setOrderId(buyOrder.getId());
responseVo.setOrderId(buyOrder.getOrderId());
Integer userId = buyOrder.getUserId();
QueryWrapper<MyUserEntity> userEntityQueryWrapper = new QueryWrapper<>();
userEntityQueryWrapper.eq("id", userId);
@@ -463,7 +461,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
}
responseVo.setConsignee(consigneeVo);
QueryWrapper<BuyOrderProduct> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("order_id", buyOrder.getId());
queryWrapper.eq("order_id", buyOrder.getOrderId());
List<BuyOrderProduct> buyOrderProductList = buyOrderProductService.list(queryWrapper);
List<GoodsResponseVo> goodsResponseVoList = new ArrayList<>();
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {

View File

@@ -98,9 +98,10 @@ public class ExpressOrderServiceImpl extends ServiceImpl<ExpressOrderDao, Expres
}
@Override
public ExpressQueryResponse queryExpressOrder(String shipperCode, String logisticCode) {
public ExpressQueryResponse queryExpressOrder(String shipperCode, String logisticCode, String customerName) {
ExpressQueryRequestVo requestVo = new ExpressQueryRequestVo();
requestVo.setLogisticCode(logisticCode);
requestVo.setCustomerName(customerName);
requestVo.setShipperCode(shipperCode);
String requestData = JSONObject.toJSONString(requestVo);
Map<String, String> params = new HashMap<>();

View File

@@ -17,4 +17,8 @@ public class ExpressQueryRequestVo {
* 快递单号
*/
private String LogisticCode;
/**
* 手机尾号
*/
private String CustomerName;
}