refactor(mall): 重构活动订单核销接口并添加取消订单功能
- 重构了 AdminHappyActivityServiceImpl 和 AdminVotesActivityCategoryController 中的 checkOrder 方法,简化参数传递
- 新增 ApiExpireOrderDto 类用于处理取消订单请求
- 在 ApiHappyActivityOrderController 中添加 expireOrder 方法处理取消订单
- 在 HappyActivityService 接口中添加 expireOrder 方法
- 实现 HappyActivityServiceImpl 中的 expireOrder 方法,用于更新订单状态和活动剩余名额
- 更新前端 orderList.html 文件中的订单核销逻辑
7 files modified
1 files added
| | |
| | | */ |
| | | @PostMapping("checkOrder") |
| | | @ControllerEndpoint(operation = "订单-手动核销", exceptionMessage = "操作失败") |
| | | public FebsResponse checkOrder(@RequestBody AdminHappyActivityCheckOrderDto dto) { |
| | | public FebsResponse checkOrder(@RequestBody List<Long> dto) { |
| | | |
| | | return adminHappyActivityService.checkOrder(dto); |
| | | } |
| | |
| | | import cc.mrbird.febs.mall.dto.*; |
| | | import cc.mrbird.febs.mall.dto.activity.ApiActivityOrderListDto; |
| | | import cc.mrbird.febs.mall.dto.activity.ApiCheckOrderDto; |
| | | import cc.mrbird.febs.mall.dto.activity.ApiExpireOrderDto; |
| | | import cc.mrbird.febs.mall.dto.activity.ApiPayOrderAddCommentDto; |
| | | import cc.mrbird.febs.mall.service.HappyActivityService; |
| | | import cc.mrbird.febs.mall.vo.*; |
| | |
| | | return happyActivityService.connectSave(dto); |
| | | } |
| | | |
| | | @ApiOperation(value = "活动报名-报名-取消订单", notes = "活动报名-报名-创建订单") |
| | | @PostMapping(value = "/expireOrder") |
| | | public FebsResponse expireOrder(@RequestBody @Validated ApiExpireOrderDto dto) { |
| | | |
| | | return happyActivityService.expireOrder(dto); |
| | | } |
| | | |
| | | @ApiOperation(value = "活动报名-报名-创建订单", notes = "活动报名-报名-创建订单") |
| | | @PostMapping(value = "/createOrder") |
| | | public FebsResponse createOrder(@RequestBody @Validated ApiCreateOrderDto dto) { |
New file |
| | |
| | | package cc.mrbird.febs.mall.dto.activity; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | @ApiModel(value = "ApiExpireOrderDto", description = "参数") |
| | | public class ApiExpireOrderDto { |
| | | |
| | | |
| | | @ApiModelProperty(value = "订单ID", example = "1") |
| | | private List<Long> ids; |
| | | } |
| | |
| | | |
| | | FebsResponse connectSave(ApiConnectSaveDto dto); |
| | | |
| | | FebsResponse expireOrder(ApiExpireOrderDto dto); |
| | | |
| | | FebsResponse createOrder(ApiCreateOrderDto dto); |
| | | |
| | | FebsResponse payOrder(ApiPayOrderDto dto); |
| | |
| | | |
| | | IPage<HappyActivityOrder> activityOrderList(AdminHappyActivityOrderDto dto, QueryRequest request); |
| | | |
| | | FebsResponse checkOrder(AdminHappyActivityCheckOrderDto dto); |
| | | FebsResponse checkOrder(List<Long> dto); |
| | | |
| | | FebsResponse activityOrderDel(Long id); |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse checkOrder(AdminHappyActivityCheckOrderDto dto) { |
| | | public FebsResponse checkOrder(List<Long> ids) { |
| | | |
| | | List<Long> ids = dto.getIds(); |
| | | if (CollUtil.isEmpty(ids)){ |
| | | return new FebsResponse().fail().message("请选择需要核销的订单"); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse expireOrder(ApiExpireOrderDto dto) { |
| | | if(CollUtil.isEmpty(dto.getIds())){ |
| | | throw new FebsException("请选择订单"); |
| | | } |
| | | |
| | | dto.getIds().forEach(id -> { |
| | | HappyActivityOrder happyActivityOrder = happyActivityOrderMapper.selectById(id); |
| | | if(ObjectUtil.isNotEmpty(happyActivityOrder)){ |
| | | Long activityId = happyActivityOrder.getActivityId(); |
| | | Integer numCnt = happyActivityOrder.getNumCnt(); |
| | | this.baseMapper.updateHappyActivitySurplusCnt(activityId,numCnt); |
| | | |
| | | happyActivityOrder.setState(StateUpDownEnum.ORDER_STATE_OVERTIME.getCode()); |
| | | happyActivityOrderMapper.updateById(happyActivityOrder); |
| | | } |
| | | }); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse createOrder(ApiCreateOrderDto dto) { |
| | | Long memberId = LoginUserUtil.getLoginUser().getId(); |
| | | if(CollUtil.isEmpty(dto.getConnectIds())){ |
| | |
| | | dataType: 'json', |
| | | headers: { 'Content-Type': 'application/json;charset=utf-8' }, |
| | | traditional: true, |
| | | data: JSON.stringify('{ids:'+ids+'}'), // 确保传递的是 JSON 格式 |
| | | data: JSON.stringify(ids), // 确保传递的是 JSON 格式 |
| | | success: function (response) { |
| | | if (response.code === 200) { |
| | | successCallback(response); |