flow
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import jodd.util.StringUtil;
|
||||
import com.peanut.modules.book.entity.BuyOrderDetail;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@@ -12,19 +11,18 @@ import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
|
||||
import com.peanut.modules.book.dao.BuyOrderDetailDao;
|
||||
import com.peanut.modules.book.entity.BuyOrderDetailEntity;
|
||||
import com.peanut.modules.book.service.BuyOrderDetailService;
|
||||
|
||||
|
||||
@Service("buyOrderDetailService")
|
||||
public class BuyOrderDetailServiceImpl extends ServiceImpl<BuyOrderDetailDao, BuyOrderDetailEntity> implements BuyOrderDetailService {
|
||||
public class BuyOrderDetailServiceImpl extends ServiceImpl<BuyOrderDetailDao, BuyOrderDetail> implements BuyOrderDetailService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
Integer orderId = Integer.valueOf((String) params.get("orderId"));
|
||||
IPage<BuyOrderDetailEntity> page = this.page(
|
||||
new Query<BuyOrderDetailEntity>().getPage(params),
|
||||
new QueryWrapper<BuyOrderDetailEntity>()
|
||||
IPage<BuyOrderDetail> page = this.page(
|
||||
new Query<BuyOrderDetail>().getPage(params),
|
||||
new QueryWrapper<BuyOrderDetail>()
|
||||
.eq("order_id",orderId)
|
||||
);
|
||||
|
||||
@@ -38,9 +36,9 @@ public class BuyOrderDetailServiceImpl extends ServiceImpl<BuyOrderDetailDao, Bu
|
||||
*/
|
||||
@Override
|
||||
public PageUtils querySheet(Map<String, Object> params) {
|
||||
IPage<BuyOrderDetailEntity> page = this.page(
|
||||
new Query<BuyOrderDetailEntity>().getPage(params),
|
||||
new QueryWrapper<BuyOrderDetailEntity>().eq("is_print","0")
|
||||
IPage<BuyOrderDetail> page = this.page(
|
||||
new Query<BuyOrderDetail>().getPage(params),
|
||||
new QueryWrapper<BuyOrderDetail>().eq("is_print","0")
|
||||
.groupBy("shipping_sn")
|
||||
);
|
||||
return new PageUtils(page);
|
||||
@@ -49,9 +47,9 @@ public class BuyOrderDetailServiceImpl extends ServiceImpl<BuyOrderDetailDao, Bu
|
||||
@Override
|
||||
public PageUtils querybuy(Map<String, Object> params) {
|
||||
Integer userid = Integer.valueOf((String) params.get("id"));
|
||||
IPage<BuyOrderDetailEntity> page = this.page(
|
||||
new Query<BuyOrderDetailEntity>().getPage(params),
|
||||
new QueryWrapper<BuyOrderDetailEntity>()
|
||||
IPage<BuyOrderDetail> page = this.page(
|
||||
new Query<BuyOrderDetail>().getPage(params),
|
||||
new QueryWrapper<BuyOrderDetail>()
|
||||
.eq("user_id",userid)
|
||||
|
||||
);
|
||||
@@ -60,17 +58,17 @@ public class BuyOrderDetailServiceImpl extends ServiceImpl<BuyOrderDetailDao, Bu
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void batchUpdateByShippingSns(String[] shippingSnList) {
|
||||
List<BuyOrderDetailEntity> buyOrderDetailEntityList = this.list(new QueryWrapper<>());
|
||||
for(String sn : shippingSnList){
|
||||
for(BuyOrderDetailEntity buyOrderDetailEntity : buyOrderDetailEntityList){
|
||||
if(StringUtil.isNotEmpty(buyOrderDetailEntity.getShippingSn()) && buyOrderDetailEntity.getShippingSn().equals(sn)){
|
||||
buyOrderDetailEntity.setIsPrint("1");
|
||||
}
|
||||
}
|
||||
}
|
||||
this.updateBatchById(buyOrderDetailEntityList);
|
||||
}
|
||||
// @Override
|
||||
// public void batchUpdateByShippingSns(String[] shippingSnList) {
|
||||
// List<BuyOrderDetailEntity> buyOrderDetailEntityList = this.list(new QueryWrapper<>());
|
||||
// for(String sn : shippingSnList){
|
||||
// for(BuyOrderDetailEntity buyOrderDetailEntity : buyOrderDetailEntityList){
|
||||
// if(StringUtil.isNotEmpty(buyOrderDetailEntity.getShippingSn()) && buyOrderDetailEntity.getShippingSn().equals(sn)){
|
||||
// buyOrderDetailEntity.setIsPrint("1");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// this.updateBatchById(buyOrderDetailEntityList);
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.modules.book.dao.BuyOrderDao;
|
||||
import com.peanut.modules.book.dao.ShopProductDao;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.book.entity.ExpressCommodity;
|
||||
@@ -34,9 +33,6 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
@Autowired
|
||||
private MyUserService myUserService;
|
||||
|
||||
@Autowired
|
||||
private ShopProductDao shopProductDao;
|
||||
|
||||
@Autowired
|
||||
private UserAddressService userAddressService;
|
||||
|
||||
@@ -89,7 +85,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
MyUserEntity myUserEntity = myUserService.getById(userId);
|
||||
if (!ObjectUtils.isEmpty(myUserEntity)) {
|
||||
record.setUserName(myUserEntity.getName());
|
||||
record.setProducts(buyOrderDetailService.list(new QueryWrapper<BuyOrderDetailEntity>()
|
||||
record.setProducts(buyOrderDetailService.list(new QueryWrapper<BuyOrderDetail>()
|
||||
.eq("order_id", record.getOrderId())));
|
||||
}
|
||||
|
||||
@@ -139,7 +135,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
new QueryWrapper<BuyOrderEntity>().eq("del_flag", "0").eq("order_status", "1")
|
||||
);
|
||||
for (BuyOrderEntity order : buyOrderList) {
|
||||
order.setProducts(buyOrderDetailService.list(new QueryWrapper<BuyOrderDetailEntity>()
|
||||
order.setProducts(buyOrderDetailService.list(new QueryWrapper<BuyOrderDetail>()
|
||||
.eq("order_id", order.getOrderId())));
|
||||
orderList.add(order);
|
||||
}
|
||||
@@ -209,7 +205,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
new QueryWrapper<BuyOrderEntity>().eq("del_flag", "0").eq("order_status", "1").eq("is_send", "0")
|
||||
);
|
||||
for (BuyOrderEntity order : buyOrderList.getRecords()) {
|
||||
order.setProducts(buyOrderDetailService.list(new QueryWrapper<BuyOrderDetailEntity>()
|
||||
order.setProducts(buyOrderDetailService.list(new QueryWrapper<BuyOrderDetail>()
|
||||
.eq("order_id", order.getOrderId())));
|
||||
orderList.add(order);
|
||||
}
|
||||
@@ -249,34 +245,34 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
|
||||
@Override
|
||||
public void createSplitPackageOrder(String expressCompanyCode, Integer userAddressId, List<Integer> buyOrderDetailId) throws Exception {
|
||||
QueryWrapper<BuyOrderDetailEntity> queryWrapper = new QueryWrapper<>();
|
||||
QueryWrapper<BuyOrderDetail> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("id", buyOrderDetailId);
|
||||
List<BuyOrderDetailEntity> buyOrderDetailList = buyOrderDetailService.list(queryWrapper);
|
||||
List<BuyOrderDetail> buyOrderDetailList = buyOrderDetailService.list(queryWrapper);
|
||||
BigDecimal totalWeight = new BigDecimal(0);
|
||||
List<ExpressCommodity> commodityList = new ArrayList<>();
|
||||
for (BuyOrderDetailEntity buyOrderDetail : buyOrderDetailList) {
|
||||
for (BuyOrderDetail buyOrderDetail : buyOrderDetailList) {
|
||||
ExpressCommodity commodity = new ExpressCommodity();
|
||||
commodity.setGoodsName(buyOrderDetail.getProductName());
|
||||
commodity.setGoodsquantity(buyOrderDetail.getQuantity());
|
||||
commodity.setGoodsWeight(buyOrderDetail.getWeight());
|
||||
commodity.setGoodsWeight(buyOrderDetail.getWeight().doubleValue());
|
||||
totalWeight = totalWeight.add(
|
||||
BigDecimal.valueOf(buyOrderDetail.getWeight()).multiply(new BigDecimal(buyOrderDetail.getQuantity()))
|
||||
BigDecimal.valueOf(buyOrderDetail.getWeight().doubleValue()).multiply(new BigDecimal(buyOrderDetail.getQuantity()))
|
||||
);
|
||||
commodityList.add(commodity);
|
||||
}
|
||||
|
||||
|
||||
// 获取用户地址
|
||||
UserAddress address = userAddressService.getById(userAddressId);
|
||||
// 计算快递费用
|
||||
BigDecimal expressFee = expressFeeService.calculateExpressFee(expressCompanyCode, totalWeight, address.getRegionCode());
|
||||
ExpressOrder expressOrder = new ExpressOrder();
|
||||
expressOrder.setOrderId(buyOrderDetailList.get(0).getOrderId());
|
||||
expressOrder.setExpressFee(expressFee);
|
||||
expressOrder.setCreateTime(new Date());
|
||||
expressOrder.setTotalWeight(totalWeight);
|
||||
expressOrder.setCommodity(commodityList);
|
||||
expressOrder.setExpressCompanyCode(expressCompanyCode);
|
||||
// 生成快递面单
|
||||
expressOrderService.placeExpressOrder(address, expressOrder);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,16 +5,16 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.book.dao.ExpressFeeDao;
|
||||
import com.peanut.modules.book.entity.ExpressFee;
|
||||
import com.peanut.modules.book.service.ExpressFeeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
/**
|
||||
* @Description: 快递费用服务接口实现类
|
||||
* @Author: Cauchy
|
||||
* @CreateTime: 2023/10/16
|
||||
*/
|
||||
@Service
|
||||
public class ExpressFeeServiceImpl extends ServiceImpl<ExpressFeeDao, ExpressFee> implements ExpressFeeService {
|
||||
@Override
|
||||
public BigDecimal calculateExpressFee(String expressCompanyCode, BigDecimal weight, String regionCode) {
|
||||
@@ -52,7 +52,9 @@ public class ExpressFeeServiceImpl extends ServiceImpl<ExpressFeeDao, ExpressFee
|
||||
additionalWeight = weight.subtract(new BigDecimal(15));
|
||||
}
|
||||
QueryWrapper<ExpressFee> queryWrapper = new QueryWrapper<>();
|
||||
regionCode = regionCode.substring(0, 3).concat("00");
|
||||
if(!regionCode.startsWith("11") && !regionCode.startsWith("12") && !regionCode.startsWith("31") && !regionCode.startsWith("50")){
|
||||
regionCode = regionCode.substring(0, 4).concat("00");
|
||||
}
|
||||
queryWrapper.eq("dest_code", regionCode);
|
||||
queryWrapper.eq("weight_interval", weightInterval);
|
||||
queryWrapper.eq("express_code", "SF");
|
||||
|
||||
@@ -53,14 +53,19 @@ public class ExpressOrderServiceImpl extends ServiceImpl<ExpressOrderDao, Expres
|
||||
public void placeExpressOrder(UserAddress userAddress, ExpressOrder expressOrder) throws Exception {
|
||||
ExpressOrderRequestVo orderRequestVo = new ExpressOrderRequestVo();
|
||||
// 订单号
|
||||
orderRequestVo.setOrderCode(expressOrder.getOrderId());
|
||||
orderRequestVo.setOrderCode(expressOrder.getOrderId().toString());
|
||||
orderRequestVo.setIsReturnPrintTemplate(1);
|
||||
orderRequestVo.setShipperCode(expressOrder.getExpressCompanyCode());
|
||||
orderRequestVo.setPayType(3);
|
||||
if (expressOrder.getExpressCompanyCode().equals("SF")) {
|
||||
orderRequestVo.setMonthCode(Constants.EXPRESS_SF_MONTH_CODE);
|
||||
}
|
||||
|
||||
orderRequestVo.setExpType(1);
|
||||
orderRequestVo.setCost(expressOrder.getExpressFee().doubleValue());
|
||||
// 发货人
|
||||
ExpressUserInfoVo sender = new ExpressUserInfoVo();
|
||||
sender.setCompany(senderName);
|
||||
sender.setName(senderName);
|
||||
sender.setMobile(senderMobile);
|
||||
sender.setProvinceName(senderProvinceName);
|
||||
sender.setCityName(senderCityName);
|
||||
@@ -88,7 +93,7 @@ public class ExpressOrderServiceImpl extends ServiceImpl<ExpressOrderDao, Expres
|
||||
|
||||
private ExpressUserInfoVo buildReceiverBasedOnUserAddress(UserAddress userAddress) {
|
||||
ExpressUserInfoVo vo = new ExpressUserInfoVo();
|
||||
vo.setCompany(userAddress.getConsigneeName());
|
||||
vo.setName(userAddress.getConsigneeName());
|
||||
vo.setMobile(userAddress.getConsigneePhone());
|
||||
vo.setAddress(userAddress.getDetailAddress());
|
||||
String regionCode = userAddress.getRegionCode();
|
||||
@@ -98,15 +103,15 @@ public class ExpressOrderServiceImpl extends ServiceImpl<ExpressOrderDao, Expres
|
||||
vo.setExpAreaName(county.getCountyName());
|
||||
String cityRegionCode;
|
||||
if (regionCode.startsWith("11") || regionCode.startsWith("12") || regionCode.startsWith("31") || regionCode.startsWith("50")) {
|
||||
cityRegionCode = regionCode.substring(0, 1).concat("0000");
|
||||
cityRegionCode = regionCode.substring(0, 2).concat("0000");
|
||||
} else {
|
||||
cityRegionCode = regionCode.substring(0, 3).concat("00");
|
||||
cityRegionCode = regionCode.substring(0, 4).concat("00");
|
||||
}
|
||||
QueryWrapper<CityEntity> cityQueryWrapper = new QueryWrapper<>();
|
||||
cityQueryWrapper.eq("region_code", cityRegionCode);
|
||||
CityEntity city = cityService.getOne(cityQueryWrapper);
|
||||
vo.setCityName(city.getCityName());
|
||||
String provinceRegionCode = regionCode.substring(0, 1).concat("0000");
|
||||
String provinceRegionCode = regionCode.substring(0, 2).concat("0000");
|
||||
QueryWrapper<ProvinceEntity> provinceQueryWrapper = new QueryWrapper<>();
|
||||
provinceQueryWrapper.eq("region_code", provinceRegionCode);
|
||||
ProvinceEntity province = provinceService.getOne(provinceQueryWrapper);
|
||||
|
||||
Reference in New Issue
Block a user