diff --git a/src/main/java/com/peanut/modules/book/controller/BookLabelAndMarketController.java b/src/main/java/com/peanut/modules/book/controller/BookLabelAndMarketController.java index 36e8efc4..638a392d 100644 --- a/src/main/java/com/peanut/modules/book/controller/BookLabelAndMarketController.java +++ b/src/main/java/com/peanut/modules/book/controller/BookLabelAndMarketController.java @@ -1,7 +1,6 @@ package com.peanut.modules.book.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.peanut.common.utils.R; @@ -267,28 +266,20 @@ public class BookLabelAndMarketController { } @RequestMapping(path = "/delToLable") - public R delToLable(String lableIds) { - if (!StringUtils.isEmpty(lableIds)) { - String[] ids = lableIds.split(","); - if (ids.length>0) { - for (String id : ids) { - toLabelService.removeById(id); - } - } - } + public R delToLable(String lableId,String productId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + wrapper.eq(ShopProductToBookLabel::getBookLabelId,lableId); + wrapper.eq(ShopProductToBookLabel::getProductId,productId); + toLabelService.remove(wrapper); return R.ok(); } @RequestMapping(path = "/delToMarket") - public R delToMarket(String marketds) { - if (!StringUtils.isEmpty(marketds)) { - String[] ids = marketds.split(","); - if (ids.length>0) { - for (String id : ids) { - toMarketService.removeById(id); - } - } - } + public R delToMarket(String marketId,String productId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + wrapper.eq(ShopProductToBookMarket::getBookMarketId,marketId); + wrapper.eq(ShopProductToBookMarket::getProductId,productId); + toMarketService.remove(wrapper); return R.ok(); } diff --git a/src/main/java/com/peanut/modules/common/controller/BaseAreaController.java b/src/main/java/com/peanut/modules/common/controller/BaseAreaController.java new file mode 100644 index 00000000..9f2716f1 --- /dev/null +++ b/src/main/java/com/peanut/modules/common/controller/BaseAreaController.java @@ -0,0 +1,84 @@ +package com.peanut.modules.common.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.peanut.common.utils.R; +import com.peanut.modules.common.entity.BaseAreaEntity; +import com.peanut.modules.common.service.BaseAreaService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +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; +import java.util.Map; + +/** + * 国家区域管理 + */ +@Slf4j +@RestController("commonBaseArea") +@RequestMapping("common/baseArea") +public class BaseAreaController { + + @Autowired + private BaseAreaService baseAreaService; + + /** + * 添加区域 + * @param baseArea + * @return + */ + @RequestMapping("/addBaseArea") + public R addBaseArea(@RequestBody BaseAreaEntity baseArea){ + baseAreaService.save(baseArea); + return R.ok(); + } + + /** + * 删除区域 + * @param map + * @return + */ + @RequestMapping("/delBaseArea") + public R delBaseArea(@RequestBody Map map){ + Integer areaId = Integer.valueOf(map.get("areaId").toString()); + baseAreaService.removeById(areaId); + return R.ok(); + } + + /** + * 编辑区域信息 + * @param baseArea + * @return + */ + @RequestMapping("/editBaseArea") + public R editBaseArea(@RequestBody BaseAreaEntity baseArea){ + baseAreaService.updateById(baseArea); + return R.ok(); + } + + /** + * 获取区域列表 + * @param map + * @return + */ + @RequestMapping("/getBaseAreas") + public R getBaseAreas(@RequestBody Map map){ + Integer limit = Integer.valueOf(map.get("limit").toString()); + Integer page = Integer.valueOf(map.get("page").toString()); + + Page baseAreas = baseAreaService.getBaseAreas(limit, page); + return R.ok().put("page",baseAreas); + } + + /** + * 获取全部国家领域 + * @return + */ + @RequestMapping("/getAllBaseArea") + public R getAllBaseArea(){ + List list = baseAreaService.list(); + return R.ok().put("baseAreas",list); + } + +} diff --git a/src/main/java/com/peanut/modules/common/controller/ProvinceController.java b/src/main/java/com/peanut/modules/common/controller/ProvinceController.java new file mode 100644 index 00000000..2725530f --- /dev/null +++ b/src/main/java/com/peanut/modules/common/controller/ProvinceController.java @@ -0,0 +1,82 @@ +package com.peanut.modules.common.controller; + +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.common.entity.City; +import com.peanut.modules.common.entity.County; +import com.peanut.modules.common.entity.Province; +import com.peanut.modules.common.service.CityService; +import com.peanut.modules.common.service.CountyService; +import com.peanut.modules.common.service.ProvinceService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * 省市区管理 + */ +@Slf4j +@RestController("commonProvince") +@RequestMapping("common/province") +public class ProvinceController { + + @Autowired + private ProvinceService provinceService; + @Autowired + private CityService cityService; + @Autowired + private CountyService countyService; + @Autowired + private StringRedisTemplate redisTemplate; + + //获取地址 + @RequestMapping("/getProvince") + public R getProvince() { + //优化查询速度 目录放入redis中 + String s = redisTemplate.opsForValue().get("Province"); + List> listData = new ArrayList<>(); + if (StringUtils.isNotBlank(s)) { + List redisData = JSONArray.parseArray(s); + for (Object object : redisData) { + Map ret = (Map) object;//取出list里面的值转为map + listData.add(ret); + } + return R.ok().put("provinceEntity", listData); + } + List provinceList = provinceService.getCity(); + redisTemplate.opsForValue().set("Province", JSON.toJSONString(provinceList)); + return R.ok().put("provinceEntity", provinceList); + } + + //获取省列表 + @RequestMapping("/getProvinceList") + public R getProvinceList() { + List provinceList = provinceService.getBaseMapper().selectList(new QueryWrapper()); + return R.ok().put("provinceList", provinceList); + } + + //获取市列表 + @RequestMapping("/getCityList") + public R getCityList(@RequestParam("provId") Integer provId) { + List prov = cityService.getBaseMapper().selectList(new QueryWrapper() + .eq("prov_id", provId)); + return R.ok().put("prov", prov); + } + + //获取区列表 + @RequestMapping("/getCountyList") + public R getCountyList(@RequestParam("cityId") Integer cityId) { + List countyList = countyService.getBaseMapper().selectList(new QueryWrapper().eq("city_id", cityId)); + return R.ok().put("countyList", countyList); + } + +} diff --git a/src/main/java/com/peanut/modules/common/controller/UserAddressController.java b/src/main/java/com/peanut/modules/common/controller/UserAddressController.java new file mode 100644 index 00000000..93bc976e --- /dev/null +++ b/src/main/java/com/peanut/modules/common/controller/UserAddressController.java @@ -0,0 +1,106 @@ +package com.peanut.modules.common.controller; + +import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.peanut.common.utils.R; +import com.peanut.modules.common.entity.UserAddress; +import com.peanut.modules.common.service.UserAddressService; +import com.peanut.modules.common.vo.UserAddressVo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import java.util.ArrayList; +import java.util.List; + +/** + * 收货地址管理 + */ +@Slf4j +@RestController("commonUserAddress") +@RequestMapping("common/userAddress") +public class UserAddressController { + + @Autowired + private UserAddressService userAddressService; + + /** + * 获取地址信息 + */ + @RequestMapping("/info/{addressId}") + public R info(@PathVariable("addressId") Integer addressId) { + UserAddress userAddress = userAddressService.getById(addressId); + UserAddressVo vo = new UserAddressVo(); + BeanUtil.copyProperties(userAddress, vo); + vo = userAddressService.getAddressName(vo, userAddress.getRegionCode()); + return R.ok().put("result", vo); + } + + /** + * 保存 + */ + @RequestMapping("/save") + public R save(@RequestBody UserAddress userAddress) { + // 判断是否已经有默认的地址了 + if ((userAddressService.getUserDefaultAddressCount(userAddress.getUserId()) >= 1) && userAddress.getIsDefault() == 1) { + return R.error("已经存在默认地址"); + } + if(userAddress.getRegionCode()==null||userAddress.getRegionCode().equals("")){ + return R.error("地址异常添加失败!"); + } + String str = userAddress.getConsigneeName()+userAddress.getConsigneePhone()+userAddress.getDetailAddress(); + if(str.contains("+")||str.contains("&")){ + return R.error("信息中不能含有“+”、“&”符号!"); + } + userAddressService.save(userAddress); + return R.ok(); + } + + @RequestMapping("/update") + public R update(@RequestBody UserAddress userAddress) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + wrapper.eq(UserAddress::getId,userAddress.getId()); + wrapper.eq(UserAddress::getIsDefault,1); + UserAddress ua = userAddressService.getOne(wrapper); + if (ua == null){ + if ((userAddressService.getUserDefaultAddressCount(userAddress.getUserId()) >= 1) && userAddress.getIsDefault() == 1) { + return R.error("已经存在默认地址"); + } + } + String str = userAddress.getConsigneeName()+userAddress.getConsigneePhone()+userAddress.getDetailAddress(); + if(str.contains("+")||str.contains("&")){ + return R.error("信息中不能含有“+”、“&”符号!"); + } + userAddressService.updateById(userAddress); + return R.ok(); + } + + /** + * 删除用户地址 + */ + @RequestMapping(value = "/delete", method = RequestMethod.GET) + public R delete(@RequestParam("id") Integer id) { + userAddressService.removeById(id); + return R.ok(); + } + + /** + * 获取用户收货地址列表 + */ + @RequestMapping("/getUserAddress") + public R getUserAddress(@RequestParam("userId") Integer userId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("user_id", userId); + queryWrapper.orderByDesc("is_default"); + List userAddressList = userAddressService.list(queryWrapper); + List 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); + } + +} diff --git a/src/main/java/com/peanut/modules/common/controller/UserController.java b/src/main/java/com/peanut/modules/common/controller/UserController.java index 2cb7ef48..255153c3 100644 --- a/src/main/java/com/peanut/modules/common/controller/UserController.java +++ b/src/main/java/com/peanut/modules/common/controller/UserController.java @@ -1,9 +1,7 @@ package com.peanut.modules.common.controller; -import cn.hutool.core.util.ObjectUtil; import com.alibaba.druid.util.StringUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.peanut.common.utils.MD5Utils; import com.peanut.common.utils.MailUtil; import com.peanut.common.utils.R; @@ -21,8 +19,11 @@ import java.util.Map; import java.util.Random; import java.util.concurrent.TimeUnit; +/** + * 用户登陆注册验证码 + */ @Slf4j -@RestController +@RestController("commonUser") @RequestMapping("common/user") public class UserController { diff --git a/src/main/java/com/peanut/modules/common/service/BaseAreaService.java b/src/main/java/com/peanut/modules/common/service/BaseAreaService.java new file mode 100644 index 00000000..0278ea56 --- /dev/null +++ b/src/main/java/com/peanut/modules/common/service/BaseAreaService.java @@ -0,0 +1,12 @@ +package com.peanut.modules.common.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.peanut.modules.common.entity.BaseAreaEntity; + +public interface BaseAreaService extends IService { + + Page getBaseAreas(Integer limit, Integer page); + +} + diff --git a/src/main/java/com/peanut/modules/common/service/CityService.java b/src/main/java/com/peanut/modules/common/service/CityService.java new file mode 100644 index 00000000..66e04644 --- /dev/null +++ b/src/main/java/com/peanut/modules/common/service/CityService.java @@ -0,0 +1,12 @@ +package com.peanut.modules.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.peanut.common.utils.PageUtils; +import com.peanut.modules.common.entity.City; +import java.util.Map; + +public interface CityService extends IService { + + PageUtils queryPage(Map params); + +} diff --git a/src/main/java/com/peanut/modules/common/service/CountyService.java b/src/main/java/com/peanut/modules/common/service/CountyService.java new file mode 100644 index 00000000..29d021bd --- /dev/null +++ b/src/main/java/com/peanut/modules/common/service/CountyService.java @@ -0,0 +1,13 @@ +package com.peanut.modules.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.peanut.common.utils.PageUtils; +import com.peanut.modules.common.entity.County; + +import java.util.Map; + +public interface CountyService extends IService { + + PageUtils queryPage(Map params); +} + diff --git a/src/main/java/com/peanut/modules/common/service/ProvinceService.java b/src/main/java/com/peanut/modules/common/service/ProvinceService.java new file mode 100644 index 00000000..09c33845 --- /dev/null +++ b/src/main/java/com/peanut/modules/common/service/ProvinceService.java @@ -0,0 +1,16 @@ +package com.peanut.modules.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.peanut.common.utils.PageUtils; +import com.peanut.modules.common.entity.Province; +import java.util.List; +import java.util.Map; + +public interface ProvinceService extends IService { + + PageUtils queryPage(Map params); + + List getCity(); + +} + diff --git a/src/main/java/com/peanut/modules/common/service/UserAddressService.java b/src/main/java/com/peanut/modules/common/service/UserAddressService.java new file mode 100644 index 00000000..a5a52c23 --- /dev/null +++ b/src/main/java/com/peanut/modules/common/service/UserAddressService.java @@ -0,0 +1,17 @@ +package com.peanut.modules.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.peanut.common.utils.PageUtils; +import com.peanut.modules.common.entity.UserAddress; +import com.peanut.modules.common.vo.UserAddressVo; +import java.util.Map; + +public interface UserAddressService extends IService { + + PageUtils queryPage(Map params); + + UserAddressVo getAddressName(UserAddressVo vo, String regionCode); + + int getUserDefaultAddressCount(Integer userId); + +} \ No newline at end of file diff --git a/src/main/java/com/peanut/modules/common/service/impl/BaseAreaServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/BaseAreaServiceImpl.java new file mode 100644 index 00000000..3058f6cd --- /dev/null +++ b/src/main/java/com/peanut/modules/common/service/impl/BaseAreaServiceImpl.java @@ -0,0 +1,24 @@ +package com.peanut.modules.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.peanut.modules.common.dao.BaseAreaDao; +import com.peanut.modules.common.entity.BaseAreaEntity; +import com.peanut.modules.common.service.BaseAreaService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Slf4j +@Service("commonBaseAreaService") +public class BaseAreaServiceImpl extends ServiceImpl implements BaseAreaService { + + @Override + public Page getBaseAreas(Integer limit, Integer page) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(BaseAreaEntity::getDelFlag,0); + Page baseAreaEntityPage = getBaseMapper().selectPage(new Page(page, limit), wrapper); + return baseAreaEntityPage; + } + +} \ No newline at end of file diff --git a/src/main/java/com/peanut/modules/common/service/impl/CityServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/CityServiceImpl.java new file mode 100644 index 00000000..d7aa5ef3 --- /dev/null +++ b/src/main/java/com/peanut/modules/common/service/impl/CityServiceImpl.java @@ -0,0 +1,29 @@ +package com.peanut.modules.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.peanut.common.utils.PageUtils; +import com.peanut.common.utils.Query; +import com.peanut.modules.common.dao.CityDao; +import com.peanut.modules.common.entity.City; +import com.peanut.modules.common.service.CityService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.Map; + +@Slf4j +@Service("commonCityService") +public class CityServiceImpl extends ServiceImpl implements CityService { + + @Override + public PageUtils queryPage(Map params) { + IPage page = this.page( + new Query().getPage(params), + new QueryWrapper() + ); + return new PageUtils(page); + } + +} \ No newline at end of file diff --git a/src/main/java/com/peanut/modules/common/service/impl/CountyServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/CountyServiceImpl.java new file mode 100644 index 00000000..ae7baaa8 --- /dev/null +++ b/src/main/java/com/peanut/modules/common/service/impl/CountyServiceImpl.java @@ -0,0 +1,28 @@ +package com.peanut.modules.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.peanut.common.utils.PageUtils; +import com.peanut.common.utils.Query; +import com.peanut.modules.common.dao.CountyDao; +import com.peanut.modules.common.entity.County; +import com.peanut.modules.common.service.CountyService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import java.util.Map; + +@Slf4j +@Service("commonCountyService") +public class CountyServiceImpl extends ServiceImpl implements CountyService { + + @Override + public PageUtils queryPage(Map params) { + IPage page = this.page( + new Query().getPage(params), + new QueryWrapper() + ); + return new PageUtils(page); + } + +} \ No newline at end of file diff --git a/src/main/java/com/peanut/modules/common/service/impl/ProvinceServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/ProvinceServiceImpl.java new file mode 100644 index 00000000..23d46453 --- /dev/null +++ b/src/main/java/com/peanut/modules/common/service/impl/ProvinceServiceImpl.java @@ -0,0 +1,59 @@ +package com.peanut.modules.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.peanut.common.utils.PageUtils; +import com.peanut.common.utils.Query; +import com.peanut.modules.common.dao.ProvinceDao; +import com.peanut.modules.common.entity.City; +import com.peanut.modules.common.entity.County; +import com.peanut.modules.common.entity.Province; +import com.peanut.modules.common.service.CityService; +import com.peanut.modules.common.service.CountyService; +import com.peanut.modules.common.service.ProvinceService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +@Slf4j +@Service("commonProvinceService") +public class ProvinceServiceImpl extends ServiceImpl implements ProvinceService { + + @Autowired + private CityService cityService; + @Autowired + private CountyService countyService; + + @Override + public PageUtils queryPage(Map params) { + IPage page = this.page( + new Query().getPage(params), + new QueryWrapper() + ); + + return new PageUtils(page); + } + + @Override + public List getCity() { + List provinceList = this.baseMapper.selectList(new QueryWrapper()); + for (Province province:provinceList){ + List prov = cityService.getBaseMapper().selectList(new QueryWrapper() + .eq("prov_id", province.getProvId())); + if (prov.size() > 0) { + for (City city : prov) { + List countyList = countyService.getBaseMapper().selectList(new QueryWrapper().eq("city_id", city.getCityId())); + if (countyList != null) { + city.setCountyList(countyList); + } + } + province.setCityList(prov); + } + } + return provinceList; + } +} \ No newline at end of file diff --git a/src/main/java/com/peanut/modules/common/service/impl/UserAddressServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/UserAddressServiceImpl.java new file mode 100644 index 00000000..07f3ba8a --- /dev/null +++ b/src/main/java/com/peanut/modules/common/service/impl/UserAddressServiceImpl.java @@ -0,0 +1,72 @@ +package com.peanut.modules.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.peanut.common.utils.PageUtils; +import com.peanut.common.utils.Query; +import com.peanut.modules.common.dao.UserAddressDao; +import com.peanut.modules.common.entity.City; +import com.peanut.modules.common.entity.County; +import com.peanut.modules.common.entity.Province; +import com.peanut.modules.common.entity.UserAddress; +import com.peanut.modules.common.service.CityService; +import com.peanut.modules.common.service.CountyService; +import com.peanut.modules.common.service.ProvinceService; +import com.peanut.modules.common.service.UserAddressService; +import com.peanut.modules.common.vo.UserAddressVo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Map; + +@Slf4j +@Service("commonUserAddressService") +public class UserAddressServiceImpl extends ServiceImpl implements UserAddressService { + @Autowired + private CountyService countyService; + + @Autowired + private CityService cityService; + + @Autowired + private ProvinceService provinceService; + + @Override + public PageUtils queryPage(Map params) { + IPage page = this.page( + new Query().getPage(params), + new QueryWrapper<>() + ); + return new PageUtils(page); + } + + @Override + public UserAddressVo getAddressName(UserAddressVo vo, String regionCode) { + QueryWrapper countyQueryWrapper = new QueryWrapper<>(); + countyQueryWrapper.eq("region_code", regionCode); + County county = countyService.getOne(countyQueryWrapper); + if(county==null){ + return null; + } + vo.setCounty(county.getCountyName()); + LambdaQueryWrapper cityLambdaQueryWrapper = new LambdaQueryWrapper<>(); + cityLambdaQueryWrapper.eq(City::getCityId,county.getCityId()); + City city = cityService.getOne(cityLambdaQueryWrapper); + vo.setCity(city.getCityName()); + LambdaQueryWrapper provinceLambdaQueryWrapper = new LambdaQueryWrapper<>(); + provinceLambdaQueryWrapper.eq(Province::getProvId,city.getProvId()); + Province province = provinceService.getOne(provinceLambdaQueryWrapper); + vo.setProvince((province.getProvName())); + return vo; + } + + public int getUserDefaultAddressCount(Integer userId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("user_id", userId); + queryWrapper.eq("is_default", 1); + return this.count(queryWrapper); + } +} \ No newline at end of file diff --git a/src/main/java/com/peanut/modules/common/vo/UserAddressVo.java b/src/main/java/com/peanut/modules/common/vo/UserAddressVo.java new file mode 100644 index 00000000..fdf35dcb --- /dev/null +++ b/src/main/java/com/peanut/modules/common/vo/UserAddressVo.java @@ -0,0 +1,49 @@ +package com.peanut.modules.common.vo; + +import lombok.Data; + +@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; + +} diff --git a/src/main/java/com/peanut/modules/master/controller/BuyConfigController.java b/src/main/java/com/peanut/modules/master/controller/BuyConfigController.java new file mode 100644 index 00000000..b2ab906e --- /dev/null +++ b/src/main/java/com/peanut/modules/master/controller/BuyConfigController.java @@ -0,0 +1,82 @@ +package com.peanut.modules.master.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.common.entity.BookBuyConfigEntity; +import com.peanut.modules.master.service.BuyConfigService; +import lombok.extern.slf4j.Slf4j; +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; + +/** + * 充值价格表单管理 + */ +@Slf4j +@RestController("masterBookBuyConfig") +@RequestMapping("master/bookBuyConfig") +public class BuyConfigController { + + @Autowired + private BuyConfigService buyConfigService; + + /** + * 列表 + */ + @RequestMapping("/list") + public R list(@RequestParam Map params){ + PageUtils page = buyConfigService.queryPage(params); + return R.ok().put("page", page); + } + + /** + * 信息 + */ + @RequestMapping("/info/{priceTypeId}") + public R info(@PathVariable("priceTypeId") Integer priceTypeId){ + BookBuyConfigEntity bookBuyConfig = buyConfigService.getById(priceTypeId); + return R.ok().put("bookBuyConfig", bookBuyConfig); + } + + /** + * 保存 + */ + @RequestMapping("/save") + public R save(@RequestBody BookBuyConfigEntity bookBuyConfig){ + buyConfigService.save(bookBuyConfig); + return R.ok(); + } + + /** + * 修改 + */ + @RequestMapping("/update") + public R update(@RequestBody BookBuyConfigEntity bookBuyConfig){ + buyConfigService.updateById(bookBuyConfig); + return R.ok(); + } + + /** + * 删除 + */ + @RequestMapping("/delete") + public R delete(@RequestBody Integer[] priceTypeIds){ + buyConfigService.removeByIds(Arrays.asList(priceTypeIds)); + return R.ok(); + } + + /** + * 获取VIP 金额 或者充值类型 + */ + @RequestMapping("/getVipOrPoint") + public R getVipOrPoint(@RequestParam("type") String type,@RequestParam("qudao") String qudao){ + List bookBuyConfigEntities = buyConfigService.getBaseMapper().selectList(new QueryWrapper().eq("type",type).eq("qudao",qudao)); + return R.ok().put("list",bookBuyConfigEntities); + } + + + +} diff --git a/src/main/java/com/peanut/modules/master/controller/PayPaymentOrderController.java b/src/main/java/com/peanut/modules/master/controller/PayPaymentOrderController.java new file mode 100644 index 00000000..92878193 --- /dev/null +++ b/src/main/java/com/peanut/modules/master/controller/PayPaymentOrderController.java @@ -0,0 +1,70 @@ +package com.peanut.modules.master.controller; + +import com.peanut.common.utils.PageUtils; +import com.peanut.common.utils.R; +import com.peanut.modules.common.entity.PayPaymentOrderEntity; +import com.peanut.modules.master.service.PayPaymentOrderService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import java.util.Arrays; +import java.util.Map; + +/** + * 充值订单表 + */ +@Slf4j +@RestController("masterPayPaymentOrder") +@RequestMapping("master/payPaymentOrder") +public class PayPaymentOrderController { + + @Autowired + private PayPaymentOrderService payPaymentOrderService; + + /** + * 列表 + */ + @RequestMapping("/list") + public R list(@RequestParam Map params){ + PageUtils page = payPaymentOrderService.queryPage(params); + return R.ok().put("page", page); + } + + + /** + * 信息 + */ + @RequestMapping("/info/{id}") + public R info(@PathVariable("id") Long id){ + PayPaymentOrderEntity payPaymentOrder = payPaymentOrderService.getById(id); + return R.ok().put("payPaymentOrder", payPaymentOrder); + } + + /** + * 保存 + */ + @RequestMapping("/save") + public R save(@RequestBody PayPaymentOrderEntity payPaymentOrder){ + payPaymentOrderService.save(payPaymentOrder); + return R.ok(); + } + + /** + * 修改 + */ + @RequestMapping("/update") + public R update(@RequestBody PayPaymentOrderEntity payPaymentOrder){ + payPaymentOrderService.updateById(payPaymentOrder); + return R.ok(); + } + + /** + * 删除 + */ + @RequestMapping("/delete") + public R delete(@RequestBody Long[] ids){ + payPaymentOrderService.removeByIds(Arrays.asList(ids)); + return R.ok(); + } + +} diff --git a/src/main/java/com/peanut/modules/master/controller/ShopProductController.java b/src/main/java/com/peanut/modules/master/controller/ShopProductController.java index cc911b99..2d20dd6c 100644 --- a/src/main/java/com/peanut/modules/master/controller/ShopProductController.java +++ b/src/main/java/com/peanut/modules/master/controller/ShopProductController.java @@ -13,6 +13,9 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.Map; +/** + * 商品 + */ @Slf4j @RestController("masterShopProduct") @RequestMapping("master/shopProduct") diff --git a/src/main/java/com/peanut/modules/master/service/BuyConfigService.java b/src/main/java/com/peanut/modules/master/service/BuyConfigService.java new file mode 100644 index 00000000..2294a9c4 --- /dev/null +++ b/src/main/java/com/peanut/modules/master/service/BuyConfigService.java @@ -0,0 +1,14 @@ +package com.peanut.modules.master.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.peanut.common.utils.PageUtils; +import com.peanut.modules.common.entity.BookBuyConfigEntity; + +import java.util.Map; + +public interface BuyConfigService extends IService { + + PageUtils queryPage(Map params); + +} + diff --git a/src/main/java/com/peanut/modules/master/service/PayPaymentOrderService.java b/src/main/java/com/peanut/modules/master/service/PayPaymentOrderService.java new file mode 100644 index 00000000..68861630 --- /dev/null +++ b/src/main/java/com/peanut/modules/master/service/PayPaymentOrderService.java @@ -0,0 +1,12 @@ +package com.peanut.modules.master.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.peanut.common.utils.PageUtils; +import com.peanut.modules.common.entity.PayPaymentOrderEntity; +import java.util.Map; + +public interface PayPaymentOrderService extends IService { + + PageUtils queryPage(Map params); + +} \ No newline at end of file diff --git a/src/main/java/com/peanut/modules/master/service/impl/BuyConfigServiceImpl.java b/src/main/java/com/peanut/modules/master/service/impl/BuyConfigServiceImpl.java new file mode 100644 index 00000000..02d36094 --- /dev/null +++ b/src/main/java/com/peanut/modules/master/service/impl/BuyConfigServiceImpl.java @@ -0,0 +1,29 @@ +package com.peanut.modules.master.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.peanut.common.utils.PageUtils; +import com.peanut.common.utils.Query; +import com.peanut.modules.common.dao.BookBuyConfigDao; +import com.peanut.modules.common.entity.BookBuyConfigEntity; +import com.peanut.modules.master.service.BuyConfigService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.Map; + +@Slf4j +@Service("buyConfigService") +public class BuyConfigServiceImpl extends ServiceImpl implements BuyConfigService { + + @Override + public PageUtils queryPage(Map params) { + IPage page = this.page( + new Query().getPage(params), + new QueryWrapper() + ); + return new PageUtils(page); + } + +} \ No newline at end of file diff --git a/src/main/java/com/peanut/modules/master/service/impl/PayPaymentOrderServiceImpl.java b/src/main/java/com/peanut/modules/master/service/impl/PayPaymentOrderServiceImpl.java new file mode 100644 index 00000000..ecb73a73 --- /dev/null +++ b/src/main/java/com/peanut/modules/master/service/impl/PayPaymentOrderServiceImpl.java @@ -0,0 +1,31 @@ +package com.peanut.modules.master.service.impl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.peanut.common.utils.ExcludeEmptyQueryWrapper; +import com.peanut.common.utils.PageUtils; +import com.peanut.common.utils.Query; +import com.peanut.modules.common.dao.PayPaymentOrderDao; +import com.peanut.modules.common.entity.PayPaymentOrderEntity; +import com.peanut.modules.master.service.PayPaymentOrderService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.Map; + +@Slf4j +@Service("masterPayPaymentOrderService") +public class PayPaymentOrderServiceImpl extends ServiceImpl implements PayPaymentOrderService { + + @Override + public PageUtils queryPage(Map params) { + IPage page = this.page( + new Query().getPage(params), + new ExcludeEmptyQueryWrapper() + .eq("tel",params.get("key")) + .or().like("user_name",params.get("key")).orderByDesc("create_time") + ); + return new PageUtils(page); + } + +} \ No newline at end of file