退款
This commit is contained in:
@ -89,6 +89,12 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode APP_UP_NOT_EXISTS = new ErrorCode(1_007_902_001, "app更新不存在");
|
||||
|
||||
ErrorCode DINING_PLATES_CANNOT_UNBIND = new ErrorCode(1_007_902_002, "餐盘已产生费用,无法解绑");
|
||||
ErrorCode DINING_PLATES_ALREADY = new ErrorCode(1_007_902_002, "餐盘已存在");
|
||||
ErrorCode DINING_PLATES_ALREADY = new ErrorCode(1_007_902_003, "餐盘已存在");
|
||||
|
||||
ErrorCode REFUND_NOT_EXISTS = new ErrorCode(1_007_903_001, "退款审核不存在");
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,95 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.refund;
|
||||
|
||||
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 cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.member.controller.admin.refund.vo.*;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.refund.RefundDO;
|
||||
import cn.iocoder.yudao.module.member.service.refund.RefundService;
|
||||
|
||||
@Tag(name = "管理后台 - 退款审核")
|
||||
@RestController
|
||||
@RequestMapping("/member/refund")
|
||||
@Validated
|
||||
public class RefundController {
|
||||
|
||||
@Resource
|
||||
private RefundService refundService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建退款审核")
|
||||
@PreAuthorize("@ss.hasPermission('member:refund:create')")
|
||||
public CommonResult<Long> createRefund(@Valid @RequestBody RefundSaveReqVO createReqVO) {
|
||||
return success(refundService.createRefund(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新退款审核")
|
||||
@PreAuthorize("@ss.hasPermission('member:refund:update')")
|
||||
public CommonResult<Boolean> updateRefund(@Valid @RequestBody RefundSaveReqVO updateReqVO) {
|
||||
refundService.updateRefund(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除退款审核")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('member:refund:delete')")
|
||||
public CommonResult<Boolean> deleteRefund(@RequestParam("id") Long id) {
|
||||
refundService.deleteRefund(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得退款审核")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('member:refund:query')")
|
||||
public CommonResult<RefundRespVO> getRefund(@RequestParam("id") Long id) {
|
||||
RefundDO refund = refundService.getRefund(id);
|
||||
return success(BeanUtils.toBean(refund, RefundRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得退款审核分页")
|
||||
@PreAuthorize("@ss.hasPermission('member:refund:query')")
|
||||
public CommonResult<PageResult<RefundRespVO>> getRefundPage(@Valid RefundPageReqVO pageReqVO) {
|
||||
PageResult<RefundDO> pageResult = refundService.getRefundPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, RefundRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出退款审核 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('member:refund:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportRefundExcel(@Valid RefundPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<RefundDO> list = refundService.getRefundPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "退款审核.xls", "数据", RefundRespVO.class,
|
||||
BeanUtils.toBean(list, RefundRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.refund.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 退款审核分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class RefundPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "关联订单", example = "14732")
|
||||
private Long orderId;
|
||||
|
||||
@Schema(description = "退款金额")
|
||||
private BigDecimal money;
|
||||
|
||||
@Schema(description = "审核状态", example = "1")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "审核人id", example = "21777")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "审核人", example = "王五")
|
||||
private String userName;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "订单金额")
|
||||
private BigDecimal orderMoney;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.refund.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 退款审核 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class RefundRespVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "20066")
|
||||
@ExcelProperty("主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "关联订单", example = "14732")
|
||||
@ExcelProperty("关联订单")
|
||||
private Long orderId;
|
||||
|
||||
@Schema(description = "退款金额")
|
||||
@ExcelProperty("退款金额")
|
||||
private BigDecimal money;
|
||||
|
||||
@Schema(description = "审核状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("审核状态")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "审核人id", example = "21777")
|
||||
@ExcelProperty("审核人id")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "审核人", example = "王五")
|
||||
@ExcelProperty("审核人")
|
||||
private String userName;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "订单金额")
|
||||
private BigDecimal orderMoney;
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.refund.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Schema(description = "管理后台 - 退款审核新增/修改 Request VO")
|
||||
@Data
|
||||
public class RefundSaveReqVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "20066")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "关联订单", example = "14732")
|
||||
private Long orderId;
|
||||
|
||||
@Schema(description = "退款金额")
|
||||
@NotNull(message = "退款金额不能为空")
|
||||
private BigDecimal money;
|
||||
|
||||
@Schema(description = "审核状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotEmpty(message = "审核状态不能为空")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "申请人id", example = "21777")
|
||||
@NotNull(message = "申请人id不能为空")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "审核人", example = "王五")
|
||||
private String userName;
|
||||
|
||||
}
|
@ -58,4 +58,7 @@ public class AppOrderRespVO {
|
||||
@ExcelProperty("完结时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@Schema(description = "退款状态")
|
||||
private String refundStatus;
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.member.controller.app.refund;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.member.controller.app.refund.vo.AppRefundSaveReqVO;
|
||||
import cn.iocoder.yudao.module.member.service.refund.RefundService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "用户App - 退款审核")
|
||||
@RestController
|
||||
@RequestMapping("/member/refund")
|
||||
@Validated
|
||||
public class AppRefundController {
|
||||
|
||||
@Resource
|
||||
private RefundService refundService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建退款审核")
|
||||
public CommonResult<Long> createRefund(@Valid @RequestBody AppRefundSaveReqVO createReqVO) {
|
||||
return success(refundService.createAppRefund(createReqVO));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.module.member.controller.app.refund.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Schema(description = "管理后台 - 退款审核新增/修改 Request VO")
|
||||
@Data
|
||||
public class AppRefundSaveReqVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "20066")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "关联订单", example = "14732")
|
||||
@NotNull(message = "关联订单不能为空")
|
||||
private Long orderId;
|
||||
|
||||
@Schema(description = "退款金额")
|
||||
private BigDecimal orderMoney;
|
||||
|
||||
@Schema(description = "审核状态(1:待审核)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "申请人ID", example = "21777")
|
||||
@NotNull(message = "申请人ID不能为空")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "审核人", example = "王五")
|
||||
private String userName;
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package cn.iocoder.yudao.module.member.dal.dataobject.refund;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 退款审核 DO
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@TableName("member_refund")
|
||||
@KeySequence("member_refund_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class RefundDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 关联订单
|
||||
*/
|
||||
private Long orderId;
|
||||
/**
|
||||
* 退款金额
|
||||
*/
|
||||
private BigDecimal money;
|
||||
|
||||
/**
|
||||
* 订单金额
|
||||
*/
|
||||
private BigDecimal orderMoney;
|
||||
/**
|
||||
* 审核状态
|
||||
*/
|
||||
private String status;
|
||||
/**
|
||||
* 审核人id
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 审核人
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
}
|
@ -8,11 +8,16 @@ import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO;
|
||||
import cn.iocoder.yudao.module.system.enums.common.SexEnum;
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@ -144,6 +149,7 @@ public class MemberUserDO extends TenantBaseDO {
|
||||
/**
|
||||
* 卡号
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||
private String cardId;
|
||||
/**
|
||||
* 人脸
|
||||
|
@ -0,0 +1,29 @@
|
||||
package cn.iocoder.yudao.module.member.dal.mysql.refund;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.refund.vo.RefundPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.refund.RefundDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 退款审核 Mapper
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@Mapper
|
||||
public interface IntegralRefundMapper extends BaseMapperX<RefundDO> {
|
||||
|
||||
default PageResult<RefundDO> selectPage(RefundPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<RefundDO>()
|
||||
.eqIfPresent(RefundDO::getOrderId, reqVO.getOrderId())
|
||||
.eqIfPresent(RefundDO::getMoney, reqVO.getMoney())
|
||||
.eqIfPresent(RefundDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(RefundDO::getUserId, reqVO.getUserId())
|
||||
.likeIfPresent(RefundDO::getUserName, reqVO.getUserName())
|
||||
.betweenIfPresent(RefundDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(RefundDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -16,7 +16,8 @@ public enum CostTypeEnum {
|
||||
MORNING("2", "早餐"),
|
||||
NOON("3", "午餐"),
|
||||
NIGHT("4", "晚餐"),
|
||||
ADMIN_PAY("5","管理后台充值")
|
||||
ADMIN_PAY("5","管理后台充值"),
|
||||
REFUND("6","退款")
|
||||
;
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.module.member.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 代码生成的场景枚举
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum RefundStatusEnum {
|
||||
|
||||
TO_AUDIT("1", "待审核"),
|
||||
SUCCESS("2", "审核成功"),
|
||||
FAIL("3", "审核失败"),
|
||||
;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private final String code;
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private final String name;
|
||||
}
|
@ -75,13 +75,15 @@ public class BalanceDeductionJob implements JobHandler {
|
||||
cardDO.setUserId(userId);
|
||||
cardDO.setChangeMoney(total);
|
||||
cardDO.setFlag(CardDO.MINUS);
|
||||
cardService.insertOne(cardDO);
|
||||
list.add(cardDO);
|
||||
dishOrderDO.setTotalMoney(total);
|
||||
dishOrderDO.setOrderStatus(DishOrderDO.COMPLETE);
|
||||
dishOrderDO.setUpdateTime(LocalDateTime.now());
|
||||
stringRedisTemplate.delete(dishOrderDO.getDiningPlatesNum());
|
||||
});
|
||||
cardService.insertBatch(list);
|
||||
//取消批量,防止同一人订餐少扣款
|
||||
//cardService.insertBatch(list);
|
||||
size = list.size();
|
||||
//餐盘解绑
|
||||
platesService.updateBind(ids);
|
||||
|
@ -86,9 +86,17 @@ public interface CardService {
|
||||
*/
|
||||
void insertBatch(List<CardDO> list);
|
||||
|
||||
/**
|
||||
* 批量扣款
|
||||
*/
|
||||
void insertOne(CardDO cardDO);
|
||||
|
||||
|
||||
AppCardMonthVO getMonthMoney(Long userId,String flag, String time);
|
||||
|
||||
Boolean rechargeByAdmin(RechargeVO vo);
|
||||
|
||||
FaceVo getFaceData(String faceId);
|
||||
|
||||
void refund(Long userId,BigDecimal money);
|
||||
}
|
@ -149,11 +149,18 @@ public class CardServiceImpl implements CardService {
|
||||
return lastCardDO;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void insertBatch(List<CardDO> list) {
|
||||
cardMapper.insertBatch(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertOne(CardDO cardDO) {
|
||||
cardMapper.insert(cardDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppCardMonthVO getMonthMoney(Long userId, String flag, String time) {
|
||||
|
||||
@ -229,4 +236,21 @@ public class CardServiceImpl implements CardService {
|
||||
public FaceVo getFaceData(String faceId){
|
||||
return cardMapper.getFaceData(faceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refund(Long userId,BigDecimal money) {
|
||||
//获取最新余额
|
||||
CardDO lastCardDO = cardMapper.selectOne(Wrappers.<CardDO>lambdaQuery().eq(CardDO::getUserId, userId)
|
||||
.orderByDesc(CardDO::getCreateTime).last(MemberConstants.LIMIT_ONE));
|
||||
CardDO cardDO = new CardDO();
|
||||
cardDO.setUserId(userId);
|
||||
cardDO.setFlag(CardDO.ADD);
|
||||
cardDO.setChangeMoney(money);
|
||||
cardDO.setType(CostTypeEnum.REFUND.getCode());
|
||||
BigDecimal oldMoney = BigDecimal.ZERO;
|
||||
if (ObjectUtil.isNotEmpty(lastCardDO) && lastCardDO.getMoney() != null) {
|
||||
oldMoney = lastCardDO.getMoney();
|
||||
}
|
||||
cardDO.setMoney(oldMoney.add(money).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
}
|
@ -26,6 +26,7 @@ import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper;
|
||||
import cn.iocoder.yudao.module.member.enums.CostTypeEnum;
|
||||
import cn.iocoder.yudao.module.member.enums.TimePeriodEnum;
|
||||
import cn.iocoder.yudao.module.member.service.orderdetail.OrderDetailService;
|
||||
import cn.iocoder.yudao.module.member.service.refund.RefundService;
|
||||
import cn.iocoder.yudao.module.member.util.MemberConstants;
|
||||
import cn.iocoder.yudao.module.system.api.carteen.CarteenApi;
|
||||
import cn.iocoder.yudao.module.system.api.carteen.dto.CarteenRespDto;
|
||||
@ -78,6 +79,8 @@ public class OrderServiceImpl implements OrderService {
|
||||
private CardMapper cardMapper;
|
||||
@Resource
|
||||
private MemberGroupMapper groupMapper;
|
||||
@Resource
|
||||
private RefundService refundService;
|
||||
|
||||
@Override
|
||||
public Long createOrder(AppOrderSaveReqVO createReqVO) {
|
||||
@ -170,8 +173,8 @@ public class OrderServiceImpl implements OrderService {
|
||||
.setDishesSumPrice(dishesRespDto.getDishesSumPrice())
|
||||
.setDishesNumber(dishesRespDto.getDishesNumber());
|
||||
});
|
||||
dishOrderDO.setRefundStatus(refundService.getRefundStatus(dishOrderDO.getId()));
|
||||
}
|
||||
|
||||
dishOrderDO.setDetailList(appOrderDetailRespVOS);
|
||||
}
|
||||
return appOrderRespVOPageResult;
|
||||
|
@ -0,0 +1,66 @@
|
||||
package cn.iocoder.yudao.module.member.service.refund;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.refund.vo.RefundPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.refund.vo.RefundSaveReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.refund.vo.AppRefundSaveReqVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.refund.RefundDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 退款审核 Service 接口
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
public interface RefundService {
|
||||
|
||||
/**
|
||||
* 创建退款审核
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createRefund(@Valid RefundSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新退款审核
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateRefund(@Valid RefundSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除退款审核
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteRefund(Long id);
|
||||
|
||||
/**
|
||||
* 获得退款审核
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 退款审核
|
||||
*/
|
||||
RefundDO getRefund(Long id);
|
||||
|
||||
/**
|
||||
* 获得退款审核分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 退款审核分页
|
||||
*/
|
||||
PageResult<RefundDO> getRefundPage(RefundPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 创建退款审核
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createAppRefund(@Valid AppRefundSaveReqVO createReqVO);
|
||||
|
||||
|
||||
String getRefundStatus(Long orderId);
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package cn.iocoder.yudao.module.member.service.refund;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.refund.vo.RefundPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.refund.vo.RefundSaveReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.refund.vo.AppRefundSaveReqVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.refund.RefundDO;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.refund.IntegralRefundMapper;
|
||||
import cn.iocoder.yudao.module.member.enums.RefundStatusEnum;
|
||||
import cn.iocoder.yudao.module.member.service.card.CardService;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.REFUND_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 退款审核 Service 实现类
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class RefundServiceImpl implements RefundService {
|
||||
|
||||
@Resource
|
||||
private IntegralRefundMapper refundMapper;
|
||||
@Resource
|
||||
private CardService cardService;
|
||||
|
||||
@Override
|
||||
public Long createRefund(RefundSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
RefundDO refund = BeanUtils.toBean(createReqVO, RefundDO.class);
|
||||
refundMapper.insert(refund);
|
||||
// 返回
|
||||
return refund.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateRefund(RefundSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateRefundExists(updateReqVO.getId());
|
||||
// 更新
|
||||
RefundDO updateObj = BeanUtils.toBean(updateReqVO, RefundDO.class);
|
||||
refundMapper.updateById(updateObj);
|
||||
if(RefundStatusEnum.SUCCESS.getCode().equals(updateReqVO.getStatus())){
|
||||
cardService.refund(updateReqVO.getUserId(),updateReqVO.getMoney());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRefund(Long id) {
|
||||
// 校验存在
|
||||
validateRefundExists(id);
|
||||
// 删除
|
||||
refundMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateRefundExists(Long id) {
|
||||
if (refundMapper.selectById(id) == null) {
|
||||
throw exception(REFUND_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RefundDO getRefund(Long id) {
|
||||
return refundMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<RefundDO> getRefundPage(RefundPageReqVO pageReqVO) {
|
||||
return refundMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long createAppRefund(AppRefundSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
RefundDO refund = BeanUtils.toBean(createReqVO, RefundDO.class);
|
||||
refundMapper.insert(refund);
|
||||
// 返回
|
||||
return refund.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRefundStatus(Long orderId) {
|
||||
RefundDO refundDO = refundMapper.selectOne(Wrappers.<RefundDO>lambdaQuery()
|
||||
.eq(RefundDO::getOrderId, orderId).last("limit 1"));
|
||||
if(ObjectUtil.isNotEmpty(refundDO)){
|
||||
return refundDO.getStatus();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -312,17 +312,27 @@ public class MemberUserServiceImpl implements MemberUserService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateUser(MemberUserUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateUserExists(updateReqVO.getId());
|
||||
MemberUserDO memberUserDO = validateUserExists(updateReqVO.getId());
|
||||
// 校验手机唯一
|
||||
validateMobileUnique(updateReqVO.getId(), updateReqVO.getMobile());
|
||||
// 校验卡号
|
||||
if(StringUtils.isNotEmpty(updateReqVO.getCardId())){
|
||||
adminCardService.checkCard(updateReqVO.getCardId());
|
||||
}
|
||||
List<MemberUserDO> memberUserDOS = memberUserMapper.selectList(Wrappers.<MemberUserDO>lambdaQuery()
|
||||
.eq(MemberUserDO::getCardId, updateReqVO.getCardId())
|
||||
.ne(MemberUserDO::getId,updateReqVO.getId()));
|
||||
if(memberUserDOS.size()>0){
|
||||
throw exception(CARD_ALREADY_BIND);
|
||||
}
|
||||
//删除人脸
|
||||
if(memberUserDO.getFaceId()!=null){
|
||||
memberUserMapper.deleteFace(memberUserDO.getFaceId());
|
||||
}
|
||||
|
||||
// 更新
|
||||
MemberUserDO updateObj = MemberUserConvert.INSTANCE.convert(updateReqVO);
|
||||
updateObj.setCardId(updateReqVO.getCardId());
|
||||
updateObj.setCardId(StringUtils.isBlank(updateReqVO.getCardId())?null:updateReqVO.getCardId());
|
||||
memberUserMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,8 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@ -67,7 +69,17 @@ public class DivideInfoServiceImpl implements DivideInfoService {
|
||||
|
||||
@Override
|
||||
public PageResult<DivideInfoDO> getDivideInfoPage(DivideInfoPageReqVO pageReqVO) {
|
||||
return divideInfoMapper.selectPage(pageReqVO);
|
||||
PageResult<DivideInfoDO> divideInfoDOPageResult = divideInfoMapper.selectPage(pageReqVO);
|
||||
List<DivideInfoDO> list = divideInfoDOPageResult.getList();
|
||||
for (DivideInfoDO divideInfoDO:list){
|
||||
// 解析时间字符串
|
||||
ZonedDateTime zonedDateTime = ZonedDateTime.parse(divideInfoDO.getDFinishTime());
|
||||
// 定义所需的时间格式
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
// 格式化时间字符串
|
||||
divideInfoDO.setDFinishTime(zonedDateTime.format(formatter));
|
||||
}
|
||||
return divideInfoDOPageResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -9,22 +9,33 @@ import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.carteen.CarteenDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dishes.DishesDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dishestype.DishesTypeDO;
|
||||
import cn.iocoder.yudao.module.system.service.carteen.CarteenService;
|
||||
import cn.iocoder.yudao.module.system.service.dishes.DishesService;
|
||||
import cn.iocoder.yudao.module.system.service.dishesnutrition.DishesNutritionService;
|
||||
import cn.iocoder.yudao.module.system.service.dishesraw.DishesRawService;
|
||||
import cn.iocoder.yudao.module.system.service.dishestype.DishesTypeService;
|
||||
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 org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
@ -39,9 +50,9 @@ public class DishesController {
|
||||
@Resource
|
||||
private DishesService dishesService;
|
||||
@Resource
|
||||
private DishesNutritionService dishesNutritionService;
|
||||
private DishesTypeService dishesTypeService;
|
||||
@Resource
|
||||
private DishesRawService dishesRawService;
|
||||
private CarteenService carteenService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建菜品管理")
|
||||
@ -91,9 +102,18 @@ public class DishesController {
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<DishesDO> list = dishesService.getDishesPage(pageReqVO).getList();
|
||||
List<DishesRespVO> respVOList = BeanUtils.toBean(list, DishesRespVO.class);
|
||||
//转换类型,门店
|
||||
List<CarteenDO> carteenList = carteenService.getCarteenList();
|
||||
Map<Long, String> carteenMap = carteenList.stream().collect(Collectors.toMap(CarteenDO::getId, CarteenDO::getStoresName));
|
||||
List<DishesTypeDO> dishesTypeList = dishesTypeService.getList();
|
||||
Map<Long, String> dishesTypeMap = dishesTypeList.stream().collect(Collectors.toMap(DishesTypeDO::getId, DishesTypeDO::getDishesTypeName));
|
||||
for(DishesRespVO vo : respVOList){
|
||||
vo.setCarteenName(carteenMap.get(vo.getCarteenId()));
|
||||
vo.setDishecTypeName(dishesTypeMap.get(Long.valueOf(vo.getDishecType())));
|
||||
}
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "菜品管理.xls", "数据", DishesRespVO.class,
|
||||
BeanUtils.toBean(list, DishesRespVO.class));
|
||||
ExcelUtils.write(response, "菜品管理.xls", "数据", DishesRespVO.class,respVOList);
|
||||
}
|
||||
|
||||
}
|
@ -25,34 +25,27 @@ public class DishesRespVO {
|
||||
private String dishesName;
|
||||
|
||||
@Schema(description = "菜品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn")
|
||||
@ExcelProperty("菜品图片")
|
||||
private String dishesImageUrl;
|
||||
|
||||
@Schema(description = "菜品属性", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("菜品属性")
|
||||
private String dishesAttribute;
|
||||
|
||||
@Schema(description = "基本价格(标准)", requiredMode = Schema.RequiredMode.REQUIRED, example = "27937")
|
||||
@ExcelProperty("基本价格(标准)")
|
||||
private BigDecimal dishesBasePrice;
|
||||
|
||||
@Schema(description = "会员价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "21531")
|
||||
@ExcelProperty("会员价格")
|
||||
private BigDecimal dishesVipBasePrice;
|
||||
|
||||
@Schema(description = "称重价格(标准)", requiredMode = Schema.RequiredMode.REQUIRED, example = "6375")
|
||||
|
||||
private BigDecimal dishesWeighPrice;
|
||||
|
||||
@Schema(description = "称重会员价格(标准)", requiredMode = Schema.RequiredMode.REQUIRED, example = "9200")
|
||||
|
||||
private BigDecimal dishesVipWeighPrice;
|
||||
|
||||
@Schema(description = "厨师")
|
||||
private String dishecCook;
|
||||
|
||||
@Schema(description = "菜品类型", example = "1")
|
||||
@ExcelProperty("菜品类型")
|
||||
private String dishecType;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@ -63,9 +56,11 @@ public class DishesRespVO {
|
||||
private Long carteenId;
|
||||
|
||||
@Schema(description = "总价格")
|
||||
@ExcelProperty("价格")
|
||||
private BigDecimal dishesSumPrice;
|
||||
|
||||
@Schema(description = "菜品总重量")
|
||||
@ExcelProperty("单位重量")
|
||||
private BigDecimal dishesNumber;
|
||||
|
||||
@Schema(description = "菜品营养", example = "1")
|
||||
@ -75,4 +70,12 @@ public class DishesRespVO {
|
||||
|
||||
@Schema(description = "菜品kcal")
|
||||
private String kcal;
|
||||
|
||||
@Schema(description = "门店")
|
||||
@ExcelProperty("门店")
|
||||
private String carteenName;
|
||||
|
||||
@Schema(description = "菜品类型")
|
||||
@ExcelProperty("菜品类型")
|
||||
private String dishecTypeName;
|
||||
}
|
@ -61,4 +61,8 @@ public interface DishesTypeService {
|
||||
* @return
|
||||
*/
|
||||
List<DishesTypeListRespVO> getDishesTypeList(Long carteenId, LocalDateTime startTime,LocalDateTime endTime);
|
||||
|
||||
List<DishesTypeDO> getList();
|
||||
|
||||
|
||||
}
|
@ -14,13 +14,17 @@ import cn.iocoder.yudao.module.system.dal.mysql.dishes.DishesMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.dishestype.DishesTypeMapper;
|
||||
import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants;
|
||||
import cn.iocoder.yudao.module.system.enums.TimePeriodEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@ -128,4 +132,9 @@ public class DishesTypeServiceImpl implements DishesTypeService {
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DishesTypeDO> getList() {
|
||||
return dishesTypeMapper.selectList();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user