flow
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
@@ -22,6 +21,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -88,11 +88,11 @@ public class BuyOrderController {
|
||||
@Transactional
|
||||
public R buySave(@RequestBody BuyOrderEntity buyOrder) throws IOException {
|
||||
// 获取订单详情
|
||||
List<BuyOrderDetailEntity> products = buyOrder.getProducts();
|
||||
List<BuyOrderDetail> products = buyOrder.getProducts();
|
||||
// 订单总金额
|
||||
BigDecimal totalPrice = new BigDecimal(0);
|
||||
// 遍历商品总价计算
|
||||
for (BuyOrderDetailEntity buyOrderDetail : products) {
|
||||
for (BuyOrderDetail buyOrderDetail : products) {
|
||||
Integer productId = buyOrderDetail.getProductId();
|
||||
int quantity = buyOrderDetail.getQuantity();
|
||||
ShopProductEntity product = shopProductService.getById(productId);
|
||||
@@ -103,7 +103,11 @@ public class BuyOrderController {
|
||||
totalPrice = totalPrice.add(price.multiply(BigDecimal.valueOf(quantity)));
|
||||
buyOrderDetail.setProductName(product.getProductName());
|
||||
buyOrderDetail.setProductPrice(product.getPrice());
|
||||
buyOrderDetail.setAddressId(buyOrder.getAddressId());
|
||||
int originWeight = product.getWeight();
|
||||
int originWeightIntValue = originWeight / 100;
|
||||
int originWeightDecimalValue = originWeightIntValue % 100;
|
||||
buyOrderDetail.setWeight(BigDecimal.valueOf(originWeightIntValue).add(BigDecimal.valueOf(originWeightDecimalValue).divide(new BigDecimal(100),
|
||||
MathContext.DECIMAL64)));
|
||||
buyOrderDetail.setProductUrl(product.getProductImages());
|
||||
buyOrderDetail.setOrderStatus(Constants.ORDER_STATUS_TO_BE_PAID);
|
||||
}
|
||||
@@ -115,7 +119,7 @@ public class BuyOrderController {
|
||||
buyOrder.setPaymentDate(new Date());
|
||||
buyOrderService.save(buyOrder);
|
||||
|
||||
for (BuyOrderDetailEntity buyOrderDetail : products) {
|
||||
for (BuyOrderDetail buyOrderDetail : products) {
|
||||
buyOrderDetail.setOrderId(buyOrder.getOrderId());
|
||||
buyOrderDetail.setUserId(buyOrder.getUserId());
|
||||
if (Constants.BUY_TYPE_CART.equals(buyOrder.getBuyType())) {
|
||||
@@ -182,27 +186,27 @@ public class BuyOrderController {
|
||||
public R appGetOrderInfo(@PathVariable String type, @RequestParam("orderId") Integer orderId) {
|
||||
BuyOrderEntity buyOrder = buyOrderService.getById(orderId);
|
||||
buyOrder.setTimestamp(buyOrder.getCreateTime().getTime() / 1000);
|
||||
List<BuyOrderDetailEntity> orderDetail = null;
|
||||
List<BuyOrderDetail> orderDetail = null;
|
||||
if ("1".equals(type)) {
|
||||
orderDetail = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>()
|
||||
orderDetail = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetail>()
|
||||
.eq("order_id", orderId));
|
||||
} else {
|
||||
orderDetail = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>()
|
||||
orderDetail = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetail>()
|
||||
.eq("order_id", orderId));
|
||||
}
|
||||
for (BuyOrderDetailEntity buyOrderDetailEntity : orderDetail) {
|
||||
for (BuyOrderDetail buyOrderDetail : orderDetail) {
|
||||
|
||||
ShopProductEntity prod = shopProductService.getById(buyOrderDetailEntity.getProductId());
|
||||
ShopProductEntity prod = shopProductService.getById(buyOrderDetail.getProductId());
|
||||
if (prod != null) {
|
||||
buyOrderDetailEntity.setImage(prod.getProductImages());
|
||||
buyOrderDetail.setImage(prod.getProductImages());
|
||||
}
|
||||
}
|
||||
|
||||
List<BuyOrderDetailEntity> resultOrder = new ArrayList<BuyOrderDetailEntity>();
|
||||
List<BuyOrderDetail> resultOrder = new ArrayList<BuyOrderDetail>();
|
||||
Set<String> sn_no = new HashSet<String>();
|
||||
for (BuyOrderDetailEntity buyOrderDetailEntity : orderDetail) {
|
||||
resultOrder.add(buyOrderDetailEntity);
|
||||
sn_no.add(buyOrderDetailEntity.getShippingSn());
|
||||
for (BuyOrderDetail buyOrderDetail : orderDetail) {
|
||||
resultOrder.add(buyOrderDetail);
|
||||
sn_no.add(buyOrderDetail.getExpressOrderId());
|
||||
}
|
||||
|
||||
UserRecordEntity userRecordEntity = userRecordService.getBaseMapper().selectOne(new QueryWrapper<UserRecordEntity>()
|
||||
@@ -222,22 +226,22 @@ public class BuyOrderController {
|
||||
/**
|
||||
* 及时查询快递信息
|
||||
*/
|
||||
@RequestMapping("/queryFMS")
|
||||
public R queryFMS(@RequestParam Map<String, String> params) {
|
||||
List<BuyOrderDetailEntity> detailList = this.buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>().eq("order_id", params.get("orderId")));
|
||||
List<JSONObject> jsonList = new ArrayList<>();
|
||||
JSONObject jsonObj = null;
|
||||
for (BuyOrderDetailEntity detail : detailList) {
|
||||
jsonObj = buyOrderService.queryFMS(detail.getShipperCode(), detail.getShippingSn());
|
||||
if (Objects.isNull(jsonObj)) {
|
||||
return R.ok("暂未查到物流信息!");
|
||||
}
|
||||
jsonObj.put("ShipperName", detail.getShipperName());
|
||||
jsonList.add(jsonObj);
|
||||
|
||||
}
|
||||
return R.ok().put("rntStr", jsonList);
|
||||
}
|
||||
// @RequestMapping("/queryFMS")
|
||||
// public R queryFMS(@RequestParam Map<String, String> params) {
|
||||
// List<BuyOrderDetailEntity> detailList = this.buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>().eq("order_id", params.get("orderId")));
|
||||
// List<JSONObject> jsonList = new ArrayList<>();
|
||||
// JSONObject jsonObj = null;
|
||||
// for (BuyOrderDetailEntity detail : detailList) {
|
||||
// jsonObj = buyOrderService.queryFMS(detail.getShipperCode(), detail.getShippingSn());
|
||||
// if (Objects.isNull(jsonObj)) {
|
||||
// return R.ok("暂未查到物流信息!");
|
||||
// }
|
||||
// jsonObj.put("ShipperName", detail.getShipperName());
|
||||
// jsonList.add(jsonObj);
|
||||
//
|
||||
// }
|
||||
// return R.ok().put("rntStr", jsonList);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 检查可合并的订单信息
|
||||
@@ -267,14 +271,14 @@ public class BuyOrderController {
|
||||
*
|
||||
* @param expressCompanyCode 快递公司编码
|
||||
* @param userAddressId 用户地址 ID
|
||||
* @param productIds 商品 ID 列表
|
||||
* @param buyOrderDetailId 订单详情列表
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping(value = "/createSplitPackages", method = RequestMethod.POST)
|
||||
public R createSplitPackageOrder(@RequestParam("expressCompanyCode") String expressCompanyCode,
|
||||
@RequestParam("userAddressId") Integer userAddressId,
|
||||
@RequestBody List<Integer> productIds) {
|
||||
buyOrderService.createSplitPackageOrder(expressCompanyCode, userAddressId, productIds);
|
||||
@RequestBody List<Integer> buyOrderDetailId) throws Exception {
|
||||
buyOrderService.createSplitPackageOrder(expressCompanyCode, userAddressId, buyOrderDetailId);
|
||||
return R.ok();
|
||||
|
||||
}
|
||||
@@ -297,7 +301,7 @@ public class BuyOrderController {
|
||||
* @param product
|
||||
* @return
|
||||
*/
|
||||
private boolean handleStock(BuyOrderDetailEntity buyOrderDetail, ShopProductEntity product) {
|
||||
private boolean handleStock(BuyOrderDetail buyOrderDetail, ShopProductEntity product) {
|
||||
int quantity = buyOrderDetail.getQuantity();
|
||||
if (product.getProductStock() - quantity < 0) {
|
||||
return false;
|
||||
@@ -380,8 +384,8 @@ public class BuyOrderController {
|
||||
* @param products
|
||||
* @param buyOrder
|
||||
*/
|
||||
private void addEbookToUser(List<BuyOrderDetailEntity> products, BuyOrderEntity buyOrder) {
|
||||
List<Integer> productIds = products.stream().map(BuyOrderDetailEntity::getProductId).collect(Collectors.toList());
|
||||
private void addEbookToUser(List<BuyOrderDetail> products, BuyOrderEntity buyOrder) {
|
||||
List<Integer> productIds = products.stream().map(BuyOrderDetail::getProductId).collect(Collectors.toList());
|
||||
for (Integer productId : productIds) {
|
||||
List<Integer> collect = shopProductBookService.getBaseMapper().selectList(new LambdaQueryWrapper<ShopProductBookEntity>()
|
||||
.eq(ShopProductBookEntity::getProductId, productId)
|
||||
@@ -396,7 +400,7 @@ public class BuyOrderController {
|
||||
* @param buyOrder
|
||||
* @param buyOrderDetail
|
||||
*/
|
||||
private void handleBuyCart(BuyOrderEntity buyOrder, BuyOrderDetailEntity buyOrderDetail) {
|
||||
private void handleBuyCart(BuyOrderEntity buyOrder, BuyOrderDetail buyOrderDetail) {
|
||||
List<OrderCartEntity> orderCartList = orderCartService.getBaseMapper().selectList(new QueryWrapper<OrderCartEntity>()
|
||||
.eq("user_id", buyOrder.getUserId()).eq("product_id", buyOrderDetail.getProductId()));
|
||||
if (orderCartList.size() > 0) {
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.peanut.modules.book.controller;
|
||||
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.BuyOrderDetailEntity;
|
||||
import com.peanut.modules.book.entity.BuyOrderDetail;
|
||||
import com.peanut.modules.book.service.BuyOrderDetailService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -61,7 +61,7 @@ public class BuyOrderDetailController {
|
||||
*/
|
||||
@RequestMapping("/info/{allOrderId}")
|
||||
public R info(@PathVariable("allOrderId") Long allOrderId) {
|
||||
BuyOrderDetailEntity buyOrderDetail = buyOrderDetailService.getById(allOrderId);
|
||||
BuyOrderDetail buyOrderDetail = buyOrderDetailService.getById(allOrderId);
|
||||
return R.ok().put("buyOrderDetail", buyOrderDetail);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class BuyOrderDetailController {
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody BuyOrderDetailEntity buyOrderDetail) {
|
||||
public R save(@RequestBody BuyOrderDetail buyOrderDetail) {
|
||||
buyOrderDetailService.save(buyOrderDetail);
|
||||
return R.ok();
|
||||
}
|
||||
@@ -78,7 +78,7 @@ public class BuyOrderDetailController {
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody BuyOrderDetailEntity buyOrderDetail) {
|
||||
public R update(@RequestBody BuyOrderDetail buyOrderDetail) {
|
||||
buyOrderDetailService.updateById(buyOrderDetail);
|
||||
return R.ok();
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public class BuyOrderDetailController {
|
||||
}
|
||||
|
||||
@RequestMapping("/updateOrderStatus")
|
||||
public R updateOrderStatus(@RequestBody BuyOrderDetailEntity buyOrderDetail) {
|
||||
public R updateOrderStatus(@RequestBody BuyOrderDetail buyOrderDetail) {
|
||||
buyOrderDetail.setOrderStatus("2");
|
||||
buyOrderDetailService.updateById(buyOrderDetail);
|
||||
return R.ok();
|
||||
@@ -108,7 +108,6 @@ public class BuyOrderDetailController {
|
||||
*/
|
||||
@RequestMapping("/batchUpdateByShippingSns")
|
||||
public R batchUpdateByShippingSns(@RequestBody String[] shippingSnList) {
|
||||
buyOrderDetailService.batchUpdateByShippingSns(shippingSnList);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,17 +98,17 @@ public class ShopProductController {
|
||||
public R bookList(@RequestParam("userId") Integer userId
|
||||
) {
|
||||
//查询已购买的书籍
|
||||
List<BuyOrderDetailEntity> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>()
|
||||
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 (BuyOrderDetailEntity buyOrderDetailEntity : buyOrderDetailEntities) {
|
||||
map.put("ProductId", String.valueOf(buyOrderDetailEntity.getProductId()));
|
||||
for (BuyOrderDetail buyOrderDetail : buyOrderDetailEntities) {
|
||||
map.put("ProductId", String.valueOf(buyOrderDetail.getProductId()));
|
||||
list.add(map);
|
||||
//去重取出以后买书籍的id
|
||||
purchasedProductIds.add(String.valueOf(buyOrderDetailEntity.getProductId()));
|
||||
purchasedProductIds.add(String.valueOf(buyOrderDetail.getProductId()));
|
||||
}
|
||||
//查询商品表并过滤已购买商品id,根据时间倒叙展示
|
||||
List<ShopProductEntity> allProductEntities = shopProductService.getBaseMapper().selectList(new QueryWrapper<ShopProductEntity>()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import cn.com.marsoft.tool.ToolObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
@@ -126,7 +125,7 @@ public class UserFollowUpController {
|
||||
Integer bookid = userRecord.getBookid();
|
||||
Integer userid = userRecord.getUserid();
|
||||
Integer id1 = userRecord.getId();
|
||||
BuyOrderDetailEntity detailEntity = buyOrderDetailService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderDetailEntity>()
|
||||
BuyOrderDetail detailEntity = buyOrderDetailService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderDetail>()
|
||||
.eq("Order_id", orderId).eq("product_id",bookid));
|
||||
|
||||
UserFollowUpEntity followUpEntity = userFollowUpService.getBaseMapper().selectOne(new QueryWrapper<UserFollowUpEntity>().eq("userid", userid).eq("oid",id1).last("LIMIT 1"));
|
||||
|
||||
@@ -204,7 +204,7 @@ public class UserRecordController {
|
||||
);
|
||||
|
||||
Integer orderId = buyOrderEntity.getOrderId();
|
||||
BuyOrderDetailEntity detailEntity = buyOrderDetailService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderDetailEntity>().eq("Order_id", orderId).eq("product_id", recordEntity.getBookid()));
|
||||
BuyOrderDetail detailEntity = buyOrderDetailService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderDetail>().eq("Order_id", orderId).eq("product_id", recordEntity.getBookid()));
|
||||
Integer orderId1 = detailEntity.getOrderId();
|
||||
UserRecordEntity userRecordEntity = userRecordService.getBaseMapper().selectOne(new QueryWrapper<UserRecordEntity>().eq("orderSn", recordEntity.getOrderSn()).eq("userid", recordEntity.getUserid()).eq("orderdid", orderId1).last("LIMIT 1"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user