bug fix 1018
This commit is contained in:
@@ -745,18 +745,18 @@ public class BookController {
|
||||
@RequestMapping("/file")
|
||||
public String getFile() {
|
||||
String filePath = "C:\\Users\\Administrator\\IdeaProjects\\peanut_book\\2020年8月中华人民共和国县以上行政区划代码.json";
|
||||
List<ProvinceEntity> provinceList = ReadProvinceUtil.getFile(filePath);
|
||||
List<Province> provinceList = ReadProvinceUtil.getFile(filePath);
|
||||
// System.out.println(provinceList);
|
||||
if (provinceList != null && provinceList.size() > 0) {
|
||||
for (ProvinceEntity province : provinceList) {
|
||||
for (Province province : provinceList) {
|
||||
// ProvinceEntity provinceEntity = new ProvinceEntity();
|
||||
// provinceEntity.setProvName(province.getProvName());
|
||||
// provinceEntity.setCreateDate(province.getCreateDate());
|
||||
// provinceEntity.setRegionCode(province.getRegionCode());
|
||||
provinceService.save(province);
|
||||
List<CityEntity> cityList = province.getCityList();
|
||||
List<City> cityList = province.getCityList();
|
||||
if (cityList != null && cityList.size() > 0) {
|
||||
for (CityEntity city : cityList) {
|
||||
for (City city : cityList) {
|
||||
// CityEntity cityEntity = new CityEntity();
|
||||
// cityEntity.setCreateDate(city.getCreateDate());
|
||||
// cityEntity.setCityName(city.getCityName());
|
||||
@@ -764,9 +764,9 @@ public class BookController {
|
||||
// city.setProvId(province.getProvId());
|
||||
city.setProvId(province.getProvId());
|
||||
cityService.save(city);
|
||||
List<CountyEntity> countyList = city.getCountyList();
|
||||
List<County> countyList = city.getCountyList();
|
||||
if (countyList != null && countyList.size() > 0) {
|
||||
for (CountyEntity county : countyList) {
|
||||
for (County county : countyList) {
|
||||
// CountyEntity countyEntity = new CountyEntity();
|
||||
county.setCityId(city.getCityId());
|
||||
// countyEntity.setCountyName(county.getCountyName());
|
||||
|
||||
@@ -10,10 +10,15 @@ import com.peanut.config.Constants;
|
||||
import com.peanut.config.DelayQueueConfig;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.book.vo.ExpressQueryResponseVo;
|
||||
import com.peanut.modules.book.vo.request.ProductRequestVo;
|
||||
import com.peanut.modules.book.vo.request.ProductTransportVo;
|
||||
import com.peanut.modules.book.vo.response.ExpressQueryResponseVo;
|
||||
import com.peanut.modules.book.vo.ShippingAddressRequestVo;
|
||||
import com.peanut.modules.book.vo.UserAddressVo;
|
||||
import com.peanut.modules.pay.weChatPay.dto.WechatPaymentInfo;
|
||||
import com.peanut.modules.pay.weChatPay.service.WxpayService;
|
||||
import com.peanut.modules.sys.entity.SysConfigEntity;
|
||||
import com.peanut.modules.sys.service.SysConfigService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.MessagePostProcessor;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
@@ -24,6 +29,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -61,12 +67,16 @@ public class BuyOrderController {
|
||||
private WxpayService wxpayService;
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
@Autowired
|
||||
private ShopProductBookService shopProductBookService;
|
||||
|
||||
@Autowired
|
||||
private ExpressOrderService expressOrderService;
|
||||
@Autowired
|
||||
private UserAddressService userAddressService;
|
||||
@Autowired
|
||||
private ExpressFeeService expressFeeService;
|
||||
@Autowired
|
||||
private SysConfigService sysConfigService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
@@ -91,11 +101,11 @@ public class BuyOrderController {
|
||||
@Transactional
|
||||
public R buySave(@RequestBody BuyOrder buyOrder) throws IOException {
|
||||
// 获取订单详情
|
||||
List<BuyOrderDetail> products = buyOrder.getProducts();
|
||||
List<BuyOrderDetail> buyOrderDetails = buyOrder.getProducts();
|
||||
// 订单总金额
|
||||
BigDecimal totalPrice = new BigDecimal(0);
|
||||
// 遍历商品总价计算
|
||||
for (BuyOrderDetail buyOrderDetail : products) {
|
||||
for (BuyOrderDetail buyOrderDetail : buyOrderDetails) {
|
||||
Integer productId = buyOrderDetail.getProductId();
|
||||
int quantity = buyOrderDetail.getQuantity();
|
||||
ShopProductEntity product = shopProductService.getById(productId);
|
||||
@@ -120,16 +130,24 @@ public class BuyOrderController {
|
||||
String orderSn = IdWorker.getTimeId().substring(0, 32);
|
||||
buyOrder.setOrderSn(orderSn);
|
||||
buyOrder.setPaymentDate(new Date());
|
||||
QueryWrapper<UserAddress> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("id", buyOrder.getAddressId());
|
||||
UserAddress userAddress = userAddressService.getOne(queryWrapper);
|
||||
UserAddressVo vo = new UserAddressVo();
|
||||
vo = userAddressService.getAddressName(vo, userAddress.getRegionCode());
|
||||
buyOrder.setProvince(vo.getProvince());
|
||||
buyOrder.setCity(vo.getCity());
|
||||
buyOrder.setDistrict(vo.getCity());
|
||||
buyOrderService.save(buyOrder);
|
||||
|
||||
for (BuyOrderDetail buyOrderDetail : products) {
|
||||
for (BuyOrderDetail buyOrderDetail : buyOrderDetails) {
|
||||
buyOrderDetail.setOrderId(buyOrder.getOrderId());
|
||||
buyOrderDetail.setUserId(buyOrder.getUserId());
|
||||
if (Constants.BUY_TYPE_CART.equals(buyOrder.getBuyType())) {
|
||||
handleBuyCart(buyOrder, buyOrderDetail);
|
||||
}
|
||||
}
|
||||
buyOrderDetailService.saveBatch(products);
|
||||
buyOrderDetailService.saveBatch(buyOrderDetails);
|
||||
// 1. 虚拟币支付
|
||||
if (Constants.PAYMENT_METHOD_VIRTUAL.equals(buyOrder.getPaymentMethod())) {
|
||||
buyOrder.setOrderStatus(Constants.ORDER_STATUS_TO_BE_SHIPPED);
|
||||
@@ -138,7 +156,7 @@ public class BuyOrderController {
|
||||
// 更新订单状态
|
||||
buyOrderService.updateOrderStatus(user.getId(), buyOrder.getOrderSn(), "0");
|
||||
recordTransaction(buyOrder, user, totalPrice);
|
||||
addEbookToUser(products, buyOrder);
|
||||
addEbookToUser(buyOrderDetails, buyOrder);
|
||||
} else {
|
||||
return R.error(500, "花生币余额不足!");
|
||||
}
|
||||
@@ -163,6 +181,24 @@ public class BuyOrderController {
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/calculateTransportPrice", method = RequestMethod.POST)
|
||||
public R getTransportPrice(@RequestBody ProductTransportVo vo) {
|
||||
String regionCode = vo.getRegionCode();
|
||||
List<ProductRequestVo> products = vo.getProducts();
|
||||
BigDecimal totalWeight = new BigDecimal(0);
|
||||
for (ProductRequestVo product : products) {
|
||||
ShopProductEntity shopProduct = shopProductService.getById(product.getProductId());
|
||||
BigDecimal weight = BigDecimal.valueOf(Double.valueOf(shopProduct.getWeight()) / 1000.0);
|
||||
totalWeight = totalWeight.add(weight.multiply(new BigDecimal(product.getQuantity())));
|
||||
}
|
||||
totalWeight = totalWeight.setScale(0, RoundingMode.UP);
|
||||
QueryWrapper<SysConfigEntity> configQueryWrapper = new QueryWrapper<>();
|
||||
configQueryWrapper.eq("param_key", "DEFAULT_EXPRESS");
|
||||
SysConfigEntity config = sysConfigService.getOne(configQueryWrapper);
|
||||
BigDecimal expressFee = expressFeeService.calculateExpressFee(config.getParamValue(), totalWeight, regionCode);
|
||||
return R.ok().put("result", expressFee);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改
|
||||
|
||||
@@ -4,9 +4,9 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
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 com.peanut.modules.book.service.ProvinceService;
|
||||
@@ -50,15 +50,15 @@ public class ProvinceController {
|
||||
}
|
||||
return R.ok().put("provinceEntity", listData);
|
||||
}
|
||||
List<ProvinceEntity> provinceEntityList = provinceService.getCity();
|
||||
redisTemplate.opsForValue().set("Province", JSON.toJSONString(provinceEntityList));
|
||||
return R.ok().put("provinceEntity", provinceEntityList);
|
||||
List<Province> provinceList = provinceService.getCity();
|
||||
redisTemplate.opsForValue().set("Province", JSON.toJSONString(provinceList));
|
||||
return R.ok().put("provinceEntity", provinceList);
|
||||
}
|
||||
|
||||
//获取省列表
|
||||
@RequestMapping("/getProvinceList")
|
||||
public R getProvinceList() {
|
||||
List<ProvinceEntity> provinceList = provinceService.getBaseMapper().selectList(new QueryWrapper<ProvinceEntity>());
|
||||
List<Province> provinceList = provinceService.getBaseMapper().selectList(new QueryWrapper<Province>());
|
||||
|
||||
return R.ok().put("provinceList", provinceList);
|
||||
}
|
||||
@@ -66,7 +66,7 @@ public class ProvinceController {
|
||||
//获取市列表
|
||||
@RequestMapping("/getCityList")
|
||||
public R getCityList(@RequestParam("provId") Integer provId) {
|
||||
List<CityEntity> prov = cityService.getBaseMapper().selectList(new QueryWrapper<CityEntity>()
|
||||
List<City> prov = cityService.getBaseMapper().selectList(new QueryWrapper<City>()
|
||||
.eq("prov_id", provId));
|
||||
return R.ok().put("prov", prov);
|
||||
}
|
||||
@@ -74,7 +74,7 @@ public class ProvinceController {
|
||||
//获取区列表
|
||||
@RequestMapping("/getCountyList")
|
||||
public R getCountyList(@RequestParam("cityId") Integer cityId) {
|
||||
List<CountyEntity> countyList = countyService.getBaseMapper().selectList(new QueryWrapper<CountyEntity>().eq("city_id", cityId));
|
||||
List<County> countyList = countyService.getBaseMapper().selectList(new QueryWrapper<County>().eq("city_id", cityId));
|
||||
return R.ok().put("countyList", countyList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.UserAddress;
|
||||
import com.peanut.modules.book.service.UserAddressService;
|
||||
import com.peanut.modules.book.vo.UserAddressVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@RestController
|
||||
@@ -18,19 +19,6 @@ public class UserAddressController {
|
||||
@Autowired
|
||||
private UserAddressService userAddressService;
|
||||
|
||||
/**
|
||||
* 用户地址列表
|
||||
*
|
||||
* @param params param
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
public R list(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = userAddressService.queryPage(params);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取地址信息
|
||||
*
|
||||
@@ -40,18 +28,34 @@ public class UserAddressController {
|
||||
@RequestMapping("/info/{addressId}")
|
||||
public R info(@PathVariable("addressId") Integer addressId) {
|
||||
UserAddress userAddress = userAddressService.getById(addressId);
|
||||
return R.ok().put("userAddress", userAddress);
|
||||
UserAddressVo vo = new UserAddressVo();
|
||||
BeanUtil.copyProperties(userAddress, vo);
|
||||
vo = userAddressService.getAddressName(vo, userAddress.getRegionCode());
|
||||
return R.ok().put("result", vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存、更新
|
||||
* 保存
|
||||
*
|
||||
* @param userAddress 用户地址
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody UserAddress userAddress) {
|
||||
userAddressService.saveOrUpdate(userAddress);
|
||||
// 判断是否已经有默认的地址了
|
||||
if ((userAddressService.getUserDefaultAddressCount(userAddress.getUserId()) >= 1) && userAddress.getIsDefault() == 1) {
|
||||
return R.error("已经存在默认地址");
|
||||
}
|
||||
userAddressService.save(userAddress);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody UserAddress userAddress) {
|
||||
if ((userAddressService.getUserDefaultAddressCount(userAddress.getUserId()) >= 1) && userAddress.getIsDefault() == 1) {
|
||||
return R.error("已经存在默认地址");
|
||||
}
|
||||
userAddressService.updateById(userAddress);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -79,6 +83,13 @@ public class UserAddressController {
|
||||
queryWrapper.eq("user_id", userId);
|
||||
queryWrapper.orderByDesc("is_default");
|
||||
List<UserAddress> userAddressList = userAddressService.list(queryWrapper);
|
||||
return R.ok().put("list", userAddressList);
|
||||
List<UserAddressVo> result = new ArrayList<>();
|
||||
for (UserAddress userAddress : userAddressList) {
|
||||
UserAddressVo vo = new UserAddressVo();
|
||||
BeanUtil.copyProperties(userAddress, vo);
|
||||
vo = userAddressService.getAddressName(vo, userAddress.getRegionCode());
|
||||
result.add(vo);
|
||||
}
|
||||
return R.ok().put("list", result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.peanut.modules.book.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.peanut.modules.book.entity.CityEntity;
|
||||
import com.peanut.modules.book.entity.City;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
@@ -12,6 +12,6 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
* @date 2022-10-27 16:07:59
|
||||
*/
|
||||
@Mapper
|
||||
public interface CityDao extends BaseMapper<CityEntity> {
|
||||
public interface CityDao extends BaseMapper<City> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.peanut.modules.book.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.peanut.modules.book.entity.CountyEntity;
|
||||
import com.peanut.modules.book.entity.County;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
@@ -12,6 +12,6 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
* @date 2022-10-27 16:07:59
|
||||
*/
|
||||
@Mapper
|
||||
public interface CountyDao extends BaseMapper<CountyEntity> {
|
||||
public interface CountyDao extends BaseMapper<County> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.peanut.modules.book.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.peanut.modules.book.entity.ProvinceEntity;
|
||||
import com.peanut.modules.book.entity.Province;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
@@ -12,6 +12,6 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
* @date 2022-10-27 16:07:59
|
||||
*/
|
||||
@Mapper
|
||||
public interface ProvinceDao extends BaseMapper<ProvinceEntity> {
|
||||
public interface ProvinceDao extends BaseMapper<Province> {
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import lombok.Data;
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_city")
|
||||
public class CityEntity implements Serializable {
|
||||
public class City implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
@@ -46,5 +46,5 @@ public class CityEntity implements Serializable {
|
||||
private String regionCode;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<CountyEntity> countyList;
|
||||
private List<County> countyList;
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
package com.peanut.modules.book.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -20,7 +18,7 @@ import lombok.Data;
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_county")
|
||||
public class CountyEntity implements Serializable {
|
||||
public class County implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
@@ -20,7 +20,7 @@ import lombok.Data;
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_province")
|
||||
public class ProvinceEntity implements Serializable {
|
||||
public class Province implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
@@ -42,5 +42,5 @@ public class ProvinceEntity implements Serializable {
|
||||
private String regionCode;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<CityEntity> cityList;
|
||||
private List<City> cityList;
|
||||
}
|
||||
@@ -167,6 +167,4 @@ public class ShopProductEntity implements Serializable {
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<String> shoproudLabels;
|
||||
|
||||
private int expressOrderId;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.peanut.modules.book.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.book.entity.CityEntity;
|
||||
import com.peanut.modules.book.entity.City;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.Map;
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-27 16:07:59
|
||||
*/
|
||||
public interface CityService extends IService<CityEntity> {
|
||||
public interface CityService extends IService<City> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.peanut.modules.book.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.book.entity.CountyEntity;
|
||||
import com.peanut.modules.book.entity.County;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.Map;
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-27 16:07:59
|
||||
*/
|
||||
public interface CountyService extends IService<CountyEntity> {
|
||||
public interface CountyService extends IService<County> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.peanut.modules.book.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.book.entity.ProvinceEntity;
|
||||
import com.peanut.modules.book.entity.Province;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -14,10 +14,10 @@ import java.util.Map;
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-27 16:07:59
|
||||
*/
|
||||
public interface ProvinceService extends IService<ProvinceEntity> {
|
||||
public interface ProvinceService extends IService<Province> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
List<ProvinceEntity> getCity();
|
||||
List<Province> getCity();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,12 +3,11 @@ package com.peanut.modules.book.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.book.entity.UserAddress;
|
||||
import com.peanut.modules.book.vo.UserAddressVo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-31 11:20:32
|
||||
@@ -16,5 +15,9 @@ import java.util.Map;
|
||||
public interface UserAddressService extends IService<UserAddress> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
UserAddressVo getAddressName(UserAddressVo vo, String regionCode);
|
||||
|
||||
int getUserDefaultAddressCount(Integer userId);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.peanut.modules.book.vo;
|
||||
|
||||
import com.peanut.modules.book.vo.response.ExpressResponseOrderVo;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
|
||||
58
src/main/java/com/peanut/modules/book/vo/UserAddressVo.java
Normal file
58
src/main/java/com/peanut/modules/book/vo/UserAddressVo.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package com.peanut.modules.book.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description: 用户地址 Value Object
|
||||
* @Author: Cauchy
|
||||
* @CreateTime: 2023/10/18
|
||||
*/
|
||||
@Data
|
||||
public class UserAddressVo {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private int id;
|
||||
/**
|
||||
* 会员 ID
|
||||
*/
|
||||
private Integer userId;
|
||||
/**
|
||||
* 收货人
|
||||
*/
|
||||
private String consigneeName;
|
||||
/**
|
||||
* 收货人手机号码
|
||||
*/
|
||||
private String consigneePhone;
|
||||
/**
|
||||
* 区域代码
|
||||
*/
|
||||
private String regionCode;
|
||||
/**
|
||||
* 详细地址
|
||||
*/
|
||||
private String detailAddress;
|
||||
/**
|
||||
* 默认
|
||||
*/
|
||||
private Integer isDefault;
|
||||
/**
|
||||
* 省
|
||||
*/
|
||||
private String province;
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
private String city;
|
||||
/**
|
||||
* 县
|
||||
*/
|
||||
private String county;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.peanut.modules.book.vo;
|
||||
package com.peanut.modules.book.vo.request;
|
||||
|
||||
import com.peanut.modules.book.entity.ExpressCommodity;
|
||||
import com.peanut.modules.book.vo.ExpressUserInfoVo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.peanut.modules.book.vo.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: 商品请求 Value Object
|
||||
* @Author: Cauchy
|
||||
* @CreateTime: 2023/10/18
|
||||
*/
|
||||
@Data
|
||||
public class ProductRequestVo {
|
||||
/**
|
||||
* 商品 ID
|
||||
*/
|
||||
private String productId;
|
||||
/**
|
||||
* 商品数量
|
||||
*/
|
||||
private int quantity;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.peanut.modules.book.vo.request;
|
||||
|
||||
import com.peanut.modules.book.entity.ShopProductEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 计算运费
|
||||
* @Author: Cauchy
|
||||
* @CreateTime: 2023/10/18
|
||||
*/
|
||||
@Data
|
||||
public class ProductTransportVo {
|
||||
|
||||
private String regionCode;
|
||||
|
||||
private List<ProductRequestVo> products;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.peanut.modules.book.vo;
|
||||
package com.peanut.modules.book.vo.response;
|
||||
|
||||
import com.peanut.modules.book.entity.Trace;
|
||||
import lombok.Data;
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.peanut.modules.book.vo;
|
||||
package com.peanut.modules.book.vo.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: TODO
|
||||
* @Description: 快递查询相应 Order Value Object
|
||||
* @Author: Cauchy
|
||||
* @CreateTime: 2023/10/17
|
||||
*/
|
||||
Reference in New Issue
Block a user