修复一下bug

This commit is contained in:
wangjinlei
2024-04-22 14:33:39 +08:00
parent 3ae068513c
commit d6123a8132
8 changed files with 96 additions and 13 deletions

View File

@@ -239,18 +239,20 @@ public class BuyOrderController {
totalPrice = totalPrice.add(getShoppingAmount(buyOrder));
String orderSn = IdWorker.getTimeId().substring(0, 32);
buyOrder.setOrderSn(orderSn);
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());
String str = buyOrder.getShippingUser()+buyOrder.getAddress()+buyOrder.getRemark();
if (str.contains("+")||str.contains("&")) {
return R.error(500, "信息中不能含有“+”、“&”符号!");
if(buyOrder.getAddressId()!=0){
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());
String str = buyOrder.getShippingUser()+buyOrder.getAddress()+buyOrder.getRemark();
if (str.contains("+")||str.contains("&")) {
return R.error(500, "信息中不能含有“+”、“&”符号!");
}
}
buyOrderService.save(buyOrder);

View File

@@ -129,4 +129,10 @@ public class CourseController {
return R.ok();
}
@RequestMapping("/testCourse")
public R testCourse(){
courseService.testCourse();
return R.ok();
}
}

View File

@@ -18,4 +18,6 @@ public interface CourseService extends IService<CourseEntity> {
List<CourseEntity> getCourseListForSociology(int sociologyId);
Page getCourseListCanSociology(ParamTo param);
void testCourse();
}

View File

@@ -33,6 +33,10 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
private CourseToSociologyDao courseToSociologyDao;
@Autowired
private CourseCatalogueDao courseCatalogueDao;
@Autowired
private ShopProductDao shopProductDao;
@Autowired
private ShopProductCourseDao shopProductCourseDao;
@Override
public Page getCourseList(Map<String,Object> map) {
@@ -117,6 +121,43 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
return page;
}
@Override
public void testCourse() {
List<CourseCatalogueEntity> courseCatalogueEntities = courseCatalogueDao.selectList(new LambdaQueryWrapper<CourseCatalogueEntity>());
for (CourseCatalogueEntity c: courseCatalogueEntities){
if(shopProductCourseDao.selectCount(new LambdaQueryWrapper<ShopProductCourseEntity>().eq(ShopProductCourseEntity::getCatalogueId,c.getId()))>0){
continue;
}
ShopProduct shopProduct = new ShopProduct();
shopProduct.setProductName(c.getTitle()+"."+c.getTitle()+"(半年)");
shopProduct.setPrice(c.getHalfFee());
shopProduct.setGoodsType("05");
shopProductDao.insert(shopProduct);
//添加半年期的商品课程对应关系
ShopProductCourseEntity shopProductCourseEntity = new ShopProductCourseEntity();
shopProductCourseEntity.setProductId(shopProduct.getProductId());
shopProductCourseEntity.setCourseId(c.getCourseId());
shopProductCourseEntity.setCatalogueId(c.getId());
shopProductCourseEntity.setDays(180);
shopProductCourseDao.insert(shopProductCourseEntity);
//添加一年期商品
ShopProduct shopProduct1 = new ShopProduct();
shopProduct1.setProductName(c.getTitle()+"."+c.getTitle()+"(一年)");
shopProduct1.setPrice(c.getFee());
shopProduct1.setGoodsType("05");
shopProductDao.insert(shopProduct1);
//添加一年期的商品课程对应关系
ShopProductCourseEntity shopProductCourseEntity1 = new ShopProductCourseEntity();
shopProductCourseEntity1.setProductId(shopProduct1.getProductId());
shopProductCourseEntity1.setCourseId(c.getCourseId());
shopProductCourseEntity1.setCatalogueId(c.getId());
shopProductCourseEntity1.setDays(365);
shopProductCourseDao.insert(shopProductCourseEntity1);
}
}
private List<Integer> categoryIds(Integer id){
ArrayList<Integer> integers = new ArrayList<>();
CourseCategoryEntity courseCategoryEntity = courseCategoryDao.selectById(id);

View File

@@ -2,6 +2,7 @@ package com.peanut.modules.sociology.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.peanut.common.utils.R;
import com.peanut.modules.common.entity.ShopProduct;
import com.peanut.modules.common.to.ParamTo;
import com.peanut.modules.sociology.service.ShopProductService;
import lombok.extern.slf4j.Slf4j;
@@ -10,6 +11,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@Slf4j
@RestController("sociologyProduct")
@RequestMapping("sociology/product")
@@ -23,5 +26,11 @@ public class ShopProductController {
return R.ok().put("products",marketProductList);
}
@RequestMapping("/getProductListForCourse")
public R getProductListForCourse(@RequestBody ParamTo param){
List<ShopProduct> productListForCourse = shopProductService.getProductListForCourse(param.getId());
return R.ok().put("productList",productListForCourse);
}
}

View File

@@ -5,7 +5,11 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.common.entity.ShopProduct;
import com.peanut.modules.common.to.ParamTo;
import java.util.List;
public interface ShopProductService extends IService<ShopProduct> {
Page getMarketProductList(ParamTo param);
List<ShopProduct> getProductListForCourse(Integer CatalogueId);
}

View File

@@ -17,7 +17,7 @@ public class CourseCatalogueChapterServiceImpl extends ServiceImpl<CourseCatalog
@Override
public List<CourseCatalogueChapterEntity> getCourseCatalogueChapterList(int id) {
LambdaQueryWrapper<CourseCatalogueChapterEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CourseCatalogueChapterEntity::getCourseId,id);
wrapper.eq(CourseCatalogueChapterEntity::getCatalogueId,id);
wrapper.orderByAsc(CourseCatalogueChapterEntity::getSort);
List<CourseCatalogueChapterEntity> list = this.list(wrapper);
return list;

View File

@@ -3,17 +3,24 @@ package com.peanut.modules.sociology.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.peanut.modules.common.dao.ShopProductCourseDao;
import com.peanut.modules.common.dao.ShopProductDao;
import com.peanut.modules.common.entity.ShopProduct;
import com.peanut.modules.common.entity.ShopProductCourseEntity;
import com.peanut.modules.common.entity.ShopProductToSociologyMarket;
import com.peanut.modules.common.to.ParamTo;
import com.peanut.modules.sociology.service.ShopProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Slf4j
@Service("sociologyShopProduct")
public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProduct> implements ShopProductService {
@Autowired
private ShopProductCourseDao shopProductCourseDao;
@Override
public Page getMarketProductList(ParamTo param) {
@@ -24,4 +31,16 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
Page<ShopProduct> shopProductPage = this.getBaseMapper().selectJoinPage(new Page<>(param.getPage(), param.getLimit()), ShopProduct.class, wrapper);
return shopProductPage;
}
@Override
public List<ShopProduct> getProductListForCourse(Integer catalogueId) {
MPJLambdaWrapper<ShopProductCourseEntity> wrapper = new MPJLambdaWrapper<>();
wrapper.selectAll(ShopProduct.class);
wrapper.leftJoin(ShopProduct.class,ShopProduct::getProductId,ShopProductCourseEntity::getProductId);
wrapper.eq(ShopProductCourseEntity::getCatalogueId,catalogueId);
wrapper.orderByAsc(ShopProduct::getPrice);
List<ShopProduct> shopProducts = shopProductCourseDao.selectJoinList(ShopProduct.class, wrapper);
return shopProducts;
}
}