bug fix 1018

This commit is contained in:
Cauchy
2023-10-18 16:37:58 +08:00
parent 5dee4b619e
commit c90ecfb7ce
33 changed files with 309 additions and 114 deletions

View File

@@ -265,9 +265,9 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
// 获取用户地址
Integer orderId = buyOrderDetailList.get(0).getOrderId();
BuyOrder buyOrder = getById(orderId);
QueryWrapper<CountyEntity> countyQueryWrapper = new QueryWrapper<>();
QueryWrapper<County> countyQueryWrapper = new QueryWrapper<>();
countyQueryWrapper.eq("county_name", buyOrder.getDistrict());
CountyEntity county = countyService.getOne(countyQueryWrapper);
County county = countyService.getOne(countyQueryWrapper);
// 计算快递费用
BigDecimal expressFee = expressFeeService.calculateExpressFee(expressCompanyCode, totalWeight, county.getRegionCode());
ExpressOrder expressOrder = new ExpressOrder();

View File

@@ -1,6 +1,6 @@
package com.peanut.modules.book.service.impl;
import com.peanut.modules.book.entity.CityEntity;
import com.peanut.modules.book.entity.City;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -14,13 +14,13 @@ import com.peanut.modules.book.service.CityService;
@Service("cityService")
public class CityServiceImpl extends ServiceImpl<CityDao, CityEntity> implements CityService {
public class CityServiceImpl extends ServiceImpl<CityDao, City> implements CityService {
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<CityEntity> page = this.page(
new Query<CityEntity>().getPage(params),
new QueryWrapper<CityEntity>()
IPage<City> page = this.page(
new Query<City>().getPage(params),
new QueryWrapper<City>()
);
return new PageUtils(page);

View File

@@ -1,6 +1,6 @@
package com.peanut.modules.book.service.impl;
import com.peanut.modules.book.entity.CountyEntity;
import com.peanut.modules.book.entity.County;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -14,13 +14,13 @@ import com.peanut.modules.book.service.CountyService;
@Service("countyService")
public class CountyServiceImpl extends ServiceImpl<CountyDao, CountyEntity> implements CountyService {
public class CountyServiceImpl extends ServiceImpl<CountyDao, County> implements CountyService {
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<CountyEntity> page = this.page(
new Query<CountyEntity>().getPage(params),
new QueryWrapper<CountyEntity>()
IPage<County> page = this.page(
new Query<County>().getPage(params),
new QueryWrapper<County>()
);
return new PageUtils(page);

View File

@@ -40,7 +40,7 @@ public class ExpressFeeServiceImpl extends ServiceImpl<ExpressFeeDao, ExpressFee
private BigDecimal calculateSFExpressFee(BigDecimal weight, String regionCode) {
// 判断运费计算区间
int weightInterval;
BigDecimal additionalWeight = null;
BigDecimal additionalWeight;
if (weight.compareTo(new BigDecimal(0)) >= 0 && weight.compareTo(new BigDecimal(3)) < 0) {
weightInterval = 1;
additionalWeight = weight.subtract(new BigDecimal(1));
@@ -72,7 +72,7 @@ public class ExpressFeeServiceImpl extends ServiceImpl<ExpressFeeDao, ExpressFee
* @return 费用
*/
private BigDecimal calculateYDExpressFee(BigDecimal weight, String regionCode) {
regionCode = regionCode.substring(0, 3).concat("00");
regionCode = regionCode.substring(0, 4).concat("00");
QueryWrapper<ExpressFee> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("dest_code", regionCode);
queryWrapper.eq("express_code", "YD");

View File

@@ -10,6 +10,7 @@ import com.peanut.modules.book.entity.ExpressOrder;
import com.peanut.modules.book.entity.ExpressQueryResponse;
import com.peanut.modules.book.service.ExpressOrderService;
import com.peanut.modules.book.vo.*;
import com.peanut.modules.book.vo.request.ExpressOrderRequestVo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

View File

@@ -1,8 +1,8 @@
package com.peanut.modules.book.service.impl;
import com.peanut.modules.book.entity.CityEntity;
import com.peanut.modules.book.entity.CountyEntity;
import com.peanut.modules.book.entity.ProvinceEntity;
import com.peanut.modules.book.entity.City;
import com.peanut.modules.book.entity.County;
import com.peanut.modules.book.entity.Province;
import com.peanut.modules.book.service.CityService;
import com.peanut.modules.book.service.CountyService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -21,7 +21,7 @@ import com.peanut.modules.book.service.ProvinceService;
@Service("provinceService")
public class ProvinceServiceImpl extends ServiceImpl<ProvinceDao, ProvinceEntity> implements ProvinceService {
public class ProvinceServiceImpl extends ServiceImpl<ProvinceDao, Province> implements ProvinceService {
@Autowired
private CityService cityService;
@@ -30,26 +30,26 @@ public class ProvinceServiceImpl extends ServiceImpl<ProvinceDao, ProvinceEntity
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<ProvinceEntity> page = this.page(
new Query<ProvinceEntity>().getPage(params),
new QueryWrapper<ProvinceEntity>()
IPage<Province> page = this.page(
new Query<Province>().getPage(params),
new QueryWrapper<Province>()
);
return new PageUtils(page);
}
@Override
public List<ProvinceEntity> getCity() {
List<ProvinceEntity> provinceList = this.baseMapper.selectList(new QueryWrapper<ProvinceEntity>());
for (ProvinceEntity province:provinceList){
List<CityEntity> prov = cityService.getBaseMapper().selectList(new QueryWrapper<CityEntity>()
public List<Province> getCity() {
List<Province> provinceList = this.baseMapper.selectList(new QueryWrapper<Province>());
for (Province province:provinceList){
List<City> prov = cityService.getBaseMapper().selectList(new QueryWrapper<City>()
.eq("prov_id", province.getProvId()));
if (prov.size() > 0) {
for (CityEntity cityEntity : prov) {
List<CountyEntity> countyList = countyService.getBaseMapper().selectList(new QueryWrapper<CountyEntity>().eq("city_id", cityEntity.getCityId()));
for (City city : prov) {
List<County> countyList = countyService.getBaseMapper().selectList(new QueryWrapper<County>().eq("city_id", city.getCityId()));
if (countyList != null) {
cityEntity.setCountyList(countyList);
city.setCountyList(countyList);
}
}
province.setCityList(prov);

View File

@@ -1,7 +1,17 @@
package com.peanut.modules.book.service.impl;
import com.peanut.modules.book.entity.City;
import com.peanut.modules.book.entity.County;
import com.peanut.modules.book.entity.Province;
import com.peanut.modules.book.service.CityService;
import com.peanut.modules.book.service.CountyService;
import com.peanut.modules.book.service.ProvinceService;
import com.peanut.modules.book.vo.UserAddressVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -15,6 +25,14 @@ import com.peanut.modules.book.service.UserAddressService;
@Service("userAddressService")
public class UserAddressServiceImpl extends ServiceImpl<UserAddressDao, UserAddress> implements UserAddressService {
@Autowired
private CountyService countyService;
@Autowired
private CityService cityService;
@Autowired
private ProvinceService provinceService;
@Override
public PageUtils queryPage(Map<String, Object> params) {
@@ -24,4 +42,34 @@ public class UserAddressServiceImpl extends ServiceImpl<UserAddressDao, UserAddr
);
return new PageUtils(page);
}
public UserAddressVo getAddressName(UserAddressVo vo, String regionCode) {
QueryWrapper<County> countyQueryWrapper = new QueryWrapper<>();
countyQueryWrapper.eq("region_code", regionCode);
County county = countyService.getOne(countyQueryWrapper);
vo.setCounty(county.getCountyName());
String cityRegionCode;
if (regionCode.startsWith("11") || regionCode.startsWith("12") || regionCode.startsWith("31") || regionCode.startsWith("50")) {
cityRegionCode = regionCode.substring(0, 2).concat("0000");
} else {
cityRegionCode = regionCode.substring(0, 4).concat("00");
}
QueryWrapper<City> cityQueryWrapper = new QueryWrapper<>();
cityQueryWrapper.eq("region_code", cityRegionCode);
City city = cityService.getOne(cityQueryWrapper);
vo.setCity(city.getCityName());
String provinceRegionCode = regionCode.substring(0, 2).concat("0000");
QueryWrapper<Province> provinceQueryWrapper = new QueryWrapper<>();
provinceQueryWrapper.eq("region_code", provinceRegionCode);
Province province = provinceService.getOne(provinceQueryWrapper);
vo.setProvince(province.getProvName());
return vo;
}
public int getUserDefaultAddressCount(Integer userId) {
QueryWrapper<UserAddress> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("user_id", userId);
queryWrapper.eq("is_default", 1);
return this.count(queryWrapper);
}
}