Merge branch 'develop/express'

# Conflicts:
#	src/main/resources/application-dev.yml
This commit is contained in:
wangjinlei
2023-10-27 13:14:51 +08:00
49 changed files with 1405 additions and 792 deletions

View File

@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.BookClockEntryEntity;
@@ -69,6 +70,7 @@ public class BookClockForumController {
@RequestParam(value = "userId", required = false) Integer userId,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
@RequestParam(value = "currentPage", defaultValue = "1") Integer currentPage) {
Page<BookClockEntryChat> chatPage = new Page<>(currentPage, pageSize);
QueryWrapper<BookClockEntryChat> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("entry_id", entryId);
queryWrapper.eq("fid", 0);
@@ -77,7 +79,8 @@ public class BookClockForumController {
}
queryWrapper.orderByAsc("fid", "create_time");
List<ClockInCommentVo> resultList = new ArrayList<>();
List<BookClockEntryChat> chatEntityList = bookClockEntryChatService.list(queryWrapper);
Page<BookClockEntryChat> page = bookClockEntryChatService.page(chatPage, queryWrapper);
List<BookClockEntryChat> chatEntityList = page.getRecords();
for (BookClockEntryChat entity : chatEntityList) {
List<String> imageList = JSON.parseObject(entity.getImages(), new TypeReference<List<String>>() {
});
@@ -89,8 +92,7 @@ public class BookClockForumController {
vo.setAvatar(user.getAvatar());
resultList.add(vo);
}
PageUtils page = new PageUtils(resultList, resultList.size(), pageSize, currentPage);
return R.ok().put("result", page);
return R.ok().put("result", resultList);
}
/**
@@ -105,9 +107,11 @@ public class BookClockForumController {
public R getSubChatList(@RequestParam("fid") Integer fid,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
@RequestParam(value = "currentPage", defaultValue = "1") Integer currentPage) {
Page<BookClockEntryChat> bookClockEntryChatPage = new Page<>(currentPage, pageSize);
QueryWrapper<BookClockEntryChat> subQueryWrapper = new QueryWrapper<>();
subQueryWrapper.eq("fid", fid);
List<BookClockEntryChat> subClockInChatList = bookClockEntryChatService.list(subQueryWrapper);
Page<BookClockEntryChat> page = bookClockEntryChatService.page(bookClockEntryChatPage, subQueryWrapper);
List<BookClockEntryChat> subClockInChatList = page.getRecords();
List<ClockInCommentVo> subCommentList = new ArrayList<>();
for (BookClockEntryChat subChat : subClockInChatList) {
ClockInCommentVo subVo = new ClockInCommentVo();
@@ -120,8 +124,7 @@ public class BookClockForumController {
subVo.setNickName(subChatUser.getNickname());
subCommentList.add(subVo);
}
PageUtils subChatPage = new PageUtils(subCommentList, subCommentList.size(), pageSize, currentPage);
return R.ok().put("result", subChatPage);
return R.ok().put("result", subCommentList);
}
/**

View File

@@ -10,14 +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.to.UserOrderDto;
import com.peanut.modules.book.vo.UserAddressVo;
import com.peanut.modules.book.vo.request.BuyOrderListRequestVo;
import com.peanut.modules.book.vo.request.ModifyOrderAddressRequestVo;
import com.peanut.modules.book.vo.request.ProductRequestVo;
import com.peanut.modules.book.vo.request.ProductTransportVo;
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;
@@ -80,10 +81,18 @@ public class BuyOrderController {
private ExpressFeeService expressFeeService;
@Autowired
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) {
Map<Integer, List<String>> result = buyOrderService.decomposeShipment(userId);
@RequestMapping(value = "/decomposeShipment", method = RequestMethod.POST)
public R decomposeShipment(@RequestBody BuyOrderListRequestVo requestVo) {
Map<String, Object> result = buyOrderService.decomposeShipment(requestVo);
return R.ok().put("result", result);
}
@@ -103,8 +112,19 @@ public class BuyOrderController {
*/
@RequestMapping(path = "/orderList", method = RequestMethod.POST)
public R orderList(@RequestBody BuyOrderListRequestVo requestVo) {
PageUtils page = buyOrderService.orderList(requestVo);
return R.ok().put("result", page);
Map<String, Object> result = buyOrderService.orderList(requestVo);
return R.ok().put("result", result);
}
/**
* 获取用户订单列表
* @param userOrderDto
* @return
*/
@RequestMapping("/getUserOrderList")
public R getUserOrderList(@RequestBody UserOrderDto userOrderDto){
Page<BuyOrder> userOrderList = buyOrderService.getUserOrderList(userOrderDto);
return R.ok().put("page",userOrderList);
}
/**
@@ -121,6 +141,7 @@ public class BuyOrderController {
/**
* 下单
* TODO 原下单接口,新版本上线后废弃
*
* @param buyOrder 订单
* @return R
@@ -210,6 +231,93 @@ public class BuyOrderController {
return R.ok(result);
}
/**
* 下单
*
* @param buyOrder
* @return
* @throws IOException
*/
@RequestMapping(value = "/placeOrder", method = RequestMethod.POST)
@Transactional
public R placeOrder(@RequestBody BuyOrder buyOrder) throws IOException {
List<BuyOrderProduct> buyOrderProductList = buyOrder.getProductList();
// 订单总金额
BigDecimal totalPrice = new BigDecimal(0);
// 遍历商品总价计算
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
Integer productId = buyOrderProduct.getProductId();
int quantity = buyOrderProduct.getQuantity();
ShopProduct product = shopProductService.getById(productId);
BigDecimal price = getRealPrice(product);
if (!handleStock(buyOrderProduct, product)) {
return R.error(500, "库存不足");
}
totalPrice = totalPrice.add(price.multiply(BigDecimal.valueOf(quantity)));
}
totalPrice = totalPrice.subtract(useCouponAmount(buyOrder));
totalPrice = totalPrice.add(getShoppingAmount(buyOrder));
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.getCounty());
buyOrder.setAddress(userAddress.getDetailAddress());
buyOrderService.save(buyOrder);
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
buyOrderProduct.setOrderId(buyOrder.getOrderId());
if (Constants.BUY_TYPE_CART.equals(buyOrder.getBuyType())) {
handleBuyCart(buyOrder, buyOrderProduct);
}
}
buyOrderProductService.saveBatch(buyOrderProductList);
// 1. 虚拟币支付
if (Constants.PAYMENT_METHOD_VIRTUAL.equals(buyOrder.getPaymentMethod())) {
buyOrder.setOrderStatus(Constants.ORDER_STATUS_TO_BE_SHIPPED);
MyUserEntity user = this.myUserService.getById(buyOrder.getUserId());
if (usePeanutCoin(user, totalPrice)) {
// 更新订单状态
buyOrderService.updateOrderStatus(user.getId(), buyOrder.getOrderSn(), "0");
recordTransaction(buyOrder, user, totalPrice);
addEbookToUser(buyOrderProductList, buyOrder, 0);
} else {
return R.error(500, "花生币余额不足!");
}
}
// 2. 微信支付
if (Constants.PAYMENT_METHOD_WECHAT_PAY.equals(buyOrder.getPaymentMethod())) {
rabbitTemplate.convertAndSend(
DelayQueueConfig.ORDER_TO_BE_PAY_EXCHANGE,
DelayQueueConfig.ORDER_TO_BE_PAY_ROUTING_KEY,
buyOrder.getOrderId(),
messagePostProcessor()
);
WechatPaymentInfo paymentInfo = new WechatPaymentInfo();
paymentInfo.setOrderSn(orderSn);
paymentInfo.setBuyOrderId(buyOrder.getOrderId());
paymentInfo.setTotalAmount(totalPrice);
wxpayService.prepay(paymentInfo);
}
Map<String, Object> result = new HashMap<>();
result.put("orderSn", buyOrder.getOrderSn());
result.put("money", totalPrice);
return R.ok(result);
}
/**
* 计算运费
*
* @param vo
* @return
*/
@RequestMapping(path = "/calculateTransportPrice", method = RequestMethod.POST)
public R getTransportPrice(@RequestBody ProductTransportVo vo) {
String regionCode = vo.getRegionCode();
@@ -217,14 +325,21 @@ public class BuyOrderController {
BigDecimal totalWeight = new BigDecimal(0);
for (ProductRequestVo product : products) {
ShopProduct shopProduct = shopProductService.getById(product.getProductId());
if(shopProduct.getIsFreeMail()==0){
continue;
}
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);
BigDecimal expressFee = new BigDecimal(0);
if(totalWeight.compareTo(BigDecimal.ZERO)!=0){
totalWeight = totalWeight.setScale(0, RoundingMode.UP);
QueryWrapper<SysConfigEntity> configQueryWrapper = new QueryWrapper<>();
configQueryWrapper.eq("param_key", "DEFAULT_EXPRESS");
SysConfigEntity config = sysConfigService.getOne(configQueryWrapper);
expressFee = expressFeeService.calculateExpressFee(config.getParamValue(), totalWeight, regionCode);
}
return R.ok().put("result", expressFee);
}
@@ -238,6 +353,40 @@ public class BuyOrderController {
}
/**
* @param orderSn 订单号
* @return R
*/
@RequestMapping(value = "/cancelOrder", method = RequestMethod.GET)
@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);
}
// 库存回滚
QueryWrapper<BuyOrderProduct> buyOrderProductQueryWrapper = new QueryWrapper<>();
buyOrderProductQueryWrapper.eq("order_id", buyOrder.getOrderId());
List<BuyOrderProduct> buyOrderProductList = buyOrderProductService.list(buyOrderProductQueryWrapper);
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();
}
/**
* 修改
*/
@@ -251,14 +400,17 @@ public class BuyOrderController {
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] orderIds) {
buyOrderService.removeByIds(Arrays.asList(orderIds));
public R delete(@RequestBody List<String> orderSnList) {
QueryWrapper<BuyOrder> queryWrapper = new QueryWrapper<>();
queryWrapper.in("order_sn", orderSnList);
buyOrderService.remove(queryWrapper);
return R.ok();
}
/**
* app 端 取消订单
* TODO 新版本上线后此方法删除
*/
@RequestMapping("/appDelete")
@Transactional
@@ -340,6 +492,7 @@ public class BuyOrderController {
*
* @param orderId 订单 ID
* @return R
* TODO 新版本上线后 该方法删除
*/
@RequestMapping(value = "/getOrderInfo", method = RequestMethod.GET)
public R appGetOrderInfo(@RequestParam("orderId") Integer orderId) {
@@ -357,39 +510,93 @@ public class BuyOrderController {
return R.ok().put("result", buyOrder);
}
@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());
buyOrder.setShippingUser(addressRequestVo.getName());
buyOrder.setUserPhone(addressRequestVo.getMobile());
/**
* 修改订单地址
*
* @param addressRequestVo 地址请求 value object
* @return R
*/
@RequestMapping(value = "/modifyConsigneeAddress", method = RequestMethod.POST)
public R modifyOrderAddress(@RequestBody ModifyOrderAddressRequestVo addressRequestVo) {
QueryWrapper<BuyOrder> buyOrderQueryWrapper = new QueryWrapper<>();
buyOrderQueryWrapper.eq("order_sn", addressRequestVo.getOrderSn());
BuyOrder buyOrder = buyOrderService.getOne(buyOrderQueryWrapper);
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.getConsigneeName());
buyOrder.setUserPhone(addressRequestVo.getConsigneeMobile());
buyOrder.setAddress(addressRequestVo.getAddress());
buyOrderService.updateById(buyOrder);
return R.ok();
}
/**
* 获取订单地址
*
* @param orderSn 订单号
* @return R
*/
@RequestMapping(value = "/getConsigneeAddress", 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 expressOrderSn 运单号
* @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);
List<ExpressQueryResponseVo> result = new ArrayList<>();
for (BuyOrderDetail buyOrderDetail : buyOrderDetailList) {
ExpressQueryResponseVo vo = new ExpressQueryResponseVo();
vo.setOrderDetailId(buyOrderDetail.getId());
ExpressQueryResponse expressQueryResponse = expressOrderService.queryExpressOrder(buyOrderDetail.getExpressCompanyCode(), buyOrderDetail.getExpressBillNo());
vo.setLogisticCode(expressQueryResponse.getLogisticCode());
vo.setTraces(expressQueryResponse.getTraces());
result.add(vo);
}
return R.ok().put("result", result);
public R queryExpress(@RequestParam("expressOrderSn") String expressOrderSn,
@RequestParam("expressCompanyCode") String expressCompanyCode,
@RequestParam("customerName") String customerName) {
ExpressQueryResponseVo vo = new ExpressQueryResponseVo();
ExpressQueryResponse expressQueryResponse = expressOrderService.queryExpressOrder(expressCompanyCode, expressOrderSn, customerName);
vo.setLogisticCode(expressQueryResponse.getLogisticCode());
vo.setTraces(expressQueryResponse.getTraces());
return R.ok().put("result", vo);
}
/**
@@ -419,13 +626,13 @@ public class BuyOrderController {
* 分包发货
*
* @param expressCompanyCode 快递公司编码
* @param buyOrderDetailId 订单详情列表
* @param buyOrderProductId 订单商品
* @return R
*/
@RequestMapping(value = "/delivery", method = RequestMethod.POST)
public R delivery(@RequestParam("expressCompanyCode") String expressCompanyCode,
@RequestBody List<Integer> buyOrderDetailId) throws Exception {
buyOrderService.delivery(expressCompanyCode, buyOrderDetailId);
@RequestBody List<Integer> buyOrderProductId) throws Exception {
buyOrderService.delivery(expressCompanyCode, buyOrderProductId);
return R.ok();
}
@@ -443,6 +650,7 @@ public class BuyOrderController {
/**
* 处理商品库存
* TODO 新版本上线后删除此方法
*
* @param buyOrderDetail
* @param product
@@ -459,6 +667,24 @@ public class BuyOrderController {
return true;
}
/**
* 处理商品库存
*
* @param buyOrderProduct 订单商品信息
* @param product 商品
* @return boolean
*/
private boolean handleStock(BuyOrderProduct buyOrderProduct, ShopProduct product) {
int quantity = buyOrderProduct.getQuantity();
if (product.getProductStock() - quantity < 0) {
return false;
}
product.setProductStock(product.getProductStock() - quantity);
product.setSumSales(product.getSumSales() + quantity);
shopProductService.updateById(product);
return true;
}
/**
* 使用优惠券
*
@@ -480,21 +706,6 @@ public class BuyOrderController {
return BigDecimal.ZERO;
}
@RequestMapping("/modifyConsigneeAddress")
public R modifyConsigneeAddress(@RequestBody ModifyOrderAddressRequestVo requestVo) {
QueryWrapper<BuyOrder> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("order_sn", requestVo.getOrderSn());
BuyOrder buyOrder = buyOrderService.getOne(queryWrapper);
buyOrder.setShippingUser(requestVo.getConsigneeName());
buyOrder.setUserPhone(requestVo.getConsigneeMobile());
buyOrder.setProvince(requestVo.getProvince());
buyOrder.setCity(requestVo.getCity());
buyOrder.setDistrict(requestVo.getCounty());
buyOrder.setAddress(requestVo.getAddress());
buyOrder.setAddressModified(1);
buyOrderService.updateById(buyOrder);
return R.ok();
}
/**
* 计算运费
@@ -543,8 +754,9 @@ public class BuyOrderController {
/**
* 给用户添加电子书
* TODO 新版本上线删除此接口
* @param products
*
* @param products
* @param buyOrder
*/
private void addEbookToUser(List<BuyOrderDetail> products, BuyOrder buyOrder) {
@@ -557,8 +769,26 @@ public class BuyOrderController {
}
}
/**
* 给用户添加电子书
* TODO 这里的参数 0 没用 新版本上线后删除
*
* @param products
* @param buyOrder
*/
private void addEbookToUser(List<BuyOrderProduct> products, BuyOrder buyOrder, Integer x) {
List<Integer> productIds = products.stream().map(BuyOrderProduct::getProductId).collect(Collectors.toList());
for (Integer productId : productIds) {
List<Integer> collect = shopProductBookService.getBaseMapper().selectList(new LambdaQueryWrapper<ShopProductBookEntity>()
.eq(ShopProductBookEntity::getProductId, productId)
.eq(ShopProductBookEntity::getDelFlag, 0)).stream().map(ShopProductBookEntity::getBookId).collect(Collectors.toList());
userEbookBuyService.addBookForUser(buyOrder.getUserId(), collect);
}
}
/**
* 购物车
* TODO 新版本上线后删除此方法
*
* @param buyOrder
* @param buyOrderDetail
@@ -572,6 +802,21 @@ public class BuyOrderController {
}
}
/**
* 购物车
*
* @param buyOrder 订单
* @param buyOrderProduct
*/
private void handleBuyCart(BuyOrder buyOrder, BuyOrderProduct buyOrderProduct) {
List<OrderCartEntity> orderCartList = orderCartService.getBaseMapper().selectList(new QueryWrapper<OrderCartEntity>()
.eq("user_id", buyOrder.getUserId()).eq("product_id", buyOrderProduct.getProductId()));
if (orderCartList.size() > 0) {
List<Integer> collect = orderCartList.stream().map(OrderCartEntity::getCartId).collect(Collectors.toList());
orderCartService.removeByIds(collect);
}
}
private MessagePostProcessor messagePostProcessor() {
return message -> {
//设置有效期30分钟

View File

@@ -1,113 +1,113 @@
package com.peanut.modules.book.controller;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.BuyOrderDetail;
import com.peanut.modules.book.service.BuyOrderDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.Map;
/**
* 商品订单详情表
*
* @author yl
* @email yl328572838@163.com
* @date 2022-08-29 15:27:44
*/
@RestController
@RequestMapping("book/buyorderdetail")
public class BuyOrderDetailController {
@Autowired
private BuyOrderDetailService buyOrderDetailService;
/**
* 列表
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params) {
PageUtils page = buyOrderDetailService.queryPage(params);
return R.ok().put("page", page);
}
/**
* 查询已购买书籍
*
* @param params
* @return
*/
@RequestMapping("/querybuy")
public R querybuy(@RequestParam Map<String, Object> params) {
PageUtils page = buyOrderDetailService.querybuy(params);
return R.ok().put("page", page);
}
/**
* 去重查询可打印面单
*
* @param params
* @return
*/
@RequestMapping("/querySheetPage")
public R querySheetPage(@RequestParam Map<String, Object> params) {
PageUtils page = buyOrderDetailService.querySheet(params);
return R.ok().put("page", page);
}
/**
* 信息
*/
@RequestMapping("/info/{allOrderId}")
public R info(@PathVariable("allOrderId") Long allOrderId) {
BuyOrderDetail buyOrderDetail = buyOrderDetailService.getById(allOrderId);
return R.ok().put("buyOrderDetail", buyOrderDetail);
}
/**
* 保存
*/
@RequestMapping("/save")
public R save(@RequestBody BuyOrderDetail buyOrderDetail) {
buyOrderDetailService.save(buyOrderDetail);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody BuyOrderDetail buyOrderDetail) {
buyOrderDetailService.updateById(buyOrderDetail);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] allOrderIds) {
buyOrderDetailService.removeByIds(Arrays.asList(allOrderIds));
return R.ok();
}
@RequestMapping("/updateOrderStatus")
public R updateOrderStatus(@RequestBody BuyOrderDetail buyOrderDetail) {
buyOrderDetail.setOrderStatus("2");
buyOrderDetailService.updateById(buyOrderDetail);
return R.ok();
}
/**
* 根据运单号批量修改打印状态
*
* @param shippingSnList
* @return
*/
@RequestMapping("/batchUpdateByShippingSns")
public R batchUpdateByShippingSns(@RequestBody String[] shippingSnList) {
return R.ok();
}
}
//package com.peanut.modules.book.controller;
//
//import com.peanut.common.utils.PageUtils;
//import com.peanut.common.utils.R;
//import com.peanut.modules.book.entity.BuyOrderDetail;
//import com.peanut.modules.book.service.BuyOrderDetailService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.Arrays;
//import java.util.Map;
//
///**
// * 商品订单详情表
// *
// * @author yl
// * @email yl328572838@163.com
// * @date 2022-08-29 15:27:44
// */
//@RestController
//@RequestMapping("book/buyorderdetail")
//public class BuyOrderDetailController {
// @Autowired
// private BuyOrderDetailService buyOrderDetailService;
//
// /**
// * 列表
// */
// @RequestMapping("/list")
// public R list(@RequestParam Map<String, Object> params) {
// PageUtils page = buyOrderDetailService.queryPage(params);
// return R.ok().put("page", page);
// }
//
// /**
// * 查询已购买书籍
// *
// * @param params
// * @return
// */
// @RequestMapping("/querybuy")
// public R querybuy(@RequestParam Map<String, Object> params) {
// PageUtils page = buyOrderDetailService.querybuy(params);
// return R.ok().put("page", page);
// }
//
// /**
// * 去重查询可打印面单
// *
// * @param params
// * @return
// */
// @RequestMapping("/querySheetPage")
// public R querySheetPage(@RequestParam Map<String, Object> params) {
// PageUtils page = buyOrderDetailService.querySheet(params);
// return R.ok().put("page", page);
// }
//
// /**
// * 信息
// */
// @RequestMapping("/info/{allOrderId}")
// public R info(@PathVariable("allOrderId") Long allOrderId) {
// BuyOrderDetail buyOrderDetail = buyOrderDetailService.getById(allOrderId);
// return R.ok().put("buyOrderDetail", buyOrderDetail);
// }
//
// /**
// * 保存
// */
// @RequestMapping("/save")
// public R save(@RequestBody BuyOrderDetail buyOrderDetail) {
// buyOrderDetailService.save(buyOrderDetail);
// return R.ok();
// }
//
// /**
// * 修改
// */
// @RequestMapping("/update")
// public R update(@RequestBody BuyOrderDetail buyOrderDetail) {
// buyOrderDetailService.updateById(buyOrderDetail);
// return R.ok();
// }
//
// /**
// * 删除
// */
// @RequestMapping("/delete")
// public R delete(@RequestBody Long[] allOrderIds) {
// buyOrderDetailService.removeByIds(Arrays.asList(allOrderIds));
// return R.ok();
// }
//
// @RequestMapping("/updateOrderStatus")
// public R updateOrderStatus(@RequestBody BuyOrderDetail buyOrderDetail) {
// buyOrderDetail.setOrderStatus("2");
// buyOrderDetailService.updateById(buyOrderDetail);
// return R.ok();
// }
//
//
// /**
// * 根据运单号批量修改打印状态
// *
// * @param shippingSnList
// * @return
// */
// @RequestMapping("/batchUpdateByShippingSns")
// public R batchUpdateByShippingSns(@RequestBody String[] shippingSnList) {
// return R.ok();
// }
//}

View File

@@ -2,23 +2,22 @@ package com.peanut.modules.book.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.BuyOrder;
import com.peanut.modules.book.entity.BuyOrderProduct;
import com.peanut.modules.book.entity.ExpressCompany;
import com.peanut.modules.book.entity.ExpressOrder;
import com.peanut.modules.book.service.BuyOrderProductService;
import com.peanut.modules.book.service.BuyOrderService;
import com.peanut.modules.book.service.ExpressCompanyService;
import com.peanut.modules.book.service.ExpressOrderService;
import com.peanut.modules.book.vo.ExpressCompanyVo;
import com.peanut.modules.book.vo.response.PrintTemplateVo;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Description: 快递 Controller
@@ -32,10 +31,6 @@ public class ExpressController {
@Autowired
private ExpressCompanyService expressCompanyService;
@Autowired
private BuyOrderService buyOrderService;
@Autowired
private BuyOrderProductService buyOrderProductService;
@Autowired
private ExpressOrderService expressOrderService;
@@ -53,36 +48,44 @@ public class ExpressController {
/**
* 获取快递面单列表
*
* @return
* @return R
*/
@RequestMapping(path = "/getPrintTemplateList", method = RequestMethod.GET)
public R getPrintTemplate(String orderSn) {
QueryWrapper<BuyOrder> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("order_sn", orderSn);
BuyOrder buyOrder = buyOrderService.getOne(queryWrapper);
QueryWrapper<BuyOrderProduct> buyOrderProductQueryWrapper = new QueryWrapper<>();
buyOrderProductQueryWrapper.eq("order_id", buyOrder.getOrderId());
List<BuyOrderProduct> buyOrderProductList = buyOrderProductService.list(buyOrderProductQueryWrapper);
List<Integer> expressOrderIdList = new ArrayList<>();
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
expressOrderIdList.add(buyOrderProduct.getExpressOrderId());
}
public R getPrintTemplate(@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
@RequestParam(value = "currentPage", defaultValue = "1") Integer currentPage) {
Page<ExpressOrder> expressOrderPage = new Page<>(currentPage, pageSize);
QueryWrapper<ExpressOrder> expressOrderQueryWrapper = new QueryWrapper<>();
expressOrderQueryWrapper.in("id", expressOrderIdList);
expressOrderQueryWrapper.select("print_template");
List<ExpressOrder> expressOrderList = expressOrderService.list(expressOrderQueryWrapper);
List<String> result = new ArrayList<>();
int totalDataSize = expressOrderService.count(expressOrderQueryWrapper);
int totalPage = totalDataSize / pageSize + 1;
Page<ExpressOrder> page = expressOrderService.page(expressOrderPage, expressOrderQueryWrapper);
List<ExpressOrder> expressOrderList = page.getRecords();
List<PrintTemplateVo> data = new ArrayList<>();
for (ExpressOrder expressOrder : expressOrderList) {
result.add(expressOrder.getPrintTemplate());
PrintTemplateVo vo = new PrintTemplateVo();
QueryWrapper<ExpressCompany> expressCompanyQueryWrapper = new QueryWrapper<>();
expressCompanyQueryWrapper.eq("code", expressOrder.getExpressCompanyCode());
ExpressCompany expressCompany = expressCompanyService.getOne(expressCompanyQueryWrapper);
vo.setExpressCompanyCode(expressCompany.getName());
vo.setPrintTemplate(expressOrder.getPrintTemplate());
vo.setExpressOrderSn(expressOrder.getExpressOrderSn());
vo.setTemplatedPrinted(vo.getTemplatedPrinted());
data.add(vo);
}
Map<String, Object> result = new HashMap<>();
result.put("data", data);
result.put("currentPage", currentPage);
result.put("pageSize", pageSize);
result.put("totalDataSize", totalDataSize);
result.put("totalPage", totalPage);
return R.ok().put("result", result);
}
@RequestMapping(value = "/printTemplate", method = RequestMethod.GET)
public R printTemplate(@RequestParam("expressOrderId") Integer expressOrderId) {
@RequestMapping(value = "/printTemplate", method = RequestMethod.POST)
public R printTemplate(@RequestBody List<Integer> expressOrderIdList) {
UpdateWrapper<ExpressOrder> updateWrapper = new UpdateWrapper<>();
updateWrapper.set("template_printed", 1);
updateWrapper.eq("id", expressOrderId);
updateWrapper.in("id", expressOrderIdList);
expressOrderService.update(updateWrapper);
return R.ok();
}

View File

@@ -37,8 +37,6 @@ public class ProvinceController {
//获取地址
@RequestMapping("/getProvince")
public R getProvince() {
//优化查询速度 目录放入redis中
String s = redisTemplate.opsForValue().get("Province");
List<Map<String, Object>> listData = new ArrayList<>();

View File

@@ -32,13 +32,15 @@ public class ShopProductController {
@Autowired
private ShopCategoryService shopCategoryService;
@Autowired
private BuyOrderDetailService buyOrderDetailService;
private BuyOrderProductService buyOrderProductService;
@Autowired
private BookService bookService;
@Autowired
private ShopProductBookService shopProductBookService;
@Autowired
private ShopProductToLabelService shopProductToLabelService;
@Autowired
private BuyOrderDetailService buyOrderDetailService;
/**
* 精选商品 列表
@@ -87,7 +89,6 @@ public class ShopProductController {
return R.ok().put("page", page);
}
/**
* 未购买书列表
*
@@ -95,7 +96,7 @@ public class ShopProductController {
* @return
*/
@RequestMapping("/booklist")
public R bookList(@RequestParam("userId") Integer userId
public R booklist(@RequestParam("userId") Integer userId
) {
//查询已购买的书籍
List<BuyOrderDetail> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetail>()
@@ -131,6 +132,47 @@ public class ShopProductController {
}
/**
* 未购买书列表
*
* @param userId 用户id
* @return
*/
@RequestMapping("/bookList")
public R bookList(@RequestParam("userId") Integer userId
) {
//查询已购买的书籍
List<BuyOrderProduct> buyOrderProductList = buyOrderProductService.getBaseMapper().selectList(new QueryWrapper<BuyOrderProduct>()
.eq("user_id", userId));
//hashset不重复 且无序
Set<String> purchasedProductIds = new HashSet<>();
ArrayList<Object> list = new ArrayList<>();
Map<String, Object> map = new HashMap<>();
for (BuyOrderProduct buyOrderDetail : buyOrderProductList) {
map.put("ProductId", String.valueOf(buyOrderDetail.getProductId()));
list.add(map);
//去重取出以后买书籍的id
purchasedProductIds.add(String.valueOf(buyOrderDetail.getProductId()));
}
//查询商品表并过滤已购买商品id,根据时间倒叙展示
List<ShopProduct> allProductEntities = shopProductService.getBaseMapper().selectList(new QueryWrapper<ShopProduct>()
.notIn("product_id", purchasedProductIds)
.orderByDesc("create_time")
// .notLike("book_ids",",")
.isNotNull("book_ids")
);
List lists = new ArrayList<>();
for (ShopProduct product : allProductEntities) {
Map<String, Object> productMap = new HashMap<>();
productMap.put("product", product);
lists.add(productMap);
}
return R.ok().put("pages", lists); // 返回未购买的书籍分页
}
@RequestMapping("/bookinfo/{productId}")
public R bookInfo(@PathVariable("productId") Integer productId) {
ArrayList<Map<String, String>> imagesUrl = new ArrayList<Map<String, String>>();

View File

@@ -1,91 +1,91 @@
package com.peanut.modules.book.controller;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.ShopSeckillEntity;
import com.peanut.modules.book.service.ShopSeckillService;
import com.peanut.modules.book.to.SeckillRedisTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 秒杀库存表
*
* @author yl
* @email yl328572838@163.com
* @date 2022-10-28 11:24:05
*/
@RestController
@RequestMapping("book/shopseckill")
public class ShopSeckillController {
@Autowired
private ShopSeckillService shopSeckillService;
/**
* 列表
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params) {
PageUtils page = shopSeckillService.queryPage(params);
return R.ok().put("page", page);
}
/**
* 信息
*/
@RequestMapping("/info/{seckillId}")
public R info(@PathVariable("seckillId") Long seckillId) {
ShopSeckillEntity shopSeckill = shopSeckillService.getById(seckillId);
return R.ok().put("shopSeckill", shopSeckill);
}
/**
* 保存
*/
@RequestMapping("/save")
public R save(@RequestBody ShopSeckillEntity shopSeckill) {
shopSeckillService.save(shopSeckill);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody ShopSeckillEntity shopSeckill) {
shopSeckillService.updateById(shopSeckill);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] seckillIds) {
shopSeckillService.removeByIds(Arrays.asList(seckillIds));
return R.ok();
}
@GetMapping("/getSeckillProd")
public R getSeckillProd() {
List<SeckillRedisTo> list = shopSeckillService.getCurrentSeckillProd();
return R.ok().put("list", list);
}
@GetMapping("/kill")
public R kill(@RequestParam("killId") String killId,
@RequestParam("key") String key,
@RequestParam("num") Integer num,
@RequestParam("userId") Integer userId) {
String orderId = shopSeckillService.kill(killId, key, num, userId);
return R.ok().put("orderId", orderId);
}
}
//package com.peanut.modules.book.controller;
//
//import com.peanut.common.utils.PageUtils;
//import com.peanut.common.utils.R;
//import com.peanut.modules.book.entity.ShopSeckillEntity;
//import com.peanut.modules.book.service.ShopSeckillService;
//import com.peanut.modules.book.to.SeckillRedisTo;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.Arrays;
//import java.util.List;
//import java.util.Map;
//
//
///**
// * 秒杀库存表
// *
// * @author yl
// * @email yl328572838@163.com
// * @date 2022-10-28 11:24:05
// */
//@RestController
//@RequestMapping("book/shopseckill")
//public class ShopSeckillController {
// @Autowired
// private ShopSeckillService shopSeckillService;
//
// /**
// * 列表
// */
// @RequestMapping("/list")
// public R list(@RequestParam Map<String, Object> params) {
// PageUtils page = shopSeckillService.queryPage(params);
// return R.ok().put("page", page);
// }
//
//
// /**
// * 信息
// */
// @RequestMapping("/info/{seckillId}")
// public R info(@PathVariable("seckillId") Long seckillId) {
// ShopSeckillEntity shopSeckill = shopSeckillService.getById(seckillId);
// return R.ok().put("shopSeckill", shopSeckill);
// }
//
// /**
// * 保存
// */
// @RequestMapping("/save")
// public R save(@RequestBody ShopSeckillEntity shopSeckill) {
// shopSeckillService.save(shopSeckill);
// return R.ok();
// }
//
// /**
// * 修改
// */
// @RequestMapping("/update")
// public R update(@RequestBody ShopSeckillEntity shopSeckill) {
// shopSeckillService.updateById(shopSeckill);
// return R.ok();
// }
//
// /**
// * 删除
// */
// @RequestMapping("/delete")
// public R delete(@RequestBody Long[] seckillIds) {
// shopSeckillService.removeByIds(Arrays.asList(seckillIds));
// return R.ok();
// }
//
// @GetMapping("/getSeckillProd")
// public R getSeckillProd() {
// List<SeckillRedisTo> list = shopSeckillService.getCurrentSeckillProd();
// return R.ok().put("list", list);
// }
//
// @GetMapping("/kill")
// public R kill(@RequestParam("killId") String killId,
// @RequestParam("key") String key,
// @RequestParam("num") Integer num,
// @RequestParam("userId") Integer userId) {
// String orderId = shopSeckillService.kill(killId, key, num, userId);
// return R.ok().put("orderId", orderId);
// }
//
//
//}

View File

@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.MyUserEntity;
import com.peanut.modules.book.entity.UserFeedbackEntity;
import com.peanut.modules.book.entity.UserRecordEntity;
import com.peanut.modules.book.service.MyUserService;
import com.peanut.modules.book.service.UserFeedbackSerivce;
import org.springframework.beans.factory.annotation.Autowired;

View File

@@ -3,15 +3,19 @@ package com.peanut.modules.book.controller;
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.*;
import com.peanut.modules.book.service.*;
import com.peanut.modules.book.entity.BuyOrder;
import com.peanut.modules.book.entity.MyUserEntity;
import com.peanut.modules.book.entity.UserFollowUpEntity;
import com.peanut.modules.book.entity.UserRecord;
import com.peanut.modules.book.service.BuyOrderService;
import com.peanut.modules.book.service.MyUserService;
import com.peanut.modules.book.service.UserFollowUpService;
import com.peanut.modules.book.service.UserRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;
import static com.peanut.common.utils.R.error;
@RestController
@RequestMapping("/user/followUp")
public class UserFollowUpController {
@@ -25,41 +29,34 @@ public class UserFollowUpController {
private MyUserService myUserService;
@Autowired
private BuyOrderService buyOrderService;
@Autowired
private BuyOrderDetailService buyOrderDetailService;
/**
* 列表
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params ){
public R list(@RequestParam Map<String, Object> params) {
PageUtils page = userFollowUpService.queryPage(params);
return R.ok().put("page", page);
}
/**
* 我的评价
* 我的评价
*/
@RequestMapping("/Allevaluations")
public R Allevaluations(@RequestBody UserFollowUpEntity userFollowUpEntity){
public R Allevaluations(@RequestBody UserFollowUpEntity userFollowUpEntity) {
List<UserFollowUpEntity> userid = userFollowUpService.getBaseMapper().selectList(new QueryWrapper<UserFollowUpEntity>().eq("userid", userFollowUpEntity.getUserId()));
return R.ok().put("Allevaluations",userid);
return R.ok().put("Allevaluations", userid);
}
/**
* 全部评价
* 全部评价
*/
@RequestMapping("/Alllevas")
public R Alllevas(@RequestBody UserFollowUpEntity users){
public R Alllevas(@RequestBody UserFollowUpEntity users) {
HashMap<Object, Object> maps = new HashMap<>();
List list = new ArrayList<>();
List<UserFollowUpEntity> bookid = userFollowUpService.getBaseMapper().selectList(new QueryWrapper<UserFollowUpEntity>().eq("bookid", users.getBookid()));
@@ -68,67 +65,62 @@ public class UserFollowUpController {
Integer bookid1 = userRecord.getBookid();
Integer userid1 = userRecord.getUserId();
List<MyUserEntity> id = myUserService.getBaseMapper().selectList(new QueryWrapper<MyUserEntity>().eq("id", userid1));
String usser="";
String usser = "";
String name = "";
for (MyUserEntity user : id) {
usser = user.getAvatar();
name =user.getNickname();
usser = user.getAvatar();
name = user.getNickname();
}
map.put("Avatar",usser);
map.put("name",name);
map.put("Avatar", usser);
map.put("name", name);
map.put("userId", users.getUserId());
map.put("bookid",bookid1);
map.put("userid",userid1);
map.put("content",users.getConTent());
map.put("create_date",users.getCreateDate());
map.put("oid",users.getOid());
map.put("praIse",users.getPraIse());
map.put("bookid", bookid1);
map.put("userid", userid1);
map.put("content", users.getConTent());
map.put("create_date", users.getCreateDate());
map.put("oid", users.getOid());
map.put("praIse", users.getPraIse());
list.add(map);
}
maps.put("list",list);
maps.put("list", list);
return R.ok().put("list",list);
return R.ok().put("list", list);
}
/*
* 追加评论(用户只可评论一次)
*
* */
@RequestMapping("/userFollowUp")
public Object UserFollowUp(@RequestBody UserFollowUpEntity userFollowUpEntity ) {
public Object UserFollowUp(@RequestBody UserFollowUpEntity userFollowUpEntity) {
//根据传过来的userid和oid查询出来userRecordEntity中关联数据
UserRecordEntity userRecord = userRecordService.getBaseMapper().selectOne(new QueryWrapper<UserRecordEntity>()
UserRecord userRecord = userRecordService.getBaseMapper().selectOne(new QueryWrapper<UserRecord>()
.eq("userid", userFollowUpEntity.getUserId()).last("LIMIT 1")
.eq("bookid", userFollowUpEntity.getBookid())
.eq("id",userFollowUpEntity.getOid())
.eq("id", userFollowUpEntity.getOid())
);
if (userRecord==null){
return R.error("请先评论再追评");
}
if (userRecord == null) {
return R.error("请先评论再追评");
}
String orderSn = userRecord.getOrderSn();
BuyOrder buyOrder =buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>()
.eq("order_sn",orderSn).last("LIMIT 1")
BuyOrder buyOrder = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>()
.eq("order_sn", orderSn).last("LIMIT 1")
);
Integer orderId = buyOrder.getOrderId();
Integer bookid = userRecord.getBookid();
Integer userid = userRecord.getUserid();
Integer id1 = userRecord.getId();
BuyOrderDetail detailEntity = buyOrderDetailService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderDetail>()
.eq("Order_id", orderId).eq("product_id",bookid));
UserFollowUpEntity followUpEntity = userFollowUpService.getBaseMapper().selectOne(new QueryWrapper<UserFollowUpEntity>().eq("userid", userid).eq("oid",id1).last("LIMIT 1"));
UserFollowUpEntity followUpEntity = userFollowUpService.getBaseMapper().selectOne(new QueryWrapper<UserFollowUpEntity>().eq("userid", userid).eq("oid", id1).last("LIMIT 1"));
// if (followUpEntity != null) {
// return R.error("您已评价过");
@@ -136,11 +128,11 @@ public class UserFollowUpController {
buyOrder.setRecordId(2);
buyOrderService.saveOrUpdate(buyOrder);
if (userFollowUpEntity.getImages()!=null) {
if (userFollowUpEntity.getImages() != null) {
List<Map<String,String>> imageList = (ArrayList<Map<String,String>>)userFollowUpEntity.getImages();
List<Map<String, String>> imageList = (ArrayList<Map<String, String>>) userFollowUpEntity.getImages();
String imageStr = "";
for(Map m : imageList){
for (Map m : imageList) {
imageStr += m.get("url") + ",";
}
@@ -148,33 +140,30 @@ public class UserFollowUpController {
}
userFollowUpEntity.setOid(id1);
userFollowUpEntity.setDelflag(0);
userFollowUpEntity.setCreateDate(new Date());
userFollowUpService.saveOrUpdate(userFollowUpEntity);
return R.ok("成功").put("userFollowUpEntity",userFollowUpEntity);
}
userFollowUpEntity.setOid(id1);
userFollowUpEntity.setDelflag(0);
userFollowUpEntity.setCreateDate(new Date());
userFollowUpService.saveOrUpdate(userFollowUpEntity);
return R.ok("成功").put("userFollowUpEntity", userFollowUpEntity);
}
/**
* 信息
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Integer id){
public R info(@PathVariable("id") Integer id) {
UserFollowUpEntity user = userFollowUpService.getById(id);
return R.ok().put("UserFollowUpEntity", user);
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody UserRecordEntity user){
public R update(@RequestBody UserRecord user) {
userRecordService.updateById(user);
return R.ok();
@@ -184,7 +173,7 @@ public class UserFollowUpController {
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids){
public R delete(@RequestBody Integer[] ids) {
userRecordService.removeByIds(Arrays.asList(ids));
@@ -192,4 +181,4 @@ public class UserFollowUpController {
}
}
}

View File

@@ -23,9 +23,11 @@ public class UserRecordController {
@Autowired
private MyUserService myUserService;
@Autowired
private BuyOrderDetailService buyOrderDetailService;
private BuyOrderProductService buyOrderProductService;
@Autowired
private UserFollowUpService userFollowUpService;
@Autowired
private BuyOrderDetailService buyOrderDetailService;
/**
@@ -43,8 +45,8 @@ public class UserRecordController {
* 查看我的评价
*/
@RequestMapping("/Allevaluations")
public R Allevaluations(@RequestBody UserRecordEntity userRecordEntity) {
List<UserRecordEntity> userid = userRecordService.getBaseMapper().selectList(new QueryWrapper<UserRecordEntity>().eq("userid", userRecordEntity.getUserid()).orderByDesc("create_date"));
public R Allevaluations(@RequestBody UserRecord userRecord) {
List<UserRecord> userid = userRecordService.getBaseMapper().selectList(new QueryWrapper<UserRecord>().eq("userid", userRecord.getUserid()).orderByDesc("create_date"));
return R.ok().put("Allevaluations", userid);
}
@@ -52,16 +54,16 @@ public class UserRecordController {
* 查看全部评价
*/
@RequestMapping("/All")
public R All(@RequestBody UserRecordEntity userRecordEntity) {
public R All(@RequestBody UserRecord userRecordEntity) {
List list = new ArrayList<>();
//此处bookid实际传的是商品id
List<UserRecordEntity> bookid = userRecordService.getBaseMapper().selectList(new QueryWrapper<UserRecordEntity>().eq("bookid", userRecordEntity.getBookid()).orderByDesc("create_date"));
List<UserRecord> bookid = userRecordService.getBaseMapper().selectList(new QueryWrapper<UserRecord>().eq("bookid", userRecordEntity.getBookid()).orderByDesc("create_date"));
if (bookid != null) {
for (UserRecordEntity userRecord : bookid) {
for (UserRecord userRecord : bookid) {
HashMap<Object, Object> map = new HashMap<>();
Integer bookid1 = userRecord.getBookid();
@@ -114,16 +116,16 @@ public class UserRecordController {
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Integer id) {
UserRecordEntity userRecordEntity = userRecordService.getById(id);
return R.ok().put("bookChapterContent", userRecordEntity);
UserRecord userRecord = userRecordService.getById(id);
return R.ok().put("bookChapterContent", userRecord);
}
/**
* 保存
*/
@RequestMapping("/save")
public R save(@RequestBody UserRecordEntity userRecordEntity) {
userRecordService.save(userRecordEntity);
public R save(@RequestBody UserRecord userRecord) {
userRecordService.save(userRecord);
return R.ok();
}
@@ -131,8 +133,8 @@ public class UserRecordController {
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody UserRecordEntity userRecordEntity) {
userRecordService.updateById(userRecordEntity);
public R update(@RequestBody UserRecord userRecord) {
userRecordService.updateById(userRecord);
return R.ok();
}
@@ -169,23 +171,23 @@ public class UserRecordController {
//状态3为已收货
// .eq("order_status","3")
);
UserRecordEntity userRecordEntity = new UserRecordEntity();
UserRecord userRecord = new UserRecord();
if (!ToolObject.isNullOrEmpty(buyOrder)) {
return error("您已评价过了,请勿重复评论");
//
} else {
userRecordEntity.setId(buyOrder.getOrderId());
userRecordEntity.setContent(comment);
userRecord.setId(buyOrder.getOrderId());
userRecord.setContent(comment);
//商品评价
userRecordEntity.setBookid(bookid);
userRecordEntity.setUserid(userid);
userRecordEntity.setOrderSn(orderSn);
userRecordEntity.setDelflag(0);
userRecordEntity.setProductId(bookid);
userRecordService.saveOrUpdate(userRecordEntity);
return R.ok("成功").put("userRecordEntity", userRecordEntity);
userRecord.setBookid(bookid);
userRecord.setUserid(userid);
userRecord.setOrderSn(orderSn);
userRecord.setDelflag(0);
userRecord.setProductId(bookid);
userRecordService.saveOrUpdate(userRecord);
return R.ok("成功").put("userRecordEntity", userRecord);
}
@@ -196,8 +198,44 @@ public class UserRecordController {
* @param recordEntity
* @return 生成评论(上传图片,星级评价
*/
@RequestMapping("/UserRecordComment")
public R comment(@RequestBody UserRecord recordEntity) {
QueryWrapper<BuyOrder> buyOrderQueryWrapper = new QueryWrapper<>();
buyOrderQueryWrapper.eq("order_sn", recordEntity.getOrderSn());
BuyOrder buyOrder = buyOrderService.getOne(buyOrderQueryWrapper);
Integer orderId = buyOrder.getOrderId();
QueryWrapper<BuyOrderProduct> buyOrderProductQueryWrapper = new QueryWrapper<>();
buyOrderProductQueryWrapper.eq("order_id", orderId);
buyOrderProductQueryWrapper.eq("product_id", recordEntity.getProductId());
BuyOrderProduct buyOrderProduct = buyOrderProductService.getOne(buyOrderProductQueryWrapper);
Integer orderId1 = buyOrderProduct.getOrderId();
UserRecord userRecord = userRecordService.getBaseMapper().selectOne(new QueryWrapper<UserRecord>().eq("orderSn", recordEntity.getOrderSn()).eq("userid", recordEntity.getUserid()).eq("orderdid", orderId1).last("LIMIT 1"));
if (userRecord != null) {
return R.error("您已评价过");
}
if (recordEntity.getImages() != null) {
List<Map<String, String>> imageList = (ArrayList<Map<String, String>>) recordEntity.getImages();
String imageStr = "";
for (Map m : imageList) {
imageStr += m.get("url") + ",";
}
recordEntity.setImages(imageStr);
}
recordEntity.setDelflag(0);
recordEntity.setOrderdId(orderId1);
userRecordService.saveOrUpdate(recordEntity);
buyOrderProduct.setRecordId(1);
buyOrderProductService.saveOrUpdate(buyOrderProduct);
return R.ok("成功").put("userRecordEntity", recordEntity);
}
/*
TODO 老版本接口,新版本上线后要删除
*/
@RequestMapping("/UserRecordcomment")
public R commodity(@RequestBody UserRecordEntity recordEntity) {
public R commodity(@RequestBody UserRecord recordEntity) {
//todo 已收货限制字段,只可评价一次
BuyOrder buyOrder = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>()
.eq("order_sn", recordEntity.getOrderSn())
@@ -206,7 +244,7 @@ public class UserRecordController {
Integer orderId = buyOrder.getOrderId();
BuyOrderDetail detailEntity = buyOrderDetailService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderDetail>().eq("Order_id", orderId).eq("product_id", recordEntity.getBookid()));
Integer orderId1 = detailEntity.getOrderId();
UserRecordEntity userRecordEntity = userRecordService.getBaseMapper().selectOne(new QueryWrapper<UserRecordEntity>().eq("orderSn", recordEntity.getOrderSn()).eq("userid", recordEntity.getUserid()).eq("orderdid", orderId1).last("LIMIT 1"));
UserRecord userRecordEntity = userRecordService.getBaseMapper().selectOne(new QueryWrapper<UserRecord>().eq("orderSn", recordEntity.getOrderSn()).eq("userid", recordEntity.getUserid()).eq("orderdid", orderId1).last("LIMIT 1"));
if (userRecordEntity != null) {
return R.error("您已评价过");