1
This commit is contained in:
parent
571f8b7f63
commit
b396048b98
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
@ -28,39 +29,48 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 会员卡Controller
|
* 会员卡Controller
|
||||||
*
|
*
|
||||||
* @author vinjor-m
|
* @author vinjor-m
|
||||||
* @date 2025-03-17
|
* @date 2025-03-17
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/base/card")
|
@RequestMapping("/base/card")
|
||||||
public class BaseCardController extends BaseController
|
public class BaseCardController extends BaseController {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IBaseCardService baseCardService;
|
private IBaseCardService baseCardService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询会员卡列表
|
* 查询会员卡列表
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('base:card:list')")
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public AjaxResult list(BaseCard baseCard,
|
public AjaxResult list(BaseCard baseCard,
|
||||||
@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
||||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize)
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||||
{
|
|
||||||
Page<BaseCard> page = new Page<>(pageNum, pageSize);
|
Page<BaseCard> page = new Page<>(pageNum, pageSize);
|
||||||
IPage<BaseCard> list = baseCardService.queryListPage(baseCard,page);
|
IPage<BaseCard> list = baseCardService.queryListPage(baseCard, page);
|
||||||
return success(list);
|
return success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员卡数组
|
||||||
|
*
|
||||||
|
* @param userType 用户类型
|
||||||
|
* @return com.ruoyi.common.core.domain.AjaxResult
|
||||||
|
* @author PQZ
|
||||||
|
* @date 10:15 2025/4/7
|
||||||
|
**/
|
||||||
|
@GetMapping("/baseCardList")
|
||||||
|
public AjaxResult baseCardList(@RequestParam(name = "userType") String userType) {
|
||||||
|
return success(baseCardService.baseCardList(userType));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出会员卡列表
|
* 导出会员卡列表
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('base:card:export')")
|
|
||||||
@Log(title = "会员卡", businessType = BusinessType.EXPORT)
|
@Log(title = "会员卡", businessType = BusinessType.EXPORT)
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, BaseCard baseCard)
|
public void export(HttpServletResponse response, BaseCard baseCard) {
|
||||||
{
|
|
||||||
List<BaseCard> list = baseCardService.list();
|
List<BaseCard> list = baseCardService.list();
|
||||||
ExcelUtil<BaseCard> util = new ExcelUtil<BaseCard>(BaseCard.class);
|
ExcelUtil<BaseCard> util = new ExcelUtil<BaseCard>(BaseCard.class);
|
||||||
util.exportExcel(response, list, "会员卡数据");
|
util.exportExcel(response, list, "会员卡数据");
|
||||||
@ -69,43 +79,35 @@ public class BaseCardController extends BaseController
|
|||||||
/**
|
/**
|
||||||
* 获取会员卡详细信息
|
* 获取会员卡详细信息
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('base:card:query')")
|
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
public AjaxResult getInfo(@PathVariable("id") String id)
|
public AjaxResult getInfo(@PathVariable("id") String id) {
|
||||||
{
|
|
||||||
return success(baseCardService.getById(id));
|
return success(baseCardService.getById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增会员卡
|
* 新增会员卡
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('base:card:add')")
|
|
||||||
@Log(title = "会员卡", businessType = BusinessType.INSERT)
|
@Log(title = "会员卡", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@RequestBody BaseCard baseCard)
|
public AjaxResult add(@RequestBody BaseCard baseCard) {
|
||||||
{
|
|
||||||
return toAjax(baseCardService.save(baseCard));
|
return toAjax(baseCardService.save(baseCard));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改会员卡
|
* 修改会员卡
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('base:card:edit')")
|
|
||||||
@Log(title = "会员卡", businessType = BusinessType.UPDATE)
|
@Log(title = "会员卡", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@RequestBody BaseCard baseCard)
|
public AjaxResult edit(@RequestBody BaseCard baseCard) {
|
||||||
{
|
|
||||||
return toAjax(baseCardService.updateById(baseCard));
|
return toAjax(baseCardService.updateById(baseCard));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除会员卡
|
* 删除会员卡
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('base:card:remove')")
|
|
||||||
@Log(title = "会员卡", businessType = BusinessType.DELETE)
|
@Log(title = "会员卡", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{ids}")
|
@DeleteMapping("/{ids}")
|
||||||
public AjaxResult remove(@PathVariable String[] ids)
|
public AjaxResult remove(@PathVariable String[] ids) {
|
||||||
{
|
|
||||||
List<String> list = new ArrayList<>(Arrays.asList(ids));
|
List<String> list = new ArrayList<>(Arrays.asList(ids));
|
||||||
return toAjax(baseCardService.removeByIds(list));
|
return toAjax(baseCardService.removeByIds(list));
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
@ -28,14 +29,13 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 会员权益Controller
|
* 会员权益Controller
|
||||||
*
|
*
|
||||||
* @author vinjor-m
|
* @author vinjor-m
|
||||||
* @date 2025-03-17
|
* @date 2025-03-17
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/base/rights")
|
@RequestMapping("/base/rights")
|
||||||
public class BaseRightsController extends BaseController
|
public class BaseRightsController extends BaseController {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IBaseRightsService baseRightsService;
|
private IBaseRightsService baseRightsService;
|
||||||
|
|
||||||
@ -45,22 +45,34 @@ public class BaseRightsController extends BaseController
|
|||||||
@PreAuthorize("@ss.hasPermi('base:rights:list')")
|
@PreAuthorize("@ss.hasPermi('base:rights:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public AjaxResult list(BaseRights baseRights,
|
public AjaxResult list(BaseRights baseRights,
|
||||||
@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
||||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize)
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||||
{
|
|
||||||
Page<BaseRights> page = new Page<>(pageNum, pageSize);
|
Page<BaseRights> page = new Page<>(pageNum, pageSize);
|
||||||
IPage<BaseRights> list = baseRightsService.queryListPage(baseRights,page);
|
IPage<BaseRights> list = baseRightsService.queryListPage(baseRights, page);
|
||||||
return success(list);
|
return success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 权益对比数组
|
||||||
|
*
|
||||||
|
* @param userType 用户类型
|
||||||
|
* @return com.ruoyi.common.core.domain.AjaxResult
|
||||||
|
* @author PQZ
|
||||||
|
* @date 10:15 2025/4/7
|
||||||
|
**/
|
||||||
|
@GetMapping("/rightList")
|
||||||
|
public AjaxResult rightList(@RequestParam(name = "userType") String userType) {
|
||||||
|
return success(baseRightsService.rightList(userType));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出会员权益列表
|
* 导出会员权益列表
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('base:rights:export')")
|
@PreAuthorize("@ss.hasPermi('base:rights:export')")
|
||||||
@Log(title = "会员权益", businessType = BusinessType.EXPORT)
|
@Log(title = "会员权益", businessType = BusinessType.EXPORT)
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, BaseRights baseRights)
|
public void export(HttpServletResponse response, BaseRights baseRights) {
|
||||||
{
|
|
||||||
List<BaseRights> list = baseRightsService.list();
|
List<BaseRights> list = baseRightsService.list();
|
||||||
ExcelUtil<BaseRights> util = new ExcelUtil<BaseRights>(BaseRights.class);
|
ExcelUtil<BaseRights> util = new ExcelUtil<BaseRights>(BaseRights.class);
|
||||||
util.exportExcel(response, list, "会员权益数据");
|
util.exportExcel(response, list, "会员权益数据");
|
||||||
@ -71,8 +83,7 @@ public class BaseRightsController extends BaseController
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('base:rights:query')")
|
@PreAuthorize("@ss.hasPermi('base:rights:query')")
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
public AjaxResult getInfo(@PathVariable("id") String id)
|
public AjaxResult getInfo(@PathVariable("id") String id) {
|
||||||
{
|
|
||||||
return success(baseRightsService.getById(id));
|
return success(baseRightsService.getById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,8 +93,7 @@ public class BaseRightsController extends BaseController
|
|||||||
@PreAuthorize("@ss.hasPermi('base:rights:add')")
|
@PreAuthorize("@ss.hasPermi('base:rights:add')")
|
||||||
@Log(title = "会员权益", businessType = BusinessType.INSERT)
|
@Log(title = "会员权益", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@RequestBody BaseRights baseRights)
|
public AjaxResult add(@RequestBody BaseRights baseRights) {
|
||||||
{
|
|
||||||
return toAjax(baseRightsService.save(baseRights));
|
return toAjax(baseRightsService.save(baseRights));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,8 +103,7 @@ public class BaseRightsController extends BaseController
|
|||||||
@PreAuthorize("@ss.hasPermi('base:rights:edit')")
|
@PreAuthorize("@ss.hasPermi('base:rights:edit')")
|
||||||
@Log(title = "会员权益", businessType = BusinessType.UPDATE)
|
@Log(title = "会员权益", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@RequestBody BaseRights baseRights)
|
public AjaxResult edit(@RequestBody BaseRights baseRights) {
|
||||||
{
|
|
||||||
return toAjax(baseRightsService.updateById(baseRights));
|
return toAjax(baseRightsService.updateById(baseRights));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,9 +112,8 @@ public class BaseRightsController extends BaseController
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('base:rights:remove')")
|
@PreAuthorize("@ss.hasPermi('base:rights:remove')")
|
||||||
@Log(title = "会员权益", businessType = BusinessType.DELETE)
|
@Log(title = "会员权益", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{ids}")
|
@DeleteMapping("/{ids}")
|
||||||
public AjaxResult remove(@PathVariable String[] ids)
|
public AjaxResult remove(@PathVariable String[] ids) {
|
||||||
{
|
|
||||||
List<String> list = new ArrayList<>(Arrays.asList(ids));
|
List<String> list = new ArrayList<>(Arrays.asList(ids));
|
||||||
return toAjax(baseRightsService.removeByIds(list));
|
return toAjax(baseRightsService.removeByIds(list));
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,32 @@
|
|||||||
package com.ruoyi.base.mapper;
|
package com.ruoyi.base.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.ruoyi.base.domain.BaseRights;
|
import com.ruoyi.base.domain.BaseRights;
|
||||||
|
import com.ruoyi.base.vo.CardRightsVO;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 会员权益Mapper接口
|
* 会员权益Mapper接口
|
||||||
*
|
*
|
||||||
* @author vinjor-m
|
* @author vinjor-m
|
||||||
* @date 2025-03-17
|
* @date 2025-03-17
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface BaseRightsMapper extends BaseMapper<BaseRights>
|
public interface BaseRightsMapper extends BaseMapper<BaseRights> {
|
||||||
{
|
|
||||||
IPage<BaseRights> queryListPage(@Param("entity") BaseRights entity, Page<BaseRights> page);
|
IPage<BaseRights> queryListPage(@Param("entity") BaseRights entity, Page<BaseRights> page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询会员权益
|
||||||
|
*
|
||||||
|
* @param userType 用户类型
|
||||||
|
* @return java.util.List<com.ruoyi.base.vo.CardRightsVO>
|
||||||
|
* @author PQZ
|
||||||
|
* @date 11:35 2025/4/7
|
||||||
|
**/
|
||||||
|
List<CardRightsVO> rightList(@Param("userType")String userType);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
package com.ruoyi.base.service;
|
package com.ruoyi.base.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.ruoyi.base.domain.BaseCard;
|
import com.ruoyi.base.domain.BaseCard;
|
||||||
import com.ruoyi.base.vo.BaseCardVO;
|
import com.ruoyi.base.vo.BaseCardVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 会员卡Service接口
|
* 会员卡Service接口
|
||||||
*
|
*
|
||||||
@ -24,4 +27,22 @@ public interface IBaseCardService extends IService<BaseCard> {
|
|||||||
* @date 16:25 2025/3/26
|
* @date 16:25 2025/3/26
|
||||||
**/
|
**/
|
||||||
BaseCardVO queryByCardId(String cardId);
|
BaseCardVO queryByCardId(String cardId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员卡数组
|
||||||
|
* @author PQZ
|
||||||
|
* @date 10:17 2025/4/7
|
||||||
|
* @param userType 用户类型
|
||||||
|
* @return java.util.List<com.ruoyi.base.domain.BaseCard>
|
||||||
|
**/
|
||||||
|
JSONArray baseCardList(String userType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过userType查询会员卡
|
||||||
|
* @author PQZ
|
||||||
|
* @date 15:12 2025/4/7
|
||||||
|
* @param userType 用户类型
|
||||||
|
* @return java.util.List<com.ruoyi.base.domain.BaseCard>
|
||||||
|
**/
|
||||||
|
List<BaseCard> listByUserType(String userType);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
package com.ruoyi.base.service;
|
package com.ruoyi.base.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.ruoyi.base.domain.BaseRights;
|
import com.ruoyi.base.domain.BaseRights;
|
||||||
|
import com.ruoyi.base.vo.CardRightsVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 会员权益Service接口
|
* 会员权益Service接口
|
||||||
@ -13,4 +17,14 @@ import com.ruoyi.base.domain.BaseRights;
|
|||||||
*/
|
*/
|
||||||
public interface IBaseRightsService extends IService<BaseRights> {
|
public interface IBaseRightsService extends IService<BaseRights> {
|
||||||
IPage<BaseRights> queryListPage(BaseRights pageReqVO, Page<BaseRights> page);
|
IPage<BaseRights> queryListPage(BaseRights pageReqVO, Page<BaseRights> page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询会员权益
|
||||||
|
*
|
||||||
|
* @param userType 用户类型
|
||||||
|
* @return java.util.List<com.ruoyi.base.vo.CardRightsVO>
|
||||||
|
* @author PQZ
|
||||||
|
* @date 11:33 2025/4/7
|
||||||
|
**/
|
||||||
|
JSONObject rightList(String userType);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package com.ruoyi.base.service.impl;
|
package com.ruoyi.base.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
@ -11,11 +14,14 @@ import com.ruoyi.base.service.IBaseCardRightsService;
|
|||||||
import com.ruoyi.base.service.IBaseCardService;
|
import com.ruoyi.base.service.IBaseCardService;
|
||||||
import com.ruoyi.base.vo.BaseCardVO;
|
import com.ruoyi.base.vo.BaseCardVO;
|
||||||
import com.ruoyi.base.vo.CardRightsVO;
|
import com.ruoyi.base.vo.CardRightsVO;
|
||||||
|
import com.ruoyi.common.core.domain.DlBaseEntity;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,4 +60,74 @@ public class BaseCardServiceImpl extends ServiceImpl<BaseCardMapper,BaseCard> i
|
|||||||
cardVO.setRights(rights);
|
cardVO.setRights(rights);
|
||||||
return cardVO;
|
return cardVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员卡数组
|
||||||
|
*
|
||||||
|
* @param userType 用户类型
|
||||||
|
* @return java.util.List<com.ruoyi.base.domain.BaseCard>
|
||||||
|
* @author PQZ
|
||||||
|
* @date 10:17 2025/4/7
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public JSONArray baseCardList(String userType) {
|
||||||
|
LambdaQueryWrapper<BaseCard> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
lambdaQueryWrapper.eq(DlBaseEntity::getDelFlag,0)
|
||||||
|
.eq(BaseCard::getUserType,userType)
|
||||||
|
.eq(BaseCard::getIsSystem,0)
|
||||||
|
.orderByAsc(BaseCard::getSort);
|
||||||
|
List<BaseCard> list = list(lambdaQueryWrapper);
|
||||||
|
JSONArray resultArray = new JSONArray();
|
||||||
|
for (BaseCard card : list) {
|
||||||
|
JSONObject object = new JSONObject();
|
||||||
|
|
||||||
|
object.put("id",card.getId());
|
||||||
|
object.put("cardName",card.getCardName());
|
||||||
|
object.put("image",card.getImage());
|
||||||
|
|
||||||
|
JSONArray array = new JSONArray();
|
||||||
|
JSONObject yearObject = new JSONObject();
|
||||||
|
yearObject.put("title","年付会员");
|
||||||
|
yearObject.put("price",card.getYearPrice());
|
||||||
|
yearObject.put("dayPrice",card.getYearPrice().divide(new BigDecimal(365), RoundingMode.HALF_UP));
|
||||||
|
yearObject.put("isHot",true);
|
||||||
|
array.add(yearObject);
|
||||||
|
|
||||||
|
JSONObject querterObject = new JSONObject();
|
||||||
|
querterObject.put("title","季付会员");
|
||||||
|
querterObject.put("price",card.getQuarterPrice());
|
||||||
|
querterObject.put("dayPrice",card.getQuarterPrice().divide(new BigDecimal(121), RoundingMode.HALF_UP));
|
||||||
|
querterObject.put("isHot",false);
|
||||||
|
array.add(querterObject);
|
||||||
|
|
||||||
|
JSONObject monthPrice = new JSONObject();
|
||||||
|
monthPrice.put("title","月付会员");
|
||||||
|
monthPrice.put("price",card.getMonthPrice());
|
||||||
|
monthPrice.put("dayPrice",card.getMonthPrice().divide(new BigDecimal(30), RoundingMode.HALF_UP));
|
||||||
|
monthPrice.put("isHot",false);
|
||||||
|
array.add(monthPrice);
|
||||||
|
|
||||||
|
object.put("priceList",array);
|
||||||
|
resultArray.add(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过userType查询会员卡
|
||||||
|
*
|
||||||
|
* @param userType 用户类型
|
||||||
|
* @return java.util.List<com.ruoyi.base.domain.BaseCard>
|
||||||
|
* @author PQZ
|
||||||
|
* @date 15:12 2025/4/7
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public List<BaseCard> listByUserType(String userType) {
|
||||||
|
LambdaQueryWrapper<BaseCard> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
lambdaQueryWrapper.eq(DlBaseEntity::getDelFlag,0)
|
||||||
|
.eq(BaseCard::getUserType,userType)
|
||||||
|
.orderByAsc(BaseCard::getSort);
|
||||||
|
return list(lambdaQueryWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,24 @@
|
|||||||
package com.ruoyi.base.service.impl;
|
package com.ruoyi.base.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.ruoyi.base.domain.BaseCard;
|
||||||
|
import com.ruoyi.base.domain.BaseRights;
|
||||||
|
import com.ruoyi.base.mapper.BaseRightsMapper;
|
||||||
|
import com.ruoyi.base.service.IBaseCardService;
|
||||||
|
import com.ruoyi.base.service.IBaseRightsService;
|
||||||
|
import com.ruoyi.base.vo.CardRightsVO;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.ruoyi.base.mapper.BaseRightsMapper;
|
import javax.annotation.Resource;
|
||||||
import com.ruoyi.base.domain.BaseRights;
|
import java.util.ArrayList;
|
||||||
import com.ruoyi.base.service.IBaseRightsService;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 会员权益Service业务层处理
|
* 会员权益Service业务层处理
|
||||||
@ -22,9 +31,63 @@ public class BaseRightsServiceImpl extends ServiceImpl<BaseRightsMapper,BaseRigh
|
|||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
private BaseRightsMapper baseRightsMapper;
|
private BaseRightsMapper baseRightsMapper;
|
||||||
|
@Resource
|
||||||
|
private IBaseCardService cardService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<BaseRights> queryListPage(BaseRights pageReqVO, Page<BaseRights> page) {
|
public IPage<BaseRights> queryListPage(BaseRights pageReqVO, Page<BaseRights> page) {
|
||||||
return baseRightsMapper.queryListPage(pageReqVO, page);
|
return baseRightsMapper.queryListPage(pageReqVO, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询会员权益
|
||||||
|
*
|
||||||
|
* @param userType 用户类型
|
||||||
|
* @return java.util.List<com.ruoyi.base.vo.CardRightsVO>
|
||||||
|
* @author PQZ
|
||||||
|
* @date 11:33 2025/4/7
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public JSONObject rightList(String userType) {
|
||||||
|
JSONObject resultObj = new JSONObject();
|
||||||
|
//根据用户类型查询会员卡
|
||||||
|
List<BaseCard> cards = cardService.listByUserType(userType);
|
||||||
|
JSONArray cardList = new JSONArray();
|
||||||
|
for (BaseCard card : cards) {
|
||||||
|
JSONObject cardObj = new JSONObject();
|
||||||
|
cardObj.put("id",card.getId());
|
||||||
|
cardObj.put("cardName",card.getCardName());
|
||||||
|
cardList.add(cardObj);
|
||||||
|
}
|
||||||
|
resultObj.put("cardList",cardList);
|
||||||
|
//查询权益
|
||||||
|
List<CardRightsVO> list = baseRightsMapper.rightList(userType);
|
||||||
|
// 按照 id 分组
|
||||||
|
Map<String, List<CardRightsVO>> groupedById = list.stream()
|
||||||
|
.collect(Collectors.groupingBy(CardRightsVO::getId));
|
||||||
|
// 按照 id 去重
|
||||||
|
List<CardRightsVO> uniqueList = new ArrayList<>(list.stream()
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
CardRightsVO::getId,
|
||||||
|
cardRights -> cardRights,
|
||||||
|
(existing, replacement) -> existing
|
||||||
|
))
|
||||||
|
.values());
|
||||||
|
JSONArray array = new JSONArray();
|
||||||
|
for (CardRightsVO item : uniqueList) {
|
||||||
|
JSONObject itemObj = new JSONObject();
|
||||||
|
JSONObject cardRights = new JSONObject();
|
||||||
|
itemObj.put("name",item.getName());
|
||||||
|
itemObj.put("rightsType",item.getRightsType());
|
||||||
|
List<CardRightsVO> rightsList = groupedById.get(item.getId());
|
||||||
|
for (CardRightsVO rightsItem : rightsList) {
|
||||||
|
cardRights.put(rightsItem.getCardId(),rightsItem.getRightsValue());
|
||||||
|
}
|
||||||
|
itemObj.put("cardRights",cardRights);
|
||||||
|
array.add(itemObj);
|
||||||
|
}
|
||||||
|
resultObj.put("rightsList",array);
|
||||||
|
return resultObj;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,4 +16,6 @@ public class CardRightsVO extends BaseRights {
|
|||||||
private String cardId;
|
private String cardId;
|
||||||
/** 权益值 */
|
/** 权益值 */
|
||||||
private Integer rightsValue;
|
private Integer rightsValue;
|
||||||
|
/** 会员卡名称*/
|
||||||
|
private String cardName;
|
||||||
}
|
}
|
||||||
|
@ -37,4 +37,21 @@ del_flag=0
|
|||||||
</where>
|
</where>
|
||||||
order by user_type,sort asc,create_time asc
|
order by user_type,sort asc,create_time asc
|
||||||
</select>
|
</select>
|
||||||
|
<select id="rightList" resultType="com.ruoyi.base.vo.CardRightsVO">
|
||||||
|
SELECT
|
||||||
|
main.id AS id,
|
||||||
|
main.`name` AS name,
|
||||||
|
main.rights_type as rightsType,
|
||||||
|
dbcr.rights_value AS rightsValue,
|
||||||
|
dbcr.card_id AS cardId,
|
||||||
|
dbc.card_name AS cardName
|
||||||
|
FROM
|
||||||
|
dl_base_rights main
|
||||||
|
LEFT JOIN dl_base_card_rights dbcr ON dbcr.rights_id = main.id AND dbcr.del_flag = 0
|
||||||
|
LEFT JOIN dl_base_card dbc ON dbcr.card_id = dbc.id AND dbc.del_flag = 0
|
||||||
|
WHERE
|
||||||
|
main.user_type = #{userType}
|
||||||
|
AND main.del_flag = 0
|
||||||
|
ORDER BY dbc.sort,main.sort ASC
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
Loading…
Reference in New Issue
Block a user