bug fix
This commit is contained in:
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.config.Constants;
|
||||
import com.peanut.config.DelayQueueConfig;
|
||||
@@ -18,11 +19,13 @@ import com.peanut.modules.book.vo.response.BuyOrderResponseVo;
|
||||
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.book.vo.response.OrderAddressResponseVo;
|
||||
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.apache.poi.ss.formula.functions.Count;
|
||||
import org.springframework.amqp.core.MessagePostProcessor;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -82,6 +85,12 @@ public class BuyOrderController {
|
||||
private SysConfigService sysConfigService;
|
||||
@Autowired
|
||||
private BuyOrderProductService buyOrderProductService;
|
||||
@Autowired
|
||||
private ProvinceService provinceService;
|
||||
@Autowired
|
||||
private CityService cityService;
|
||||
@Autowired
|
||||
private CountyService countyService;
|
||||
|
||||
@RequestMapping(value = "/decomposeShipment", method = RequestMethod.GET)
|
||||
public R decomposeShipment(@RequestParam("userId") Integer userId) {
|
||||
@@ -361,6 +370,7 @@ public class BuyOrderController {
|
||||
|
||||
/**
|
||||
* app 端 取消订单
|
||||
* TODO 新版本上线后此方法删除
|
||||
*/
|
||||
@RequestMapping("/appDelete")
|
||||
@Transactional
|
||||
@@ -392,37 +402,37 @@ public class BuyOrderController {
|
||||
}
|
||||
|
||||
/**
|
||||
* app 端 取消订单
|
||||
* @param orderSn 订单号
|
||||
* @return R
|
||||
*/
|
||||
// @RequestMapping("/cancelOrder")
|
||||
// @Transactional
|
||||
// public R appDelete(@RequestParam("orderSn") String orderSn) {
|
||||
// QueryWrapper<BuyOrder> qu
|
||||
//
|
||||
// //1. 判断订单状态
|
||||
// BuyOrder byId = buyOrderService.getById(orderId);
|
||||
// if (byId != null) {
|
||||
// //2. 判断当前订单是否存在优惠券 进行 回显
|
||||
// Integer couponId = byId.getCouponId();
|
||||
// if (couponId != null) {
|
||||
//
|
||||
// CouponHistoryEntity byId1 = couponHistoryService.getById(couponId);
|
||||
// byId1.setUseStatus(0);
|
||||
// couponHistoryService.updateById(byId1);
|
||||
// }
|
||||
// // 库存回滚
|
||||
// List<BuyOrderDetail> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetail>()
|
||||
// .eq("order_id", byId.getOrderId()));
|
||||
// for (BuyOrderDetail buyOrderDetailEntity : buyOrderDetailEntities) {
|
||||
// Integer productId = buyOrderDetailEntity.getProductId();
|
||||
// ShopProduct product = shopProductService.getById(productId);
|
||||
// product.setProductStock(product.getProductStock() + buyOrderDetailEntity.getQuantity());
|
||||
// shopProductService.updateById(product);
|
||||
// }
|
||||
// buyOrderService.removeById(orderId);
|
||||
// }
|
||||
// return R.ok();
|
||||
// }
|
||||
@RequestMapping("/cancelOrder")
|
||||
@Transactional
|
||||
public R appDelete(@RequestParam("orderSn") String orderSn) {
|
||||
QueryWrapper<BuyOrder> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("order_sn", orderSn);
|
||||
BuyOrder buyOrder = buyOrderService.getOne(queryWrapper);
|
||||
|
||||
if (buyOrder == null) {
|
||||
return R.error("订单不存在");
|
||||
}
|
||||
if (buyOrder.getCouponId() != null) {
|
||||
Integer couponId = buyOrder.getCouponId();
|
||||
CouponHistoryEntity couponHistory = couponHistoryService.getById(couponId);
|
||||
couponHistory.setUseStatus(0);
|
||||
couponHistoryService.updateById(couponHistory);
|
||||
}
|
||||
// 库存回滚
|
||||
List<BuyOrderProduct> buyOrderProductList = buyOrderProductService.getBaseMapper().selectList(new QueryWrapper<BuyOrderProduct>()
|
||||
.eq("order_id", buyOrder.getOrderId()));
|
||||
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
|
||||
Integer productId = buyOrderProduct.getProductId();
|
||||
ShopProduct product = shopProductService.getById(productId);
|
||||
product.setProductStock(product.getProductStock() + buyOrderProduct.getQuantity());
|
||||
shopProductService.updateById(product);
|
||||
}
|
||||
buyOrderService.removeById(buyOrder.getOrderId());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -475,6 +485,7 @@ public class BuyOrderController {
|
||||
*
|
||||
* @param orderId 订单 ID
|
||||
* @return R
|
||||
* TODO 新版本上线后 该方法删除
|
||||
*/
|
||||
@RequestMapping(value = "/getOrderInfo", method = RequestMethod.GET)
|
||||
public R appGetOrderInfo(@RequestParam("orderId") Integer orderId) {
|
||||
@@ -492,34 +503,98 @@ public class BuyOrderController {
|
||||
return R.ok().put("result", buyOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改订单地址
|
||||
*
|
||||
* @param addressRequestVo 地址请求 value object
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping(value = "/modifyOrderAddress", method = RequestMethod.POST)
|
||||
public R modifyOrderAddress(@RequestBody ShippingAddressRequestVo addressRequestVo) {
|
||||
BuyOrder buyOrder = buyOrderService.getById(addressRequestVo.getOrderId());
|
||||
buyOrder.setProvince(addressRequestVo.getProvince());
|
||||
buyOrder.setCity(addressRequestVo.getCity());
|
||||
buyOrder.setDistrict(addressRequestVo.getCounty());
|
||||
|
||||
String provinceCode = addressRequestVo.getProvinceCode();
|
||||
QueryWrapper<Province> provinceQueryWrapper = new QueryWrapper<>();
|
||||
provinceQueryWrapper.eq("region_code", provinceCode);
|
||||
Province province = provinceService.getOne(provinceQueryWrapper);
|
||||
buyOrder.setProvince(province.getProvName());
|
||||
String cityCode = addressRequestVo.getCityCode();
|
||||
QueryWrapper<City> cityQueryWrapper = new QueryWrapper<>();
|
||||
cityQueryWrapper.eq("region_code", cityCode);
|
||||
City city = cityService.getOne(cityQueryWrapper);
|
||||
buyOrder.setCity(city.getCityName());
|
||||
String countyCode = addressRequestVo.getCountyCode();
|
||||
QueryWrapper<County> countyQueryWrapper = new QueryWrapper<>();
|
||||
countyQueryWrapper.eq("region_code", countyCode);
|
||||
County county = countyService.getOne(countyQueryWrapper);
|
||||
buyOrder.setDistrict(county.getCountyName());
|
||||
buyOrder.setShippingUser(addressRequestVo.getName());
|
||||
buyOrder.setUserPhone(addressRequestVo.getMobile());
|
||||
buyOrder.setAddress(addressRequestVo.getAddress());
|
||||
buyOrderService.updateById(buyOrder);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单地址
|
||||
*
|
||||
* @param orderSn 订单号
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping(value = "/getOrderAddress", method = RequestMethod.GET)
|
||||
public R getOrderAddress(@RequestParam("orderSn") String orderSn) {
|
||||
QueryWrapper<BuyOrder> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("order_sn", orderSn);
|
||||
BuyOrder buyOrder = buyOrderService.getOne(queryWrapper);
|
||||
OrderAddressResponseVo responseVo = new OrderAddressResponseVo();
|
||||
responseVo.setConsigneeMobile(buyOrder.getUserPhone());
|
||||
responseVo.setConsigneeName(buyOrder.getShippingUser());
|
||||
responseVo.setDetailAddress(buyOrder.getAddress());
|
||||
String provinceName = buyOrder.getProvince();
|
||||
String cityName = buyOrder.getCity();
|
||||
String countyName = buyOrder.getDistrict();
|
||||
|
||||
QueryWrapper<Province> provinceQueryWrapper = new QueryWrapper<>();
|
||||
provinceQueryWrapper.eq("prov_name", provinceName);
|
||||
Province province = provinceService.getOne(provinceQueryWrapper);
|
||||
responseVo.setProvinceCode(province.getRegionCode());
|
||||
|
||||
QueryWrapper<City> cityQueryWrapper = new QueryWrapper<>();
|
||||
cityQueryWrapper.eq("city_name", cityName);
|
||||
City city = cityService.getOne(cityQueryWrapper);
|
||||
responseVo.setCityCode(city.getRegionCode());
|
||||
|
||||
QueryWrapper<County> countyQueryWrapper = new QueryWrapper<>();
|
||||
countyQueryWrapper.eq("county_name", countyName);
|
||||
County county = countyService.getOne(countyQueryWrapper);
|
||||
responseVo.setCountyCode(county.getRegionCode());
|
||||
|
||||
return R.ok().put("result", responseVo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询订单快递
|
||||
*
|
||||
* @param orderId 订单号
|
||||
* @param orderSn 订单号
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping(value = "/queryExpress", method = RequestMethod.GET)
|
||||
public R queryExpress(@RequestParam("orderId") Integer orderId) {
|
||||
QueryWrapper<BuyOrderDetail> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("order_id", orderId);
|
||||
List<BuyOrderDetail> buyOrderDetailList = buyOrderDetailService.list(queryWrapper);
|
||||
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.getOrderId();
|
||||
|
||||
QueryWrapper<BuyOrderProduct> buyOrderProductQueryWrapper = new QueryWrapper<>();
|
||||
buyOrderProductQueryWrapper.eq("order_id", orderId);
|
||||
List<BuyOrderProduct> buyOrderProductList = buyOrderProductService.list(buyOrderProductQueryWrapper);
|
||||
List<ExpressQueryResponseVo> result = new ArrayList<>();
|
||||
for (BuyOrderDetail buyOrderDetail : buyOrderDetailList) {
|
||||
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
|
||||
int expressOrderId = buyOrderProduct.getExpressOrderId();
|
||||
ExpressOrder expressOrder = expressOrderService.getById(expressOrderId);
|
||||
ExpressQueryResponseVo vo = new ExpressQueryResponseVo();
|
||||
vo.setOrderDetailId(buyOrderDetail.getId());
|
||||
ExpressQueryResponse expressQueryResponse = expressOrderService.queryExpressOrder(buyOrderDetail.getExpressCompanyCode(), buyOrderDetail.getExpressBillNo());
|
||||
ExpressQueryResponse expressQueryResponse = expressOrderService.queryExpressOrder(expressOrder.getExpressCompanyCode(), expressOrder.getExpressOrderSn());
|
||||
vo.setLogisticCode(expressQueryResponse.getLogisticCode());
|
||||
vo.setTraces(expressQueryResponse.getTraces());
|
||||
result.add(vo);
|
||||
|
||||
Reference in New Issue
Block a user