bug fix:county name is not unique value
This commit is contained in:
@@ -227,6 +227,7 @@ public class BuyOrderController {
|
||||
* @throws IOException
|
||||
*/
|
||||
@RequestMapping(value = "/placeOrder", method = RequestMethod.POST)
|
||||
@Transactional
|
||||
public R placeOrder(@RequestBody BuyOrder buyOrder) throws IOException {
|
||||
List<BuyOrderProduct> buyOrderProductList = buyOrder.getProductList();
|
||||
// 订单总金额
|
||||
@@ -241,13 +242,6 @@ public class BuyOrderController {
|
||||
return R.error(500, "库存不足");
|
||||
}
|
||||
totalPrice = totalPrice.add(price.multiply(BigDecimal.valueOf(quantity)));
|
||||
int originWeight = product.getWeight();
|
||||
int originWeightIntValue = originWeight / 100;
|
||||
int originWeightDecimalValue = originWeightIntValue % 100;
|
||||
//buyOrderProduct.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);
|
||||
}
|
||||
|
||||
totalPrice = totalPrice.subtract(useCouponAmount(buyOrder));
|
||||
@@ -268,12 +262,10 @@ public class BuyOrderController {
|
||||
|
||||
for (BuyOrderProduct buyOrderDetail : buyOrderProductList) {
|
||||
buyOrderDetail.setOrderId(buyOrder.getId());
|
||||
//buyOrderDetail.setUserId(buyOrder.getUserId());
|
||||
if (Constants.BUY_TYPE_CART.equals(buyOrder.getBuyType())) {
|
||||
handleBuyCart(buyOrder, buyOrderDetail);
|
||||
}
|
||||
}
|
||||
// buyOrderDetailService.saveBatch(buyOrderDetails);
|
||||
buyOrderProductService.saveBatch(buyOrderProductList);
|
||||
// 1. 虚拟币支付
|
||||
if (Constants.PAYMENT_METHOD_VIRTUAL.equals(buyOrder.getPaymentMethod())) {
|
||||
@@ -364,7 +356,7 @@ public class BuyOrderController {
|
||||
}
|
||||
// 库存回滚
|
||||
QueryWrapper<BuyOrderProduct> buyOrderProductQueryWrapper = new QueryWrapper<>();
|
||||
buyOrderProductQueryWrapper.eq("order_id",buyOrder.getId());
|
||||
buyOrderProductQueryWrapper.eq("order_id", buyOrder.getId());
|
||||
List<BuyOrderProduct> buyOrderProductList = buyOrderProductService.list(buyOrderProductQueryWrapper);
|
||||
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
|
||||
Integer productId = buyOrderProduct.getProductId();
|
||||
|
||||
@@ -67,8 +67,10 @@ public class ExpressController {
|
||||
List<PrintTemplateVo> data = new ArrayList<>();
|
||||
for (ExpressOrder expressOrder : expressOrderList) {
|
||||
PrintTemplateVo vo = new PrintTemplateVo();
|
||||
vo.setExpressCompanyCode(expressOrder.getExpressCompanyCode());
|
||||
vo.setPrintTemplate(expressOrder.getPrintTemplate());
|
||||
vo.setExpressOrderSn(expressOrder.getExpressOrderSn());
|
||||
vo.setTemplatedPrinted(vo.getTemplatedPrinted());
|
||||
data.add(vo);
|
||||
}
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
@@ -32,7 +32,7 @@ public class BuyOrderProduct {
|
||||
/**
|
||||
* 商品价格
|
||||
*/
|
||||
private BigDecimal realPrice;
|
||||
// private BigDecimal realPrice;
|
||||
/**
|
||||
* 快递订单 ID
|
||||
*/
|
||||
|
||||
@@ -54,6 +54,12 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
@Autowired
|
||||
private BuyOrderProductService buyOrderProductService;
|
||||
|
||||
@Autowired
|
||||
private ProvinceService provinceService;
|
||||
|
||||
@Autowired
|
||||
private CityService cityService;
|
||||
|
||||
|
||||
protected Logger logger = LoggerFactory.getLogger(BuyOrderServiceImpl.class);
|
||||
|
||||
@@ -423,6 +429,29 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
consigneeVo.setCity(buyOrder.getCity());
|
||||
consigneeVo.setCounty(buyOrder.getDistrict());
|
||||
consigneeVo.setAddress(buyOrder.getAddress());
|
||||
QueryWrapper<Province> provinceQueryWrapper = new QueryWrapper<>();
|
||||
provinceQueryWrapper.eq("prov_name", buyOrder.getProvince());
|
||||
Province province = provinceService.getOne(provinceQueryWrapper);
|
||||
if (province != null) {
|
||||
consigneeVo.setProvinceCode(province.getRegionCode());
|
||||
}
|
||||
QueryWrapper<City> cityQueryWrapper = new QueryWrapper<>();
|
||||
cityQueryWrapper.eq("city_name", buyOrder.getCity());
|
||||
City city = cityService.getOne(cityQueryWrapper);
|
||||
Long cityId = null;
|
||||
if (city != null) {
|
||||
consigneeVo.setCityCode(city.getRegionCode());
|
||||
cityId = city.getCityId();
|
||||
}
|
||||
QueryWrapper<County> countyQueryWrapper = new QueryWrapper<>();
|
||||
countyQueryWrapper.eq("county_name", buyOrder.getDistrict());
|
||||
if (countyService.count(countyQueryWrapper) > 1) {
|
||||
countyQueryWrapper.eq("city_id", cityId);
|
||||
}
|
||||
County county = countyService.getOne(countyQueryWrapper);
|
||||
if (county != null) {
|
||||
consigneeVo.setCountyCode(county.getRegionCode());
|
||||
}
|
||||
responseVo.setConsignee(consigneeVo);
|
||||
QueryWrapper<BuyOrderProduct> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("order_id", buyOrder.getId());
|
||||
|
||||
@@ -33,5 +33,17 @@ public class ConsigneeVo {
|
||||
* 详细地址
|
||||
*/
|
||||
private String address;
|
||||
/**
|
||||
* 省份代码
|
||||
*/
|
||||
private String provinceCode;
|
||||
/**
|
||||
* 城市代码
|
||||
*/
|
||||
private String cityCode;
|
||||
/**
|
||||
* 区县代码
|
||||
*/
|
||||
private String countyCode;
|
||||
|
||||
}
|
||||
|
||||
@@ -17,4 +17,12 @@ public class PrintTemplateVo {
|
||||
* 面单
|
||||
*/
|
||||
private String printTemplate;
|
||||
/**
|
||||
* 快递公司代码
|
||||
*/
|
||||
private String expressCompanyCode;
|
||||
/**
|
||||
* 是否打印过
|
||||
*/
|
||||
private int templatedPrinted;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user