完成支付、电子面单、模板消息队列等功能
This commit is contained in:
@ -1,32 +1,21 @@
|
||||
package co.yixiang.yshop.module.cart.controller.admin.storecart;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import co.yixiang.yshop.framework.common.pojo.PageResult;
|
||||
import co.yixiang.yshop.framework.common.pojo.CommonResult;
|
||||
import static co.yixiang.yshop.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import co.yixiang.yshop.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import co.yixiang.yshop.framework.operatelog.core.annotations.OperateLog;
|
||||
import static co.yixiang.yshop.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import co.yixiang.yshop.module.cart.controller.admin.storecart.vo.*;
|
||||
import co.yixiang.yshop.module.cart.dal.dataobject.storecart.StoreCartDO;
|
||||
import co.yixiang.yshop.module.cart.convert.storecart.StoreCartConvert;
|
||||
import co.yixiang.yshop.framework.common.pojo.PageResult;
|
||||
import co.yixiang.yshop.module.cart.controller.admin.storecart.vo.StoreCartPageReqVO;
|
||||
import co.yixiang.yshop.module.cart.controller.admin.storecart.vo.StoreCartRespVO;
|
||||
import co.yixiang.yshop.module.cart.service.storecart.StoreCartService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import static co.yixiang.yshop.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 购物车")
|
||||
@RestController
|
||||
@ -37,20 +26,6 @@ public class StoreCartController {
|
||||
@Resource
|
||||
private StoreCartService storeCartService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建购物车")
|
||||
@PreAuthorize("@ss.hasPermission('cart:store-cart:create')")
|
||||
public CommonResult<Long> createStoreCart(@Valid @RequestBody StoreCartCreateReqVO createReqVO) {
|
||||
return success(storeCartService.createStoreCart(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新购物车")
|
||||
@PreAuthorize("@ss.hasPermission('cart:store-cart:update')")
|
||||
public CommonResult<Boolean> updateStoreCart(@Valid @RequestBody StoreCartUpdateReqVO updateReqVO) {
|
||||
storeCartService.updateStoreCart(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除购物车")
|
||||
@ -61,42 +36,15 @@ public class StoreCartController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得购物车")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('cart:store-cart:query')")
|
||||
public CommonResult<StoreCartRespVO> getStoreCart(@RequestParam("id") Long id) {
|
||||
StoreCartDO storeCart = storeCartService.getStoreCart(id);
|
||||
return success(StoreCartConvert.INSTANCE.convert(storeCart));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得购物车列表")
|
||||
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
|
||||
@PreAuthorize("@ss.hasPermission('cart:store-cart:query')")
|
||||
public CommonResult<List<StoreCartRespVO>> getStoreCartList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<StoreCartDO> list = storeCartService.getStoreCartList(ids);
|
||||
return success(StoreCartConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得购物车分页")
|
||||
@PreAuthorize("@ss.hasPermission('cart:store-cart:query')")
|
||||
public CommonResult<PageResult<StoreCartRespVO>> getStoreCartPage(@Valid StoreCartPageReqVO pageVO) {
|
||||
PageResult<StoreCartDO> pageResult = storeCartService.getStoreCartPage(pageVO);
|
||||
return success(StoreCartConvert.INSTANCE.convertPage(pageResult));
|
||||
return success(storeCartService.getStoreCartPage(pageVO));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出购物车 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('cart:store-cart:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportStoreCartExcel(@Valid StoreCartExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<StoreCartDO> list = storeCartService.getStoreCartList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<StoreCartExcelVO> datas = StoreCartConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "购物车.xls", "数据", StoreCartExcelVO.class, datas);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,14 +0,0 @@
|
||||
package co.yixiang.yshop.module.cart.controller.admin.storecart.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 购物车创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class StoreCartCreateReqVO extends StoreCartBaseVO {
|
||||
|
||||
}
|
||||
@ -1,55 +0,0 @@
|
||||
package co.yixiang.yshop.module.cart.controller.admin.storecart.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
|
||||
/**
|
||||
* 购物车 Excel VO
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
@Data
|
||||
public class StoreCartExcelVO {
|
||||
|
||||
@ExcelProperty("购物车表ID")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("用户ID")
|
||||
private Long uid;
|
||||
|
||||
@ExcelProperty("类型")
|
||||
private String type;
|
||||
|
||||
@ExcelProperty("商品ID")
|
||||
private Long productId;
|
||||
|
||||
@ExcelProperty("商品属性")
|
||||
private String productAttrUnique;
|
||||
|
||||
@ExcelProperty("商品数量")
|
||||
private Integer cartNum;
|
||||
|
||||
@ExcelProperty("0 = 未购买 1 = 已购买")
|
||||
private Integer isPay;
|
||||
|
||||
@ExcelProperty("是否为立即购买")
|
||||
private Integer isNew;
|
||||
|
||||
@ExcelProperty("拼团id")
|
||||
private Integer combinationId;
|
||||
|
||||
@ExcelProperty("秒杀产品ID")
|
||||
private Integer seckillId;
|
||||
|
||||
@ExcelProperty("砍价id")
|
||||
private Integer bargainId;
|
||||
|
||||
@ExcelProperty("添加时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@ -1,50 +0,0 @@
|
||||
package co.yixiang.yshop.module.cart.controller.admin.storecart.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import co.yixiang.yshop.framework.common.pojo.PageParam;
|
||||
import java.time.LocalDateTime;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static co.yixiang.yshop.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 购物车 Excel 导出 Request VO,参数和 StoreCartPageReqVO 是一致的")
|
||||
@Data
|
||||
public class StoreCartExportReqVO {
|
||||
|
||||
@Schema(description = "用户ID", example = "10667")
|
||||
private Long uid;
|
||||
|
||||
@Schema(description = "类型", example = "1")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "商品ID", example = "1696")
|
||||
private Long productId;
|
||||
|
||||
@Schema(description = "商品属性")
|
||||
private String productAttrUnique;
|
||||
|
||||
@Schema(description = "商品数量")
|
||||
private Short cartNum;
|
||||
|
||||
@Schema(description = "0 = 未购买 1 = 已购买")
|
||||
private Boolean isPay;
|
||||
|
||||
@Schema(description = "是否为立即购买")
|
||||
private Boolean isNew;
|
||||
|
||||
@Schema(description = "拼团id", example = "13847")
|
||||
private Integer combinationId;
|
||||
|
||||
@Schema(description = "秒杀产品ID", example = "8790")
|
||||
private Integer seckillId;
|
||||
|
||||
@Schema(description = "砍价id", example = "21581")
|
||||
private Integer bargainId;
|
||||
|
||||
@Schema(description = "添加时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
@ -16,4 +16,10 @@ public class StoreCartRespVO extends StoreCartBaseVO {
|
||||
@Schema(description = "添加时间", required = true)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "商品名称", required = true)
|
||||
private String StoreName;
|
||||
|
||||
@Schema(description = "用户昵称", required = true)
|
||||
private String nickname;
|
||||
|
||||
}
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
package co.yixiang.yshop.module.cart.controller.admin.storecart.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 购物车更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class StoreCartUpdateReqVO extends StoreCartBaseVO {
|
||||
|
||||
@Schema(description = "购物车表ID", required = true, example = "11256")
|
||||
@NotNull(message = "购物车表ID不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
||||
@ -20,10 +20,6 @@ public interface StoreCartConvert {
|
||||
|
||||
StoreCartConvert INSTANCE = Mappers.getMapper(StoreCartConvert.class);
|
||||
|
||||
StoreCartDO convert(StoreCartCreateReqVO bean);
|
||||
|
||||
StoreCartDO convert(StoreCartUpdateReqVO bean);
|
||||
|
||||
StoreCartRespVO convert(StoreCartDO bean);
|
||||
|
||||
AppStoreCartQueryVo convert01(StoreCartDO bean);
|
||||
@ -32,6 +28,5 @@ public interface StoreCartConvert {
|
||||
|
||||
PageResult<StoreCartRespVO> convertPage(PageResult<StoreCartDO> page);
|
||||
|
||||
List<StoreCartExcelVO> convertList02(List<StoreCartDO> list);
|
||||
|
||||
}
|
||||
|
||||
@ -35,21 +35,7 @@ public interface StoreCartMapper extends BaseMapperX<StoreCartDO> {
|
||||
.orderByDesc(StoreCartDO::getId));
|
||||
}
|
||||
|
||||
default List<StoreCartDO> selectList(StoreCartExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<StoreCartDO>()
|
||||
.eqIfPresent(StoreCartDO::getUid, reqVO.getUid())
|
||||
.eqIfPresent(StoreCartDO::getType, reqVO.getType())
|
||||
.eqIfPresent(StoreCartDO::getProductId, reqVO.getProductId())
|
||||
.eqIfPresent(StoreCartDO::getProductAttrUnique, reqVO.getProductAttrUnique())
|
||||
.eqIfPresent(StoreCartDO::getCartNum, reqVO.getCartNum())
|
||||
.eqIfPresent(StoreCartDO::getIsPay, reqVO.getIsPay())
|
||||
.eqIfPresent(StoreCartDO::getIsNew, reqVO.getIsNew())
|
||||
.eqIfPresent(StoreCartDO::getCombinationId, reqVO.getCombinationId())
|
||||
.eqIfPresent(StoreCartDO::getSeckillId, reqVO.getSeckillId())
|
||||
.eqIfPresent(StoreCartDO::getBargainId, reqVO.getBargainId())
|
||||
.betweenIfPresent(StoreCartDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(StoreCartDO::getId));
|
||||
}
|
||||
|
||||
|
||||
@Select("select IFNULL(sum(cart_num),0) from yshop_store_cart " +
|
||||
"where is_pay=0 and deleted=0 and is_new=0 and uid=#{uid}")
|
||||
|
||||
@ -1,10 +1,8 @@
|
||||
package co.yixiang.yshop.module.cart.service.storecart;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import co.yixiang.yshop.module.cart.controller.admin.storecart.vo.*;
|
||||
import co.yixiang.yshop.module.cart.dal.dataobject.storecart.StoreCartDO;
|
||||
import co.yixiang.yshop.framework.common.pojo.PageResult;
|
||||
import co.yixiang.yshop.module.cart.controller.admin.storecart.vo.StoreCartPageReqVO;
|
||||
import co.yixiang.yshop.module.cart.controller.admin.storecart.vo.StoreCartRespVO;
|
||||
|
||||
/**
|
||||
* 购物车 Service 接口
|
||||
@ -13,20 +11,6 @@ import co.yixiang.yshop.framework.common.pojo.PageResult;
|
||||
*/
|
||||
public interface StoreCartService {
|
||||
|
||||
/**
|
||||
* 创建购物车
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createStoreCart(@Valid StoreCartCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新购物车
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateStoreCart(@Valid StoreCartUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除购物车
|
||||
@ -35,21 +19,6 @@ public interface StoreCartService {
|
||||
*/
|
||||
void deleteStoreCart(Long id);
|
||||
|
||||
/**
|
||||
* 获得购物车
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 购物车
|
||||
*/
|
||||
StoreCartDO getStoreCart(Long id);
|
||||
|
||||
/**
|
||||
* 获得购物车列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 购物车列表
|
||||
*/
|
||||
List<StoreCartDO> getStoreCartList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得购物车分页
|
||||
@ -57,14 +26,8 @@ public interface StoreCartService {
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 购物车分页
|
||||
*/
|
||||
PageResult<StoreCartDO> getStoreCartPage(StoreCartPageReqVO pageReqVO);
|
||||
PageResult<StoreCartRespVO> getStoreCartPage(StoreCartPageReqVO pageReqVO);
|
||||
|
||||
|
||||
/**
|
||||
* 获得购物车列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 购物车列表
|
||||
*/
|
||||
List<StoreCartDO> getStoreCartList(StoreCartExportReqVO exportReqVO);
|
||||
|
||||
}
|
||||
|
||||
@ -1,9 +1,14 @@
|
||||
package co.yixiang.yshop.module.cart.service.storecart;
|
||||
|
||||
import co.yixiang.yshop.module.member.dal.dataobject.user.MemberUserDO;
|
||||
import co.yixiang.yshop.module.member.dal.mysql.user.MemberUserMapper;
|
||||
import co.yixiang.yshop.module.product.dal.dataobject.storeproduct.StoreProductDO;
|
||||
import co.yixiang.yshop.module.product.dal.mysql.storeproduct.StoreProductMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.lang.reflect.Member;
|
||||
import java.util.*;
|
||||
import co.yixiang.yshop.module.cart.controller.admin.storecart.vo.*;
|
||||
import co.yixiang.yshop.module.cart.dal.dataobject.storecart.StoreCartDO;
|
||||
@ -26,24 +31,11 @@ public class StoreCartServiceImpl implements StoreCartService {
|
||||
|
||||
@Resource
|
||||
private StoreCartMapper storeCartMapper;
|
||||
@Resource
|
||||
private StoreProductMapper storeProductMapper;
|
||||
@Resource
|
||||
private MemberUserMapper memberUserMapper;
|
||||
|
||||
@Override
|
||||
public Long createStoreCart(StoreCartCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
StoreCartDO storeCart = StoreCartConvert.INSTANCE.convert(createReqVO);
|
||||
storeCartMapper.insert(storeCart);
|
||||
// 返回
|
||||
return storeCart.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStoreCart(StoreCartUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateStoreCartExists(updateReqVO.getId());
|
||||
// 更新
|
||||
StoreCartDO updateObj = StoreCartConvert.INSTANCE.convert(updateReqVO);
|
||||
storeCartMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteStoreCart(Long id) {
|
||||
@ -59,24 +51,20 @@ public class StoreCartServiceImpl implements StoreCartService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public StoreCartDO getStoreCart(Long id) {
|
||||
return storeCartMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoreCartDO> getStoreCartList(Collection<Long> ids) {
|
||||
return storeCartMapper.selectBatchIds(ids);
|
||||
public PageResult<StoreCartRespVO> getStoreCartPage(StoreCartPageReqVO pageReqVO) {
|
||||
PageResult<StoreCartDO> pageResult = storeCartMapper.selectPage(pageReqVO);
|
||||
PageResult<StoreCartRespVO> storeCartRespVO = StoreCartConvert.INSTANCE.convertPage(pageResult);
|
||||
for (StoreCartRespVO storeCartRespVO1 : storeCartRespVO.getList()) {
|
||||
StoreProductDO storeProductDO = storeProductMapper.selectById(storeCartRespVO1.getProductId());
|
||||
MemberUserDO memberUserDO = memberUserMapper.selectById(storeCartRespVO1.getUid());
|
||||
storeCartRespVO1.setNickname(memberUserDO.getNickname());
|
||||
storeCartRespVO1.setStoreName(storeProductDO.getStoreName());
|
||||
}
|
||||
return storeCartRespVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<StoreCartDO> getStoreCartPage(StoreCartPageReqVO pageReqVO) {
|
||||
return storeCartMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoreCartDO> getStoreCartList(StoreCartExportReqVO exportReqVO) {
|
||||
return storeCartMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
文档可见:https://www.yixiang.co/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user