8.13优化
This commit is contained in:
@ -28,7 +28,7 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode TAG_NOT_EXISTS = new ErrorCode(1_004_006_000, "用户标签不存在");
|
ErrorCode TAG_NOT_EXISTS = new ErrorCode(1_004_006_000, "用户标签不存在");
|
||||||
ErrorCode TAG_NAME_EXISTS = new ErrorCode(1_004_006_001, "用户标签已经存在");
|
ErrorCode TAG_NAME_EXISTS = new ErrorCode(1_004_006_001, "用户标签已经存在");
|
||||||
ErrorCode TAG_HAS_USER = new ErrorCode(1_004_006_002, "用户标签下存在用户,无法删除");
|
ErrorCode TAG_HAS_USER = new ErrorCode(1_004_006_002, "用户标签下存在用户,无法删除");
|
||||||
|
ErrorCode TAG_STATE_EXISTS = new ErrorCode(1_004_006_003, "标签优先级已经存在");
|
||||||
//========== 积分配置 1-004-007-000 ==========
|
//========== 积分配置 1-004-007-000 ==========
|
||||||
|
|
||||||
//========== 积分记录 1-004-008-000 ==========
|
//========== 积分记录 1-004-008-000 ==========
|
||||||
@ -79,7 +79,7 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode ORDER_ALREADY_COMPLETE = new ErrorCode(1_004_099_004, "该餐盘订单已完成,请重新绑定餐盘");
|
ErrorCode ORDER_ALREADY_COMPLETE = new ErrorCode(1_004_099_004, "该餐盘订单已完成,请重新绑定餐盘");
|
||||||
ErrorCode FACE_NOT_BIND_USER = new ErrorCode(1_004_099_005, "人脸未绑定");
|
ErrorCode FACE_NOT_BIND_USER = new ErrorCode(1_004_099_005, "人脸未绑定");
|
||||||
ErrorCode CARD_NOT_BIND_USER = new ErrorCode(1_004_099_006, "该卡未绑定用户");
|
ErrorCode CARD_NOT_BIND_USER = new ErrorCode(1_004_099_006, "该卡未绑定用户");
|
||||||
ErrorCode INSUFFICIENT_BALANCE = new ErrorCode(1_004_099_007, "余额不足30元,请充值");
|
ErrorCode INSUFFICIENT_BALANCE = new ErrorCode(1_004_099_007, "余额不足15元,请充值");
|
||||||
ErrorCode EXIST_TO_COMPLETE_ORDER = new ErrorCode(1_004_099_008, "存在未支付完的订单");
|
ErrorCode EXIST_TO_COMPLETE_ORDER = new ErrorCode(1_004_099_008, "存在未支付完的订单");
|
||||||
ErrorCode CARD_ALREADY_BIND = new ErrorCode(1_004_099_008, "卡号已绑定");
|
ErrorCode CARD_ALREADY_BIND = new ErrorCode(1_004_099_008, "卡号已绑定");
|
||||||
ErrorCode ORDER_NOT_COMPLETE = new ErrorCode(1_004_099_009, "订单未完成");
|
ErrorCode ORDER_NOT_COMPLETE = new ErrorCode(1_004_099_009, "订单未完成");
|
||||||
|
@ -67,5 +67,10 @@ public class BusinessRespVO {
|
|||||||
|
|
||||||
private Long carteenId;
|
private Long carteenId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提现
|
||||||
|
*/
|
||||||
|
private BigDecimal withdrawal;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -78,4 +78,15 @@ public class OrderDetailsRespVO {
|
|||||||
@ExcelProperty("减免金额")
|
@ExcelProperty("减免金额")
|
||||||
private BigDecimal reductionAmount;
|
private BigDecimal reductionAmount;
|
||||||
|
|
||||||
|
@Schema(description = "现有金额")
|
||||||
|
private BigDecimal money;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 待支付金额
|
||||||
|
*/
|
||||||
|
private BigDecimal payAmount;
|
||||||
|
/**
|
||||||
|
* 最大退款金额
|
||||||
|
*/
|
||||||
|
private BigDecimal refundAmount;
|
||||||
}
|
}
|
||||||
|
@ -44,4 +44,6 @@ public class OrderDetailRespVO {
|
|||||||
|
|
||||||
@Schema(description = "总价")
|
@Schema(description = "总价")
|
||||||
private List<OrderDetailRespVO> detailList;
|
private List<OrderDetailRespVO> detailList;
|
||||||
|
|
||||||
|
private BigDecimal money;
|
||||||
}
|
}
|
@ -1,5 +1,11 @@
|
|||||||
package cn.iocoder.yudao.module.member.controller.admin.refund;
|
package cn.iocoder.yudao.module.member.controller.admin.refund;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.order.DishOrderDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.mysql.order.DishOrderMapper;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@ -11,6 +17,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import javax.validation.*;
|
import javax.validation.*;
|
||||||
import javax.servlet.http.*;
|
import javax.servlet.http.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@ -38,6 +45,9 @@ public class RefundController {
|
|||||||
@Resource
|
@Resource
|
||||||
private RefundService refundService;
|
private RefundService refundService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DishOrderMapper orderMapper;
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建退款审核")
|
@Operation(summary = "创建退款审核")
|
||||||
@PreAuthorize("@ss.hasPermission('member:refund:create')")
|
@PreAuthorize("@ss.hasPermission('member:refund:create')")
|
||||||
@ -76,7 +86,19 @@ public class RefundController {
|
|||||||
@PreAuthorize("@ss.hasPermission('member:refund:query')")
|
@PreAuthorize("@ss.hasPermission('member:refund:query')")
|
||||||
public CommonResult<PageResult<RefundRespVO>> getRefundPage(@Valid RefundPageReqVO pageReqVO) {
|
public CommonResult<PageResult<RefundRespVO>> getRefundPage(@Valid RefundPageReqVO pageReqVO) {
|
||||||
PageResult<RefundDO> pageResult = refundService.getRefundPage(pageReqVO);
|
PageResult<RefundDO> pageResult = refundService.getRefundPage(pageReqVO);
|
||||||
return success(BeanUtils.toBean(pageResult, RefundRespVO.class));
|
PageResult<RefundRespVO> bean = BeanUtils.toBean(pageResult, RefundRespVO.class);
|
||||||
|
if(CollectionUtil.isNotEmpty(bean.getList())){
|
||||||
|
for (RefundRespVO vo : bean.getList()){
|
||||||
|
DishOrderDO dishOrderDO = orderMapper.selectById(vo.getOrderId());
|
||||||
|
if(ObjectUtil.isNotEmpty(dishOrderDO)){
|
||||||
|
vo.setRefundAmount(dishOrderDO.getRefundAmount());
|
||||||
|
}else {
|
||||||
|
vo.setRefundAmount(BigDecimal.ZERO);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return success(bean);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/export-excel")
|
@GetMapping("/export-excel")
|
||||||
|
@ -40,5 +40,6 @@ public class RefundPageReqVO extends PageParam {
|
|||||||
@Schema(description = "订单金额")
|
@Schema(description = "订单金额")
|
||||||
private BigDecimal orderMoney;
|
private BigDecimal orderMoney;
|
||||||
|
|
||||||
|
@Schema(description = "手机")
|
||||||
|
private String mobile;
|
||||||
}
|
}
|
@ -29,12 +29,12 @@ public class RefundRespVO {
|
|||||||
@ExcelProperty("审核状态")
|
@ExcelProperty("审核状态")
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
@Schema(description = "审核人id", example = "21777")
|
@Schema(description = "申请人id", example = "21777")
|
||||||
@ExcelProperty("审核人id")
|
@ExcelProperty("申请人id")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
@Schema(description = "审核人", example = "王五")
|
@Schema(description = "申请人", example = "王五")
|
||||||
@ExcelProperty("审核人")
|
@ExcelProperty("申请人")
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@ -44,4 +44,9 @@ public class RefundRespVO {
|
|||||||
@Schema(description = "订单金额")
|
@Schema(description = "订单金额")
|
||||||
private BigDecimal orderMoney;
|
private BigDecimal orderMoney;
|
||||||
|
|
||||||
|
@Schema(description = "申请人电话", example = "王五")
|
||||||
|
@ExcelProperty("申请人电话")
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
|
private BigDecimal refundAmount;
|
||||||
}
|
}
|
@ -32,4 +32,7 @@ public class RefundSaveReqVO {
|
|||||||
@Schema(description = "审核人", example = "王五")
|
@Schema(description = "审核人", example = "王五")
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
|
@Schema(description = "手机", example = "王五")
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
}
|
}
|
@ -35,5 +35,22 @@ public class MemberTagBaseVO {
|
|||||||
* 执行优先
|
* 执行优先
|
||||||
*/
|
*/
|
||||||
private String state;
|
private String state;
|
||||||
|
/**
|
||||||
|
* 时间段标志:0-关闭,1-开启
|
||||||
|
*/
|
||||||
|
private String timeFlag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 早
|
||||||
|
*/
|
||||||
|
private BigDecimal morning;
|
||||||
|
/**
|
||||||
|
* 中
|
||||||
|
*/
|
||||||
|
private BigDecimal noon;
|
||||||
|
/**
|
||||||
|
* 晚
|
||||||
|
*/
|
||||||
|
private BigDecimal night;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -67,4 +67,16 @@ public class AppOrderRespVO {
|
|||||||
@Schema(description = "减免金额")
|
@Schema(description = "减免金额")
|
||||||
private BigDecimal reductionAmount;
|
private BigDecimal reductionAmount;
|
||||||
|
|
||||||
|
@Schema(description = "现有金额")
|
||||||
|
private BigDecimal money;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 待支付金额
|
||||||
|
*/
|
||||||
|
private BigDecimal payAmount;
|
||||||
|
/**
|
||||||
|
* 最大退款金额
|
||||||
|
*/
|
||||||
|
private BigDecimal refundAmount;
|
||||||
|
|
||||||
}
|
}
|
@ -55,6 +55,10 @@ public class BusinessDO extends BaseDO {
|
|||||||
* 充值钱包
|
* 充值钱包
|
||||||
*/
|
*/
|
||||||
private BigDecimal rechargePurse;
|
private BigDecimal rechargePurse;
|
||||||
|
/**
|
||||||
|
* 提现
|
||||||
|
*/
|
||||||
|
private BigDecimal withdrawal;
|
||||||
/**
|
/**
|
||||||
* 补贴钱包
|
* 补贴钱包
|
||||||
*/
|
*/
|
||||||
|
@ -93,4 +93,13 @@ public class DishOrderDO extends BaseDO {
|
|||||||
* 减免金额
|
* 减免金额
|
||||||
*/
|
*/
|
||||||
private BigDecimal reductionAmount;
|
private BigDecimal reductionAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 待支付金额
|
||||||
|
*/
|
||||||
|
private BigDecimal payAmount;
|
||||||
|
/**
|
||||||
|
* 最大退款金额
|
||||||
|
*/
|
||||||
|
private BigDecimal refundAmount;
|
||||||
}
|
}
|
@ -59,4 +59,6 @@ public class RefundDO extends BaseDO {
|
|||||||
*/
|
*/
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.dal.dataobject.refundlog;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退款记录 DO
|
||||||
|
*
|
||||||
|
* @author 管理员
|
||||||
|
*/
|
||||||
|
@TableName("member_refund_log")
|
||||||
|
@KeySequence("member_refund_log_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class RefundLogDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编号
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 退款
|
||||||
|
*/
|
||||||
|
private BigDecimal money;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
}
|
@ -49,5 +49,21 @@ public class MemberTagDO extends BaseDO {
|
|||||||
* 执行优先
|
* 执行优先
|
||||||
*/
|
*/
|
||||||
private String state;
|
private String state;
|
||||||
|
/**
|
||||||
|
* 时间段标志:0-关闭,1-开启
|
||||||
|
*/
|
||||||
|
private String timeFlag;
|
||||||
|
/**
|
||||||
|
* 早
|
||||||
|
*/
|
||||||
|
private BigDecimal morning;
|
||||||
|
/**
|
||||||
|
* 中
|
||||||
|
*/
|
||||||
|
private BigDecimal noon;
|
||||||
|
/**
|
||||||
|
* 晚
|
||||||
|
*/
|
||||||
|
private BigDecimal night;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,8 @@ import cn.iocoder.yudao.module.member.controller.app.card.vo.AppCardMonthVO;
|
|||||||
import cn.iocoder.yudao.module.member.controller.app.card.vo.AppCardPageReqVO;
|
import cn.iocoder.yudao.module.member.controller.app.card.vo.AppCardPageReqVO;
|
||||||
import cn.iocoder.yudao.module.member.controller.app.card.vo.FaceVo;
|
import cn.iocoder.yudao.module.member.controller.app.card.vo.FaceVo;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.card.CardDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.card.CardDO;
|
||||||
|
import cn.iocoder.yudao.module.member.util.MemberConstants;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
@ -53,4 +55,16 @@ public interface CardMapper extends BaseMapperX<CardDO> {
|
|||||||
List<CardDO> selectMoneyList(List<Long> list);
|
List<CardDO> selectMoneyList(List<Long> list);
|
||||||
|
|
||||||
FaceVo getFaceData(String faceId);
|
FaceVo getFaceData(String faceId);
|
||||||
|
|
||||||
|
default BigDecimal getMoneyByUsr(Long userId){
|
||||||
|
CardDO lastCardDO = selectOne(Wrappers.<CardDO>lambdaQuery().eq(CardDO::getUserId, userId)
|
||||||
|
.orderByDesc(CardDO::getCreateTime)
|
||||||
|
.orderByDesc(CardDO::getId)
|
||||||
|
.last(MemberConstants.LIMIT_ONE));
|
||||||
|
if (lastCardDO == null || lastCardDO.getMoney() == null) {
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
return lastCardDO.getMoney();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -21,6 +21,7 @@ public interface IntegralRefundMapper extends BaseMapperX<RefundDO> {
|
|||||||
.eqIfPresent(RefundDO::getMoney, reqVO.getMoney())
|
.eqIfPresent(RefundDO::getMoney, reqVO.getMoney())
|
||||||
.eqIfPresent(RefundDO::getStatus, reqVO.getStatus())
|
.eqIfPresent(RefundDO::getStatus, reqVO.getStatus())
|
||||||
.eqIfPresent(RefundDO::getUserId, reqVO.getUserId())
|
.eqIfPresent(RefundDO::getUserId, reqVO.getUserId())
|
||||||
|
.eqIfPresent(RefundDO::getMobile, reqVO.getMobile())
|
||||||
.likeIfPresent(RefundDO::getUserName, reqVO.getUserName())
|
.likeIfPresent(RefundDO::getUserName, reqVO.getUserName())
|
||||||
.betweenIfPresent(RefundDO::getCreateTime, reqVO.getCreateTime())
|
.betweenIfPresent(RefundDO::getCreateTime, reqVO.getCreateTime())
|
||||||
.orderByDesc(RefundDO::getId));
|
.orderByDesc(RefundDO::getId));
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.dal.mysql.refundlog;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.refundlog.RefundLogDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退款记录 Mapper
|
||||||
|
*
|
||||||
|
* @author 管理员
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface RefundLogMapper extends BaseMapperX<RefundLogDO> {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -25,4 +25,8 @@ public interface MemberTagMapper extends BaseMapperX<MemberTagDO> {
|
|||||||
default MemberTagDO selelctByName(String name) {
|
default MemberTagDO selelctByName(String name) {
|
||||||
return selectOne(MemberTagDO::getName, name);
|
return selectOne(MemberTagDO::getName, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default MemberTagDO selelctByState(String name) {
|
||||||
|
return selectOne(MemberTagDO::getState, name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,20 +78,41 @@ public class BalanceDeductionJob implements JobHandler {
|
|||||||
|
|
||||||
BigDecimal money = oldCardDO.getMoney();
|
BigDecimal money = oldCardDO.getMoney();
|
||||||
//计算减免价格
|
//计算减免价格
|
||||||
BigDecimal reductionAmount = userService.getReductionAmount(userId, total);
|
BigDecimal reductionAmount = BigDecimal.ZERO;
|
||||||
|
if (total.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
reductionAmount = userService.getReductionAmount(userId, total, dishOrderDO.getCreateTime());
|
||||||
|
}
|
||||||
dishOrderDO.setReductionAmount(reductionAmount);
|
dishOrderDO.setReductionAmount(reductionAmount);
|
||||||
dishOrderDO.setReductionState(reductionAmount.compareTo(BigDecimal.ZERO)>0?"1":"0");
|
dishOrderDO.setReductionState(reductionAmount.compareTo(BigDecimal.ZERO) > 0 ? "1" : "0");
|
||||||
|
|
||||||
//计算减免后的总价
|
//计算减免后的总价
|
||||||
total = total.subtract(reductionAmount);
|
if(total.compareTo(reductionAmount)<0){
|
||||||
|
total = BigDecimal.ZERO;
|
||||||
|
}else {
|
||||||
|
total = total.subtract(reductionAmount);
|
||||||
|
}
|
||||||
|
|
||||||
BigDecimal wxAmount = oldCardDO.getWxAmount();
|
BigDecimal wxAmount = oldCardDO.getWxAmount();
|
||||||
BigDecimal giftAmount = oldCardDO.getGiftAmount();
|
BigDecimal giftAmount = oldCardDO.getGiftAmount();
|
||||||
BigDecimal cashAmount = oldCardDO.getCashAmount();
|
BigDecimal cashAmount = oldCardDO.getCashAmount();
|
||||||
cardDO.setMoney(money.subtract(total).setScale(2, BigDecimal.ROUND_HALF_UP));
|
cardDO.setMoney(money.subtract(total).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
//待支付金额 最大退款金额
|
||||||
|
dishOrderDO.setRefundAmount(total);
|
||||||
|
if (money.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
|
dishOrderDO.setPayAmount(total);
|
||||||
|
dishOrderDO.setRefundAmount(BigDecimal.ZERO);
|
||||||
|
} else {
|
||||||
|
if (total.compareTo(money) > 0) {
|
||||||
|
dishOrderDO.setPayAmount(total.subtract(money).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
dishOrderDO.setRefundAmount(money);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (total.compareTo(money) > 0) {
|
if (total.compareTo(money) > 0) {
|
||||||
dishOrderDO.setOrderStatus(DishOrderDO.TOCOMPLETE);
|
dishOrderDO.setOrderStatus(DishOrderDO.TOCOMPLETE);
|
||||||
|
dishOrderDO.setWxAmount(wxAmount);
|
||||||
|
dishOrderDO.setCashAmount(cashAmount);
|
||||||
|
dishOrderDO.setGiftAmount(giftAmount);
|
||||||
} else {
|
} else {
|
||||||
dishOrderDO.setOrderStatus(DishOrderDO.COMPLETE);
|
dishOrderDO.setOrderStatus(DishOrderDO.COMPLETE);
|
||||||
//计算金额
|
//计算金额
|
||||||
|
@ -23,6 +23,7 @@ import java.math.RoundingMode;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -95,6 +96,14 @@ public class BusinessBatchJob implements JobHandler {
|
|||||||
.map(CardDO::getMoney)
|
.map(CardDO::getMoney)
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
build.setRechargePurse(reduce);
|
build.setRechargePurse(reduce);
|
||||||
|
//提现金额
|
||||||
|
BigDecimal withdrawal =cardMapper.selectList(new LambdaQueryWrapperX<CardDO>()
|
||||||
|
.betweenIfPresent(CardDO::getCreateTime, startDate, endDate)
|
||||||
|
.in(CardDO::getType, Arrays.asList(CostTypeEnum.WITHDRAW.getCode(),CostTypeEnum.CASH_WITHDRAW.getCode())))
|
||||||
|
.stream()
|
||||||
|
.map(CardDO::getChangeMoney)
|
||||||
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
build.setWithdrawal(withdrawal);
|
||||||
//早餐
|
//早餐
|
||||||
value.forEach(x-> x.setPayMethods(TimePeriodEnum.getTimePeriod(x.getCreateTime())));
|
value.forEach(x-> x.setPayMethods(TimePeriodEnum.getTimePeriod(x.getCreateTime())));
|
||||||
Map<String, List<DishOrderDO>> collect1 = value.stream().collect(Collectors.groupingBy(DishOrderDO::getPayMethods));
|
Map<String, List<DishOrderDO>> collect1 = value.stream().collect(Collectors.groupingBy(DishOrderDO::getPayMethods));
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.member.service.card;
|
package cn.iocoder.yudao.module.member.service.card;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.math.Money;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
@ -14,12 +15,19 @@ import cn.iocoder.yudao.module.member.controller.app.card.vo.AppCardPageReqVO;
|
|||||||
import cn.iocoder.yudao.module.member.controller.app.card.vo.FaceVo;
|
import cn.iocoder.yudao.module.member.controller.app.card.vo.FaceVo;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.card.CardDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.card.CardDO;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.order.DishOrderDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.order.DishOrderDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.refund.RefundDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.refundlog.RefundLogDO;
|
||||||
import cn.iocoder.yudao.module.member.dal.mysql.card.CardMapper;
|
import cn.iocoder.yudao.module.member.dal.mysql.card.CardMapper;
|
||||||
import cn.iocoder.yudao.module.member.dal.mysql.group.MemberGroupMapper;
|
import cn.iocoder.yudao.module.member.dal.mysql.group.MemberGroupMapper;
|
||||||
import cn.iocoder.yudao.module.member.dal.mysql.order.DishOrderMapper;
|
import cn.iocoder.yudao.module.member.dal.mysql.order.DishOrderMapper;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.mysql.refund.IntegralRefundMapper;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.mysql.refundlog.RefundLogMapper;
|
||||||
import cn.iocoder.yudao.module.member.enums.CostTypeEnum;
|
import cn.iocoder.yudao.module.member.enums.CostTypeEnum;
|
||||||
|
import cn.iocoder.yudao.module.member.service.refund.RefundService;
|
||||||
import cn.iocoder.yudao.module.member.util.MemberConstants;
|
import cn.iocoder.yudao.module.member.util.MemberConstants;
|
||||||
|
import com.alibaba.druid.sql.visitor.functions.Left;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@ -33,6 +41,7 @@ import java.time.LocalTime;
|
|||||||
import java.time.YearMonth;
|
import java.time.YearMonth;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -56,6 +65,12 @@ public class CardServiceImpl implements CardService {
|
|||||||
@Resource
|
@Resource
|
||||||
private DishOrderMapper dishOrderMapper;
|
private DishOrderMapper dishOrderMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IntegralRefundMapper refundMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RefundLogMapper refundLogMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createCard(CardSaveReqVO createReqVO) {
|
public Long createCard(CardSaveReqVO createReqVO) {
|
||||||
// 插入
|
// 插入
|
||||||
@ -105,7 +120,7 @@ public class CardServiceImpl implements CardService {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean recharge(BigDecimal money, String flag,BigDecimal giftMoney) {
|
public Boolean recharge(BigDecimal money, String flag, BigDecimal giftMoney) {
|
||||||
//获取最新余额
|
//获取最新余额
|
||||||
CardDO lastCardDO = getLastCardDO();
|
CardDO lastCardDO = getLastCardDO();
|
||||||
CardDO cardDO = new CardDO();
|
CardDO cardDO = new CardDO();
|
||||||
@ -114,9 +129,9 @@ public class CardServiceImpl implements CardService {
|
|||||||
cardDO.setChangeMoney(money);
|
cardDO.setChangeMoney(money);
|
||||||
cardDO.setType(CostTypeEnum.WX_PAY.getCode());
|
cardDO.setType(CostTypeEnum.WX_PAY.getCode());
|
||||||
BigDecimal oldMoney = BigDecimal.ZERO;
|
BigDecimal oldMoney = BigDecimal.ZERO;
|
||||||
BigDecimal wxOldMoney= BigDecimal.ZERO;
|
BigDecimal wxOldMoney = BigDecimal.ZERO;
|
||||||
BigDecimal giftOldMoney= BigDecimal.ZERO;
|
BigDecimal giftOldMoney = BigDecimal.ZERO;
|
||||||
BigDecimal cashAmount= BigDecimal.ZERO;
|
BigDecimal cashAmount = BigDecimal.ZERO;
|
||||||
if (ObjectUtil.isNotEmpty(lastCardDO) && lastCardDO.getMoney() != null) {
|
if (ObjectUtil.isNotEmpty(lastCardDO) && lastCardDO.getMoney() != null) {
|
||||||
oldMoney = lastCardDO.getMoney();
|
oldMoney = lastCardDO.getMoney();
|
||||||
}
|
}
|
||||||
@ -133,27 +148,29 @@ public class CardServiceImpl implements CardService {
|
|||||||
cardDO.setMoney(oldMoney.add(money).setScale(2, BigDecimal.ROUND_HALF_UP));
|
cardDO.setMoney(oldMoney.add(money).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
cardDO.setCashAmount(cashAmount);
|
cardDO.setCashAmount(cashAmount);
|
||||||
cardDO.setGiftAmount(giftOldMoney);
|
cardDO.setGiftAmount(giftOldMoney);
|
||||||
cardDO.setWxAmount(giftOldMoney);
|
cardDO.setWxAmount(wxOldMoney);
|
||||||
if(cardDO.getMoney().compareTo(BigDecimal.ZERO) >0){
|
if (cardDO.getMoney().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
BigDecimal wxAmount = money;
|
BigDecimal wxAmount = money;
|
||||||
if(giftMoney!=null){
|
if (giftMoney != null) {
|
||||||
cardDO.setGiftAmount(giftOldMoney.add(giftMoney).setScale(2, BigDecimal.ROUND_HALF_UP));
|
cardDO.setGiftAmount(giftOldMoney.add(giftMoney).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
wxAmount = wxAmount.subtract(giftMoney);
|
wxAmount = wxAmount.subtract(giftMoney);
|
||||||
}
|
}
|
||||||
if(oldMoney.compareTo(BigDecimal.ZERO)<0){
|
if (oldMoney.compareTo(BigDecimal.ZERO) < 0) {
|
||||||
updateOrderStatus(cardDO.getUserId());
|
if (wxAmount.add(oldMoney).compareTo(BigDecimal.ZERO) >= 0) {
|
||||||
if(wxAmount.add(oldMoney).compareTo(BigDecimal.ZERO)>=0){
|
cardDO.setWxAmount(wxAmount.add(oldMoney));
|
||||||
cardDO.setWxAmount(wxAmount.add(oldMoney));
|
} else {
|
||||||
}else{
|
BigDecimal left = wxAmount.add(oldMoney);
|
||||||
BigDecimal left = wxAmount.add(oldMoney);
|
cardDO.setWxAmount(BigDecimal.ZERO);
|
||||||
cardDO.setWxAmount(BigDecimal.ZERO);
|
cardDO.setGiftAmount(giftMoney.add(left));
|
||||||
cardDO.setGiftAmount(giftMoney.add(left));
|
}
|
||||||
}
|
} else {
|
||||||
}else{
|
|
||||||
cardDO.setWxAmount(wxOldMoney.add(wxAmount).setScale(2, BigDecimal.ROUND_HALF_UP));
|
cardDO.setWxAmount(wxOldMoney.add(wxAmount).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int i =cardMapper.insert(cardDO);
|
//处理未完全支付订单
|
||||||
|
handleOrderWx(cardDO.getUserId(),money,giftMoney);
|
||||||
|
|
||||||
|
int i = cardMapper.insert(cardDO);
|
||||||
return i > 0;
|
return i > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +186,7 @@ public class CardServiceImpl implements CardService {
|
|||||||
@Override
|
@Override
|
||||||
public BigDecimal getMoneyByUserId(Long userId) {
|
public BigDecimal getMoneyByUserId(Long userId) {
|
||||||
CardDO lastCardDO = cardMapper.selectOne(Wrappers.<CardDO>lambdaQuery().eq(CardDO::getUserId, userId)
|
CardDO lastCardDO = cardMapper.selectOne(Wrappers.<CardDO>lambdaQuery().eq(CardDO::getUserId, userId)
|
||||||
.orderByDesc(CardDO::getCreateTime).last(MemberConstants.LIMIT_ONE));
|
.orderByDesc(CardDO::getCreateTime).orderByDesc(CardDO::getId).last(MemberConstants.LIMIT_ONE));
|
||||||
if (lastCardDO == null || lastCardDO.getMoney() == null) {
|
if (lastCardDO == null || lastCardDO.getMoney() == null) {
|
||||||
return BigDecimal.ZERO;
|
return BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
@ -179,7 +196,7 @@ public class CardServiceImpl implements CardService {
|
|||||||
@Override
|
@Override
|
||||||
public CardDO getCardDoByUserId(Long userId) {
|
public CardDO getCardDoByUserId(Long userId) {
|
||||||
CardDO lastCardDO = cardMapper.selectOne(Wrappers.<CardDO>lambdaQuery().eq(CardDO::getUserId, userId)
|
CardDO lastCardDO = cardMapper.selectOne(Wrappers.<CardDO>lambdaQuery().eq(CardDO::getUserId, userId)
|
||||||
.orderByDesc(CardDO::getCreateTime).last(MemberConstants.LIMIT_ONE));
|
.orderByDesc(CardDO::getCreateTime).orderByDesc(CardDO::getId).last(MemberConstants.LIMIT_ONE));
|
||||||
|
|
||||||
return lastCardDO;
|
return lastCardDO;
|
||||||
}
|
}
|
||||||
@ -191,12 +208,13 @@ public class CardServiceImpl implements CardService {
|
|||||||
*/
|
*/
|
||||||
public CardDO getLastCardDO() {
|
public CardDO getLastCardDO() {
|
||||||
CardDO lastCardDO = cardMapper.selectOne(Wrappers.<CardDO>lambdaQuery().eq(CardDO::getUserId, SecurityFrameworkUtils.getLoginUserId())
|
CardDO lastCardDO = cardMapper.selectOne(Wrappers.<CardDO>lambdaQuery().eq(CardDO::getUserId, SecurityFrameworkUtils.getLoginUserId())
|
||||||
.orderByDesc(CardDO::getCreateTime).last(MemberConstants.LIMIT_ONE));
|
.orderByDesc(CardDO::getCreateTime)
|
||||||
|
.orderByDesc(CardDO::getId)
|
||||||
|
.last(MemberConstants.LIMIT_ONE));
|
||||||
return lastCardDO;
|
return lastCardDO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void insertBatch(List<CardDO> list) {
|
public void insertBatch(List<CardDO> list) {
|
||||||
cardMapper.insertBatch(list);
|
cardMapper.insertBatch(list);
|
||||||
@ -238,7 +256,7 @@ public class CardServiceImpl implements CardService {
|
|||||||
if (vo.getGroupId() != null) {
|
if (vo.getGroupId() != null) {
|
||||||
memberList.addAll(memberGroupMapper.getMemberList(vo.getGroupId()));
|
memberList.addAll(memberGroupMapper.getMemberList(vo.getGroupId()));
|
||||||
} else {
|
} else {
|
||||||
if (CollectionUtil.isEmpty(vo.getUserIds())){
|
if (CollectionUtil.isEmpty(vo.getUserIds())) {
|
||||||
throw new ServiceException(NEED_ADD_USER);
|
throw new ServiceException(NEED_ADD_USER);
|
||||||
}
|
}
|
||||||
memberList.addAll(vo.getUserIds());
|
memberList.addAll(vo.getUserIds());
|
||||||
@ -261,15 +279,11 @@ public class CardServiceImpl implements CardService {
|
|||||||
BigDecimal oldMoney = cardDO.getMoney();
|
BigDecimal oldMoney = cardDO.getMoney();
|
||||||
add.setMoney(oldMoney.add(vo.getMoney()).setScale(2, BigDecimal.ROUND_HALF_UP));
|
add.setMoney(oldMoney.add(vo.getMoney()).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
|
||||||
if(add.getMoney().compareTo(BigDecimal.ZERO) >0){
|
if (add.getMoney().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
BigDecimal cashOldMoney = cardDO.getCashAmount();
|
BigDecimal cashOldMoney = cardDO.getCashAmount();
|
||||||
add.setCashAmount(cashOldMoney.add(add.getMoney()).setScale(2, BigDecimal.ROUND_HALF_UP));
|
add.setCashAmount(cashOldMoney.add(add.getChangeMoney()).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
add.setWxAmount(cardDO.getWxAmount());
|
add.setWxAmount(cardDO.getWxAmount());
|
||||||
add.setGiftAmount(cardDO.getGiftAmount());
|
add.setGiftAmount(cardDO.getGiftAmount());
|
||||||
|
|
||||||
if(oldMoney.compareTo(BigDecimal.ZERO)<0){
|
|
||||||
updateOrderStatus(cardDO.getUserId());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
addList.add(add);
|
addList.add(add);
|
||||||
|
|
||||||
@ -288,22 +302,24 @@ public class CardServiceImpl implements CardService {
|
|||||||
addList.add(add);
|
addList.add(add);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//处理订单
|
||||||
|
handleOrderCash(memberList,vo.getMoney());
|
||||||
|
|
||||||
//批量添加
|
//批量添加
|
||||||
return cardMapper.insertBatch(addList);
|
return cardMapper.insertBatch(addList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public FaceVo getFaceData(String faceId){
|
public FaceVo getFaceData(String faceId) {
|
||||||
return cardMapper.getFaceData(faceId);
|
return cardMapper.getFaceData(faceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void refund(Long userId,BigDecimal money,Long orderId) {
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void refund(Long userId, BigDecimal money, Long orderId) {
|
||||||
//获取最新余额
|
//获取最新余额
|
||||||
|
|
||||||
CardDO lastCardDO = cardMapper.selectOne(Wrappers.<CardDO>lambdaQuery().eq(CardDO::getUserId, userId)
|
CardDO lastCardDO = cardMapper.selectOne(Wrappers.<CardDO>lambdaQuery().eq(CardDO::getUserId, userId)
|
||||||
.orderByDesc(CardDO::getCreateTime).last(MemberConstants.LIMIT_ONE));
|
.orderByDesc(CardDO::getCreateTime).orderByDesc(CardDO::getId).last(MemberConstants.LIMIT_ONE));
|
||||||
DishOrderDO dishOrderDO = dishOrderMapper.selectById(orderId);
|
DishOrderDO dishOrderDO = dishOrderMapper.selectById(orderId);
|
||||||
|
|
||||||
CardDO cardDO = new CardDO();
|
CardDO cardDO = new CardDO();
|
||||||
@ -325,38 +341,227 @@ public class CardServiceImpl implements CardService {
|
|||||||
BigDecimal dishWxAmount = dishOrderDO.getWxAmount();
|
BigDecimal dishWxAmount = dishOrderDO.getWxAmount();
|
||||||
BigDecimal dishCashAmount = dishOrderDO.getCashAmount();
|
BigDecimal dishCashAmount = dishOrderDO.getCashAmount();
|
||||||
BigDecimal dishGiftAmount = dishOrderDO.getGiftAmount();
|
BigDecimal dishGiftAmount = dishOrderDO.getGiftAmount();
|
||||||
|
if (cardDO.getMoney().compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
|
cardDO.setWxAmount(BigDecimal.ZERO);
|
||||||
|
cardDO.setGiftAmount(BigDecimal.ZERO);
|
||||||
|
cardDO.setCashAmount(BigDecimal.ZERO);
|
||||||
|
} else {
|
||||||
|
if (money.compareTo(dishGiftAmount) <= 0) {
|
||||||
|
cardDO.setGiftAmount(giftAmount.add(money).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
} else {
|
||||||
|
cardDO.setGiftAmount(giftAmount.add(dishGiftAmount).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
BigDecimal money1 = money.subtract(dishGiftAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||||
|
|
||||||
if(money.compareTo(dishGiftAmount)<=0){
|
if (money1.compareTo(dishCashAmount) <= 0) {
|
||||||
cardDO.setGiftAmount(giftAmount.add(money).setScale(2, BigDecimal.ROUND_HALF_UP));
|
cardDO.setCashAmount(cashAmount.add(money1).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
}else {
|
} else {
|
||||||
cardDO.setGiftAmount(giftAmount.add(dishGiftAmount).setScale(2, BigDecimal.ROUND_HALF_UP));
|
cardDO.setCashAmount(cashAmount.add(dishCashAmount).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
BigDecimal money1 = money.subtract(dishGiftAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
|
BigDecimal money2 = money1.subtract(dishCashAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||||
|
if (money2.compareTo(dishWxAmount) <= 0) {
|
||||||
|
cardDO.setWxAmount(wxAmount.add(money2).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
} else {
|
||||||
|
cardDO.setWxAmount(wxAmount.add(dishWxAmount).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
}
|
||||||
|
|
||||||
if(money1.compareTo(dishCashAmount)<=0){
|
}
|
||||||
cardDO.setCashAmount(cashAmount.add(money1).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
||||||
}else {
|
|
||||||
cardDO.setCashAmount(cashAmount.add(dishCashAmount).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
||||||
BigDecimal money2 = money1.subtract(dishCashAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
||||||
cardDO.setWxAmount(wxAmount.add(money2).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//记录
|
||||||
|
refundLog(dishOrderDO,money);
|
||||||
|
//订单处理
|
||||||
|
|
||||||
|
//可退款金额
|
||||||
|
dishOrderDO.setRefundAmount(BigDecimal.ZERO);
|
||||||
|
//待支付金额
|
||||||
|
if (dishOrderDO.getPayAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
BigDecimal newPayAmount = dishOrderDO.getPayAmount().subtract(money);
|
||||||
|
if (newPayAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
dishOrderDO.setPayAmount(newPayAmount);
|
||||||
|
} else {
|
||||||
|
handleOtherMoney(dishOrderDO,money);
|
||||||
|
dishOrderDO.setPayAmount(BigDecimal.ZERO);
|
||||||
|
dishOrderDO.setOrderStatus(DishOrderDO.COMPLETE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dishOrderMapper.updateById(dishOrderDO);
|
||||||
cardMapper.insert(cardDO);
|
cardMapper.insert(cardDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void handleOtherMoney(DishOrderDO dishOrderDO,BigDecimal money){
|
||||||
|
//查找其余未支付订单
|
||||||
|
List<DishOrderDO> dishOrderDOS = dishOrderMapper.selectList(Wrappers.<DishOrderDO>lambdaQuery().eq(DishOrderDO::getOrderStatus, DishOrderDO.TOCOMPLETE)
|
||||||
|
.ne(DishOrderDO::getId, dishOrderDO.getId()));
|
||||||
|
if (CollectionUtil.isNotEmpty(dishOrderDOS)){
|
||||||
|
//判断多出的金额来自哪一部分
|
||||||
|
BigDecimal payAmount = dishOrderDO.getPayAmount();
|
||||||
|
BigDecimal giftAmount = dishOrderDO.getGiftAmount();
|
||||||
|
BigDecimal cashAmount = dishOrderDO.getCashAmount();
|
||||||
|
BigDecimal wxAmount = dishOrderDO.getWxAmount();
|
||||||
|
|
||||||
|
//可用金额
|
||||||
|
BigDecimal gift = BigDecimal.ZERO;
|
||||||
|
BigDecimal cash = BigDecimal.ZERO;
|
||||||
|
BigDecimal wx = BigDecimal.ZERO;
|
||||||
|
|
||||||
|
//分配退款金额
|
||||||
|
if(money.compareTo(giftAmount)<=0){
|
||||||
|
gift = money;
|
||||||
|
}else {
|
||||||
|
gift = giftAmount;
|
||||||
|
BigDecimal left = money.subtract(giftAmount);
|
||||||
|
if(left.compareTo(cashAmount)<=0){
|
||||||
|
cash = left;
|
||||||
|
}else {
|
||||||
|
cash = cashAmount;
|
||||||
|
BigDecimal left1 = left.subtract(cashAmount);
|
||||||
|
if(left1.compareTo(wxAmount)<=0){
|
||||||
|
wx = left1;
|
||||||
|
}else {
|
||||||
|
wx = wxAmount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//去除该订单已支付的
|
||||||
|
if(payAmount.compareTo(gift)<=0){
|
||||||
|
gift = gift.subtract(payAmount);
|
||||||
|
}else {
|
||||||
|
BigDecimal left = payAmount.subtract(gift);
|
||||||
|
gift = BigDecimal.ZERO;
|
||||||
|
if(left.compareTo(cash)<=0){
|
||||||
|
cash = cash.subtract(left);
|
||||||
|
}else{
|
||||||
|
BigDecimal left1 = left.subtract(cash);
|
||||||
|
cash = BigDecimal.ZERO;
|
||||||
|
if(left1.compareTo(wx)<=0){
|
||||||
|
wx = wx.subtract(left1);
|
||||||
|
}else {
|
||||||
|
wx= BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//待修改的订单
|
||||||
|
ArrayList<DishOrderDO> update = new ArrayList<>();
|
||||||
|
|
||||||
|
//顺序补充直到金额用完跳出循环
|
||||||
|
for (DishOrderDO vo : dishOrderDOS){
|
||||||
|
BigDecimal voPayAmount = vo.getPayAmount();
|
||||||
|
|
||||||
|
//订单补充的金额
|
||||||
|
BigDecimal supGift = BigDecimal.ZERO;
|
||||||
|
BigDecimal supCash = BigDecimal.ZERO;
|
||||||
|
BigDecimal supWx = BigDecimal.ZERO;
|
||||||
|
|
||||||
|
|
||||||
|
//计算
|
||||||
|
if(voPayAmount.compareTo(gift)<=0){
|
||||||
|
gift = gift.subtract(voPayAmount);
|
||||||
|
supGift = voPayAmount;
|
||||||
|
}else {
|
||||||
|
voPayAmount = voPayAmount.subtract(gift);
|
||||||
|
supGift = gift;
|
||||||
|
gift = BigDecimal.ZERO;
|
||||||
|
|
||||||
|
if(voPayAmount.compareTo(cash)<=0){
|
||||||
|
cash = cash.subtract(voPayAmount);
|
||||||
|
supCash = voPayAmount;
|
||||||
|
}else{
|
||||||
|
voPayAmount = voPayAmount.subtract(cash);
|
||||||
|
supCash = cash;
|
||||||
|
cash = BigDecimal.ZERO;
|
||||||
|
|
||||||
|
if(voPayAmount.compareTo(wx)<=0){
|
||||||
|
wx = wx.subtract(voPayAmount);
|
||||||
|
supWx = voPayAmount;
|
||||||
|
}else {
|
||||||
|
voPayAmount = voPayAmount.subtract(wx);
|
||||||
|
supWx = wx;
|
||||||
|
wx= BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//更改数据
|
||||||
|
vo.setGiftAmount(vo.getGiftAmount().add(supGift));
|
||||||
|
vo.setCashAmount(vo.getCashAmount().add(supCash));
|
||||||
|
vo.setWxAmount(vo.getWxAmount().add(supWx));
|
||||||
|
vo.setPayAmount(voPayAmount);
|
||||||
|
vo.setRefundAmount(vo.getRefundAmount().add(supGift).add(supCash).add(supWx));
|
||||||
|
if(voPayAmount.compareTo(BigDecimal.ZERO)<=0){
|
||||||
|
vo.setOrderStatus(DishOrderDO.COMPLETE);
|
||||||
|
}
|
||||||
|
update.add(vo);
|
||||||
|
//判断是否跳出循环
|
||||||
|
if(gift.compareTo(BigDecimal.ZERO) == 0 && cash.compareTo(BigDecimal.ZERO) == 0 && wx.compareTo(BigDecimal.ZERO) ==0){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//批量
|
||||||
|
if(CollectionUtil.isNotEmpty(update)){
|
||||||
|
dishOrderMapper.updateBatch(update);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refundLog(DishOrderDO dishOrderDO,BigDecimal money){
|
||||||
|
BigDecimal giftAmount = dishOrderDO.getGiftAmount();
|
||||||
|
BigDecimal cashAmount = dishOrderDO.getCashAmount();
|
||||||
|
BigDecimal wxAmount = dishOrderDO.getWxAmount();
|
||||||
|
|
||||||
|
//可用金额
|
||||||
|
BigDecimal gift = BigDecimal.ZERO;
|
||||||
|
BigDecimal cash = BigDecimal.ZERO;
|
||||||
|
BigDecimal wx = BigDecimal.ZERO;
|
||||||
|
|
||||||
|
//分配退款金额
|
||||||
|
if(money.compareTo(giftAmount)<=0){
|
||||||
|
gift = money;
|
||||||
|
}else {
|
||||||
|
gift = giftAmount;
|
||||||
|
BigDecimal left = money.subtract(giftAmount);
|
||||||
|
if(left.compareTo(cashAmount)<=0){
|
||||||
|
cash = left;
|
||||||
|
}else {
|
||||||
|
cash = cashAmount;
|
||||||
|
BigDecimal left1 = left.subtract(cashAmount);
|
||||||
|
if(left1.compareTo(wxAmount)<=0){
|
||||||
|
wx = left1;
|
||||||
|
}else {
|
||||||
|
wx = wxAmount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<RefundLogDO> refundLogDOS = refundLogMapper.selectList(Wrappers.<RefundLogDO>lambdaQuery()
|
||||||
|
.apply("TO_DAYS(NOW())-TO_DAYS(create_time) = 0"));
|
||||||
|
if(CollectionUtil.isNotEmpty(refundLogDOS)){
|
||||||
|
RefundLogDO refundLogDO = refundLogDOS.get(0);
|
||||||
|
refundLogDO.setMoney(refundLogDO.getMoney().add(wx));
|
||||||
|
refundLogMapper.updateById(refundLogDO);
|
||||||
|
}else {
|
||||||
|
RefundLogDO refundLogDO = new RefundLogDO();
|
||||||
|
refundLogDO.setMoney(wx);
|
||||||
|
refundLogDO.setCreateTime(LocalDateTime.now());
|
||||||
|
refundLogMapper.insert(refundLogDO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public BigDecimal checkOrder(Long userId) {
|
public BigDecimal checkOrder(Long userId) {
|
||||||
|
|
||||||
LambdaQueryWrapper<DishOrderDO> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<DishOrderDO> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
wrapper.eq(DishOrderDO::getUserId,userId);
|
wrapper.eq(DishOrderDO::getUserId, userId);
|
||||||
wrapper.eq(DishOrderDO::getOrderStatus,DishOrderDO.TOCOMPLETE);
|
wrapper.eq(DishOrderDO::getOrderStatus, DishOrderDO.TOCOMPLETE);
|
||||||
|
|
||||||
List<DishOrderDO> dishOrderDOS = dishOrderMapper.selectList(wrapper);
|
List<DishOrderDO> dishOrderDOS = dishOrderMapper.selectList(wrapper);
|
||||||
|
|
||||||
if(CollectionUtil.isNotEmpty(dishOrderDOS)){
|
if (CollectionUtil.isNotEmpty(dishOrderDOS)) {
|
||||||
BigDecimal reduce = dishOrderDOS.stream().map(DishOrderDO::getTotalMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
|
BigDecimal reduce = dishOrderDOS.stream().map(DishOrderDO::getTotalMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
return reduce;
|
return reduce;
|
||||||
}else {
|
} else {
|
||||||
return BigDecimal.ZERO;
|
return BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -364,19 +569,20 @@ public class CardServiceImpl implements CardService {
|
|||||||
@Override
|
@Override
|
||||||
public BigDecimal getCashMoney(Long userId) {
|
public BigDecimal getCashMoney(Long userId) {
|
||||||
CardDO lastCardDO = cardMapper.selectOne(Wrappers.<CardDO>lambdaQuery().eq(CardDO::getUserId, userId)
|
CardDO lastCardDO = cardMapper.selectOne(Wrappers.<CardDO>lambdaQuery().eq(CardDO::getUserId, userId)
|
||||||
.orderByDesc(CardDO::getCreateTime).last(MemberConstants.LIMIT_ONE));
|
.orderByDesc(CardDO::getCreateTime).orderByDesc(CardDO::getId)
|
||||||
if(ObjectUtil.isNotEmpty(lastCardDO)){
|
.last(MemberConstants.LIMIT_ONE));
|
||||||
|
if (ObjectUtil.isNotEmpty(lastCardDO)) {
|
||||||
return lastCardDO.getCashAmount();
|
return lastCardDO.getCashAmount();
|
||||||
}
|
}
|
||||||
return BigDecimal.ZERO;
|
return BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean cashDraw(Long userId,BigDecimal money) {
|
public Boolean cashDraw(Long userId, BigDecimal money) {
|
||||||
CardDO lastCardDO = cardMapper.selectOne(Wrappers.<CardDO>lambdaQuery().eq(CardDO::getUserId, userId)
|
CardDO lastCardDO = cardMapper.selectOne(Wrappers.<CardDO>lambdaQuery().eq(CardDO::getUserId, userId)
|
||||||
.orderByDesc(CardDO::getCreateTime).last(MemberConstants.LIMIT_ONE));
|
.orderByDesc(CardDO::getCreateTime).orderByDesc(CardDO::getId).last(MemberConstants.LIMIT_ONE));
|
||||||
if(ObjectUtil.isEmpty(lastCardDO) || lastCardDO.getCashAmount().compareTo(BigDecimal.ZERO)<1
|
if (ObjectUtil.isEmpty(lastCardDO) || lastCardDO.getCashAmount().compareTo(BigDecimal.ZERO) < 1
|
||||||
|| money.compareTo(lastCardDO.getCashAmount())>0){
|
|| money.compareTo(lastCardDO.getCashAmount()) > 0) {
|
||||||
throw exception(CASH_AMOUNT_NOT_ENOUGH);
|
throw exception(CASH_AMOUNT_NOT_ENOUGH);
|
||||||
}
|
}
|
||||||
CardDO cardDO = new CardDO();
|
CardDO cardDO = new CardDO();
|
||||||
@ -385,7 +591,7 @@ public class CardServiceImpl implements CardService {
|
|||||||
cardDO.setChangeMoney(money);
|
cardDO.setChangeMoney(money);
|
||||||
cardDO.setType(CostTypeEnum.CASH_WITHDRAW.getCode());
|
cardDO.setType(CostTypeEnum.CASH_WITHDRAW.getCode());
|
||||||
|
|
||||||
BigDecimal oldMoney = lastCardDO.getMoney();
|
BigDecimal oldMoney = lastCardDO.getMoney();
|
||||||
BigDecimal oldWxAmount = lastCardDO.getWxAmount();
|
BigDecimal oldWxAmount = lastCardDO.getWxAmount();
|
||||||
BigDecimal oldCashAmount = lastCardDO.getCashAmount();
|
BigDecimal oldCashAmount = lastCardDO.getCashAmount();
|
||||||
BigDecimal oldGiftAmount = lastCardDO.getGiftAmount();
|
BigDecimal oldGiftAmount = lastCardDO.getGiftAmount();
|
||||||
@ -395,20 +601,127 @@ public class CardServiceImpl implements CardService {
|
|||||||
cardDO.setMoney(oldMoney.subtract(money));
|
cardDO.setMoney(oldMoney.subtract(money));
|
||||||
cardDO.setCashAmount(oldCashAmount.subtract(money));
|
cardDO.setCashAmount(oldCashAmount.subtract(money));
|
||||||
int insert = cardMapper.insert(cardDO);
|
int insert = cardMapper.insert(cardDO);
|
||||||
return insert>0;
|
return insert > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateOrderStatus(Long userId){
|
void updateOrderStatus(Long userId) {
|
||||||
LambdaQueryWrapper<DishOrderDO> wrapper = new LambdaQueryWrapper<>();
|
LambdaUpdateWrapper<DishOrderDO> wrapper = new LambdaUpdateWrapper<>();
|
||||||
|
|
||||||
wrapper.eq(DishOrderDO::getUserId,userId);
|
wrapper.eq(DishOrderDO::getUserId, userId);
|
||||||
wrapper.eq(DishOrderDO::getOrderStatus,DishOrderDO.TOCOMPLETE);
|
wrapper.eq(DishOrderDO::getOrderStatus, DishOrderDO.TOCOMPLETE);
|
||||||
|
wrapper.set(DishOrderDO::getOrderStatus, DishOrderDO.COMPLETE);
|
||||||
|
dishOrderMapper.update(wrapper);
|
||||||
|
|
||||||
List<DishOrderDO> dishOrderDOS = dishOrderMapper.selectList(wrapper);
|
}
|
||||||
if(CollectionUtil.isNotEmpty(dishOrderDOS)){
|
|
||||||
dishOrderDOS.forEach(vo -> vo.setOrderStatus(DishOrderDO.COMPLETE));
|
void handleOrderWx(Long userId, BigDecimal money, BigDecimal giftAmount) {
|
||||||
dishOrderMapper.updateBatch(dishOrderDOS);
|
BigDecimal wxMoney = money;
|
||||||
|
BigDecimal giftMoney = BigDecimal.ZERO;
|
||||||
|
if (giftAmount != null) {
|
||||||
|
wxMoney = money.subtract(giftMoney);
|
||||||
|
giftMoney = giftAmount;
|
||||||
|
}
|
||||||
|
//已审核的订单
|
||||||
|
List<Long> refundOrder = getRefundOrder();
|
||||||
|
|
||||||
|
//查询出所有未完全支付订单
|
||||||
|
List<DishOrderDO> dishOrderDOS = dishOrderMapper.selectList(Wrappers.<DishOrderDO>lambdaQuery()
|
||||||
|
.eq(DishOrderDO::getUserId, userId).eq(DishOrderDO::getOrderStatus, DishOrderDO.TOCOMPLETE));
|
||||||
|
|
||||||
|
ArrayList<DishOrderDO> updateList = new ArrayList<>();
|
||||||
|
if (CollectionUtil.isNotEmpty(dishOrderDOS)) {
|
||||||
|
for (DishOrderDO dishOrderDO : dishOrderDOS) {
|
||||||
|
BigDecimal payAmount = dishOrderDO.getPayAmount();
|
||||||
|
if(payAmount.compareTo(money)<=0){
|
||||||
|
dishOrderDO.setOrderStatus(DishOrderDO.COMPLETE);
|
||||||
|
dishOrderDO.setPayAmount(BigDecimal.ZERO);
|
||||||
|
dishOrderDO.setRefundAmount(dishOrderDO.getRefundAmount().add(payAmount));
|
||||||
|
if(refundOrder.contains(dishOrderDO.getId())){
|
||||||
|
dishOrderDO.setRefundAmount(BigDecimal.ZERO);
|
||||||
|
}
|
||||||
|
if(payAmount.compareTo(wxMoney)<=0){
|
||||||
|
dishOrderDO.setWxAmount(dishOrderDO.getWxAmount().add(payAmount));
|
||||||
|
wxMoney = wxMoney.subtract(payAmount);
|
||||||
|
}else {
|
||||||
|
dishOrderDO.setWxAmount(dishOrderDO.getWxAmount().add(wxMoney));
|
||||||
|
wxMoney = BigDecimal.ZERO;
|
||||||
|
BigDecimal left = payAmount.subtract(wxMoney);
|
||||||
|
dishOrderDO.setGiftAmount(dishOrderDO.getGiftAmount().add(left));
|
||||||
|
giftMoney = giftMoney.subtract(left);
|
||||||
|
}
|
||||||
|
money = money.subtract(payAmount);
|
||||||
|
|
||||||
|
updateList.add(dishOrderDO);
|
||||||
|
}else {
|
||||||
|
dishOrderDO.setPayAmount(payAmount.subtract(money));
|
||||||
|
dishOrderDO.setRefundAmount(dishOrderDO.getRefundAmount().add(money));
|
||||||
|
if(refundOrder.contains(dishOrderDO.getId())){
|
||||||
|
dishOrderDO.setRefundAmount(BigDecimal.ZERO);
|
||||||
|
}
|
||||||
|
dishOrderDO.setWxAmount(dishOrderDO.getWxAmount().add(wxMoney));
|
||||||
|
dishOrderDO.setGiftAmount(dishOrderDO.getGiftAmount().add(giftMoney));
|
||||||
|
updateList.add(dishOrderDO);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(CollectionUtil.isNotEmpty(updateList)){
|
||||||
|
dishOrderMapper.updateBatch(updateList);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handleOrderCash(List<Long> userIds, BigDecimal money) {
|
||||||
|
ArrayList<DishOrderDO> updateList = new ArrayList<>();
|
||||||
|
List<Long> refundOrder = getRefundOrder();
|
||||||
|
//查询出所有未完全支付订单
|
||||||
|
for (Long userId : userIds){
|
||||||
|
BigDecimal cashMoney = money;
|
||||||
|
|
||||||
|
List<DishOrderDO> dishOrderDOS = dishOrderMapper.selectList(Wrappers.<DishOrderDO>lambdaQuery()
|
||||||
|
.eq(DishOrderDO::getUserId, userId).eq(DishOrderDO::getOrderStatus, DishOrderDO.TOCOMPLETE));
|
||||||
|
|
||||||
|
if (CollectionUtil.isNotEmpty(dishOrderDOS)) {
|
||||||
|
for (DishOrderDO dishOrderDO : dishOrderDOS) {
|
||||||
|
BigDecimal payAmount = dishOrderDO.getPayAmount();
|
||||||
|
if(payAmount.compareTo(cashMoney)<=0){
|
||||||
|
dishOrderDO.setOrderStatus(DishOrderDO.COMPLETE);
|
||||||
|
dishOrderDO.setPayAmount(BigDecimal.ZERO);
|
||||||
|
dishOrderDO.setRefundAmount(dishOrderDO.getRefundAmount().add(payAmount));
|
||||||
|
if(refundOrder.contains(dishOrderDO.getId())){
|
||||||
|
dishOrderDO.setRefundAmount(BigDecimal.ZERO);
|
||||||
|
}
|
||||||
|
dishOrderDO.setCashAmount(dishOrderDO.getCashAmount().add(payAmount));
|
||||||
|
cashMoney = cashMoney.subtract(payAmount);
|
||||||
|
updateList.add(dishOrderDO);
|
||||||
|
}else {
|
||||||
|
dishOrderDO.setPayAmount(payAmount.subtract(cashMoney));
|
||||||
|
dishOrderDO.setRefundAmount(dishOrderDO.getRefundAmount().add(cashMoney));
|
||||||
|
if(refundOrder.contains(dishOrderDO.getId())){
|
||||||
|
dishOrderDO.setRefundAmount(BigDecimal.ZERO);
|
||||||
|
}
|
||||||
|
dishOrderDO.setCashAmount(dishOrderDO.getCashAmount().add(cashMoney));
|
||||||
|
updateList.add(dishOrderDO);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(CollectionUtil.isNotEmpty(updateList)){
|
||||||
|
dishOrderMapper.updateBatch(updateList);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<Long> getRefundOrder(){
|
||||||
|
List<RefundDO> refundDOS = refundMapper.selectList(Wrappers.<RefundDO>lambdaQuery().in(RefundDO::getStatus, Arrays.asList("2", "3")));
|
||||||
|
ArrayList<Long> orderIds = new ArrayList<>();
|
||||||
|
if(CollectionUtil.isNotEmpty(refundDOS)){
|
||||||
|
List<Long> collect = refundDOS.stream().map(RefundDO::getOrderId).collect(Collectors.toList());
|
||||||
|
orderIds.addAll(collect);
|
||||||
|
}
|
||||||
|
|
||||||
|
return orderIds;
|
||||||
|
}
|
||||||
}
|
}
|
@ -186,7 +186,9 @@ public class CarteenMoneyServiceImpl implements CarteenMoneyService {
|
|||||||
.carteenName(value.get(0).getStoreName())
|
.carteenName(value.get(0).getStoreName())
|
||||||
.carteenId(storeId1)
|
.carteenId(storeId1)
|
||||||
.successMoney(bigDecimal1)
|
.successMoney(bigDecimal1)
|
||||||
.sumMoney(bigDecimal1).build();
|
.sumMoney(bigDecimal1)
|
||||||
|
.build();
|
||||||
|
build.setCreateTime( LocalDateTime.now().minusDays(1));
|
||||||
list.add(build);
|
list.add(build);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
|
@ -251,6 +251,9 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
|||||||
if (diningPlatesDO == null || diningPlatesDO.getUserId() == null) {
|
if (diningPlatesDO == null || diningPlatesDO.getUserId() == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
//刷新绑定时间
|
||||||
|
diningPlatesDO.setBindingTime(LocalDateTime.now());
|
||||||
|
diningPlatesMapper.updateById(diningPlatesDO);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,7 +273,6 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void checkDiningPlates(DiningPlatesDO diningPlatesDO) {
|
public void checkDiningPlates(DiningPlatesDO diningPlatesDO) {
|
||||||
if (diningPlatesDO == null) {
|
if (diningPlatesDO == null) {
|
||||||
throw exception(DINING_PLATES_NOT_EXISTS);
|
throw exception(DINING_PLATES_NOT_EXISTS);
|
||||||
|
@ -176,6 +176,8 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
dishOrderDO.setRefundStatus(refundService.getRefundStatus(dishOrderDO.getId()));
|
dishOrderDO.setRefundStatus(refundService.getRefundStatus(dishOrderDO.getId()));
|
||||||
}
|
}
|
||||||
dishOrderDO.setDetailList(appOrderDetailRespVOS);
|
dishOrderDO.setDetailList(appOrderDetailRespVOS);
|
||||||
|
dishOrderDO.setMoney(cardMapper.getMoneyByUsr(dishOrderDO.getUserId()));
|
||||||
|
|
||||||
}
|
}
|
||||||
return appOrderRespVOPageResult;
|
return appOrderRespVOPageResult;
|
||||||
}
|
}
|
||||||
@ -232,6 +234,8 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
bean.setPayMethods("钱包");
|
bean.setPayMethods("钱包");
|
||||||
bean.setUserAccount(userDO.getMobile());
|
bean.setUserAccount(userDO.getMobile());
|
||||||
bean.setTimePeriod(TimePeriodEnum.getTimeName(bean.getCreateTime()));
|
bean.setTimePeriod(TimePeriodEnum.getTimeName(bean.getCreateTime()));
|
||||||
|
BigDecimal moneyByUsr = cardMapper.getMoneyByUsr(bean.getUserId());
|
||||||
|
bean.setMoney(moneyByUsr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -72,11 +72,13 @@ public class OrderDetailServiceImpl implements OrderDetailService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long createOrderDetail(AppOrderDetailSaveReqVO createReqVO) {
|
public Long createOrderDetail(AppOrderDetailSaveReqVO createReqVO) {
|
||||||
//判定餐盘是否绑定
|
//判定餐盘是否绑定并刷新绑定时间
|
||||||
Boolean b = diningPlatesService.checkBind(createReqVO.getDiningPlatesNum());
|
Boolean b = diningPlatesService.checkBind(createReqVO.getDiningPlatesNum());
|
||||||
if(!b){
|
if(!b){
|
||||||
throw exception(DINING_PLATES_NOT_BIND);
|
throw exception(DINING_PLATES_NOT_BIND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//餐盘号去获取订单
|
//餐盘号去获取订单
|
||||||
DishOrderDO dishOrderDO = dishOrderMapper.selectOne(Wrappers.<DishOrderDO>lambdaQuery().eq(DishOrderDO::getDiningPlatesNum, createReqVO.getDiningPlatesNum())
|
DishOrderDO dishOrderDO = dishOrderMapper.selectOne(Wrappers.<DishOrderDO>lambdaQuery().eq(DishOrderDO::getDiningPlatesNum, createReqVO.getDiningPlatesNum())
|
||||||
.eq(DishOrderDO::getOrderStatus, DishOrderDO.INCOMPLETE)
|
.eq(DishOrderDO::getOrderStatus, DishOrderDO.INCOMPLETE)
|
||||||
|
@ -7,11 +7,14 @@ 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.admin.refund.vo.RefundSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.member.controller.app.refund.vo.AppRefundSaveReqVO;
|
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.dataobject.refund.RefundDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||||
import cn.iocoder.yudao.module.member.dal.mysql.refund.IntegralRefundMapper;
|
import cn.iocoder.yudao.module.member.dal.mysql.refund.IntegralRefundMapper;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper;
|
||||||
import cn.iocoder.yudao.module.member.enums.RefundStatusEnum;
|
import cn.iocoder.yudao.module.member.enums.RefundStatusEnum;
|
||||||
import cn.iocoder.yudao.module.member.service.card.CardService;
|
import cn.iocoder.yudao.module.member.service.card.CardService;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@ -32,6 +35,8 @@ public class RefundServiceImpl implements RefundService {
|
|||||||
private IntegralRefundMapper refundMapper;
|
private IntegralRefundMapper refundMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private CardService cardService;
|
private CardService cardService;
|
||||||
|
@Resource
|
||||||
|
private MemberUserMapper userMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createRefund(RefundSaveReqVO createReqVO) {
|
public Long createRefund(RefundSaveReqVO createReqVO) {
|
||||||
@ -43,6 +48,7 @@ public class RefundServiceImpl implements RefundService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateRefund(RefundSaveReqVO updateReqVO) {
|
public void updateRefund(RefundSaveReqVO updateReqVO) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateRefundExists(updateReqVO.getId());
|
validateRefundExists(updateReqVO.getId());
|
||||||
@ -82,6 +88,8 @@ public class RefundServiceImpl implements RefundService {
|
|||||||
public Long createAppRefund(AppRefundSaveReqVO createReqVO) {
|
public Long createAppRefund(AppRefundSaveReqVO createReqVO) {
|
||||||
// 插入
|
// 插入
|
||||||
RefundDO refund = BeanUtils.toBean(createReqVO, RefundDO.class);
|
RefundDO refund = BeanUtils.toBean(createReqVO, RefundDO.class);
|
||||||
|
MemberUserDO memberUserDO = userMapper.selectById(refund.getUserId());
|
||||||
|
refund.setMobile(memberUserDO.getMobile());
|
||||||
refundMapper.insert(refund);
|
refundMapper.insert(refund);
|
||||||
// 返回
|
// 返回
|
||||||
return refund.getId();
|
return refund.getId();
|
||||||
|
@ -44,6 +44,9 @@ public class MemberTagServiceImpl implements MemberTagService {
|
|||||||
public Long createTag(MemberTagCreateReqVO createReqVO) {
|
public Long createTag(MemberTagCreateReqVO createReqVO) {
|
||||||
// 校验名称唯一
|
// 校验名称唯一
|
||||||
validateTagNameUnique(null, createReqVO.getName());
|
validateTagNameUnique(null, createReqVO.getName());
|
||||||
|
// 校验优先级唯一
|
||||||
|
validateTagStateUnique(null, createReqVO.getState());
|
||||||
|
|
||||||
// 插入
|
// 插入
|
||||||
MemberTagDO tag = MemberTagConvert.INSTANCE.convert(createReqVO);
|
MemberTagDO tag = MemberTagConvert.INSTANCE.convert(createReqVO);
|
||||||
memberTagMapper.insert(tag);
|
memberTagMapper.insert(tag);
|
||||||
@ -57,6 +60,8 @@ public class MemberTagServiceImpl implements MemberTagService {
|
|||||||
validateTagExists(updateReqVO.getId());
|
validateTagExists(updateReqVO.getId());
|
||||||
// 校验名称唯一
|
// 校验名称唯一
|
||||||
validateTagNameUnique(updateReqVO.getId(), updateReqVO.getName());
|
validateTagNameUnique(updateReqVO.getId(), updateReqVO.getName());
|
||||||
|
// 校验优先级唯一
|
||||||
|
validateTagStateUnique(updateReqVO.getId(), updateReqVO.getState());
|
||||||
// 更新
|
// 更新
|
||||||
MemberTagDO updateObj = MemberTagConvert.INSTANCE.convert(updateReqVO);
|
MemberTagDO updateObj = MemberTagConvert.INSTANCE.convert(updateReqVO);
|
||||||
memberTagMapper.updateById(updateObj);
|
memberTagMapper.updateById(updateObj);
|
||||||
@ -96,6 +101,24 @@ public class MemberTagServiceImpl implements MemberTagService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void validateTagStateUnique(Long id, String state) {
|
||||||
|
if (StrUtil.isBlank(state)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MemberTagDO tag = memberTagMapper.selelctByState(state);
|
||||||
|
if (tag == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果 id 为空,说明不用比较是否为相同 id 的标签
|
||||||
|
if (id == null) {
|
||||||
|
throw exception(TAG_STATE_EXISTS);
|
||||||
|
}
|
||||||
|
if (!tag.getId().equals(id)) {
|
||||||
|
throw exception(TAG_STATE_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void validateTagHasUser(Long id) {
|
void validateTagHasUser(Long id) {
|
||||||
Long count = memberUserService.getUserCountByTagId(id);
|
Long count = memberUserService.getUserCountByTagId(id);
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
|
@ -243,5 +243,5 @@ public interface MemberUserService {
|
|||||||
|
|
||||||
String getCardId(Long userId);
|
String getCardId(Long userId);
|
||||||
|
|
||||||
BigDecimal getReductionAmount(Long userId,BigDecimal money);
|
BigDecimal getReductionAmount(Long userId,BigDecimal money,LocalDateTime time);
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.ibatis.annotations.Case;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@ -75,12 +76,7 @@ import java.math.RoundingMode;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.temporal.WeekFields;
|
import java.time.temporal.WeekFields;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
@ -747,7 +743,10 @@ public class MemberUserServiceImpl implements MemberUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BigDecimal getReductionAmount(Long userId, BigDecimal money) {
|
public BigDecimal getReductionAmount(Long userId, BigDecimal money,LocalDateTime time) {
|
||||||
|
|
||||||
|
String timePeriod = TimePeriodEnum.getTimePeriod(time);
|
||||||
|
|
||||||
MemberUserDO memberUserDO = memberUserMapper.selectById(userId);
|
MemberUserDO memberUserDO = memberUserMapper.selectById(userId);
|
||||||
List<Long> tagIds = memberUserDO.getTagIds();
|
List<Long> tagIds = memberUserDO.getTagIds();
|
||||||
if (CollectionUtil.isEmpty(tagIds)){
|
if (CollectionUtil.isEmpty(tagIds)){
|
||||||
@ -756,25 +755,62 @@ public class MemberUserServiceImpl implements MemberUserService {
|
|||||||
List<MemberTagDO> tagList = memberTagService.getTagList(tagIds);
|
List<MemberTagDO> tagList = memberTagService.getTagList(tagIds);
|
||||||
|
|
||||||
if(tagList.size()>1){
|
if(tagList.size()>1){
|
||||||
List<MemberTagDO> collect = tagList.stream().filter(vo -> vo.getState().equals("1")).collect(Collectors.toList());
|
//排序
|
||||||
if(CollectionUtil.isEmpty(collect)){
|
List<MemberTagDO> collect = tagList.stream().sorted(Comparator.comparing(MemberTagDO::getState))
|
||||||
return countAmount(tagList.get(0),money);
|
.collect(Collectors.toList());
|
||||||
}else {
|
return countAmount(collect.get(0),money,timePeriod);
|
||||||
return countAmount(collect.get(0),money);
|
|
||||||
}
|
|
||||||
}else {
|
}else {
|
||||||
return countAmount(tagList.get(0),money);
|
return countAmount(tagList.get(0),money,timePeriod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public BigDecimal countAmount(MemberTagDO memberTagDO,BigDecimal money){
|
public BigDecimal countAmount(MemberTagDO memberTagDO,BigDecimal money,String timePeriod ){
|
||||||
if(memberTagDO.getType().equals("1")){
|
if(memberTagDO.getType().equals("1")){
|
||||||
BigDecimal bigDecimal = money.multiply(memberTagDO.getProportion()).setScale(2, RoundingMode.HALF_UP);
|
if (memberTagDO.getTimeFlag().equals("0")){
|
||||||
return bigDecimal;
|
return money.multiply(memberTagDO.getProportion()).setScale(2, RoundingMode.HALF_UP);
|
||||||
|
}else {
|
||||||
|
BigDecimal bigDecimal;
|
||||||
|
switch (timePeriod){
|
||||||
|
case "2":
|
||||||
|
bigDecimal = money.multiply(memberTagDO.getMorning()).setScale(2, RoundingMode.HALF_UP);
|
||||||
|
break;
|
||||||
|
case "3":
|
||||||
|
bigDecimal = money.multiply(memberTagDO.getNoon()).setScale(2, RoundingMode.HALF_UP);
|
||||||
|
break;
|
||||||
|
case "4":
|
||||||
|
bigDecimal = money.multiply(memberTagDO.getNight()).setScale(2, RoundingMode.HALF_UP);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
bigDecimal = BigDecimal.ZERO;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return bigDecimal;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if(memberTagDO.getType().equals("2")){
|
if(memberTagDO.getType().equals("2")){
|
||||||
return memberTagDO.getAmount();
|
if (memberTagDO.getTimeFlag().equals("0")){
|
||||||
|
return memberTagDO.getAmount();
|
||||||
|
}else {
|
||||||
|
BigDecimal bigDecimal;
|
||||||
|
switch (timePeriod){
|
||||||
|
case "2":
|
||||||
|
bigDecimal = memberTagDO.getMorning();
|
||||||
|
break;
|
||||||
|
case "3":
|
||||||
|
bigDecimal = memberTagDO.getNoon();
|
||||||
|
break;
|
||||||
|
case "4":
|
||||||
|
bigDecimal = memberTagDO.getNight();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
bigDecimal = BigDecimal.ZERO;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return bigDecimal;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return BigDecimal.ZERO;
|
return BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ public class MemberConstants {
|
|||||||
/**
|
/**
|
||||||
* 报警余额
|
* 报警余额
|
||||||
*/
|
*/
|
||||||
public static final BigDecimal ALARM_BALANCE = new BigDecimal("30");
|
public static final BigDecimal ALARM_BALANCE = new BigDecimal("15");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 时间格式
|
* 时间格式
|
||||||
|
@ -92,7 +92,7 @@ public interface ErrorCodeConstants {
|
|||||||
|
|
||||||
ErrorCode DIVIDE_NOT_EXISTS = new ErrorCode(1_007_902_001, "分账单不存在");
|
ErrorCode DIVIDE_NOT_EXISTS = new ErrorCode(1_007_902_001, "分账单不存在");
|
||||||
ErrorCode ORDER_NOT_COMPLETE = new ErrorCode(1_007_902_002, "还有订单尚未结算");
|
ErrorCode ORDER_NOT_COMPLETE = new ErrorCode(1_007_902_002, "还有订单尚未结算");
|
||||||
ErrorCode WX_ACCOUNT_NO = new ErrorCode(1_007_902_002, "微信充值金额已用完");
|
ErrorCode WX_ACCOUNT_NO = new ErrorCode(1_007_902_002, "微信充值金额不足");
|
||||||
|
|
||||||
|
|
||||||
ErrorCode DIVIDE_COMPANY_NOT_EXISTS = new ErrorCode(1_007_903_001, "分账公司不存在");
|
ErrorCode DIVIDE_COMPANY_NOT_EXISTS = new ErrorCode(1_007_903_001, "分账公司不存在");
|
||||||
|
@ -10,7 +10,7 @@ public class DrawMoneyVO {
|
|||||||
@Schema(description = "用户编号")
|
@Schema(description = "用户编号")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
@Schema(description = "总金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "30938")
|
@Schema(description = "总金额,单位:分")
|
||||||
//@NotNull(message = "总金额,单位:分不能为空")
|
//@NotNull(message = "总金额,单位:分不能为空")
|
||||||
private Integer totalPrice;
|
private Integer totalPrice;
|
||||||
/**
|
/**
|
||||||
|
@ -31,9 +31,12 @@ public interface DivideMapper extends BaseMapperX<DivideDO> {
|
|||||||
.orderByDesc(DivideDO::getId));
|
.orderByDesc(DivideDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Select("select sum(total_money) from member_dish_order where DATE(create_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)")
|
@Select("select sum(wx_amount) from member_dish_order where DATE(create_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)")
|
||||||
BigDecimal getToday();
|
BigDecimal getToday();
|
||||||
|
|
||||||
|
@Select("select money from member_refund_log where DATE(create_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)")
|
||||||
|
BigDecimal getRefund();
|
||||||
|
|
||||||
@Select("select wx_amount from member_card where user_id = #{userId} order by create_time desc limit 1")
|
@Select("select wx_amount from member_card where user_id = #{userId} order by create_time desc limit 1")
|
||||||
BigDecimal getWxAmount(Long userId);
|
BigDecimal getWxAmount(Long userId);
|
||||||
|
|
||||||
|
@ -172,16 +172,24 @@ public class DivideServiceImpl implements DivideService {
|
|||||||
public int startDivide() {
|
public int startDivide() {
|
||||||
|
|
||||||
BigDecimal today = divideMapper.getToday();
|
BigDecimal today = divideMapper.getToday();
|
||||||
|
|
||||||
if (today == null) {
|
if (today == null) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//转换单位 元-->分
|
||||||
int money = today.multiply(new BigDecimal("100")).intValue();
|
int money = today.multiply(new BigDecimal("100")).intValue();
|
||||||
|
|
||||||
|
//去除当天退款
|
||||||
|
BigDecimal refundToday = divideMapper.getRefund();
|
||||||
|
if (refundToday == null) {
|
||||||
|
refundToday = BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
int refund = refundToday.multiply(new BigDecimal("100")).intValue();
|
||||||
|
money = money-refund;
|
||||||
|
|
||||||
|
//查询29天内的充值订单,原因:微信30天自动解冻,订单将不能分账
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
LocalDateTime thirtyDaysAgo = now.minusDays(30);
|
LocalDateTime thirtyDaysAgo = now.minusDays(29);
|
||||||
|
|
||||||
|
|
||||||
List<DivideDO> divideDOS = divideMapper.selectList(Wrappers.<DivideDO>lambdaQuery()
|
List<DivideDO> divideDOS = divideMapper.selectList(Wrappers.<DivideDO>lambdaQuery()
|
||||||
.eq(DivideDO::getStatus, PayDivideStatusRespEnum.WAITING.getStatus())
|
.eq(DivideDO::getStatus, PayDivideStatusRespEnum.WAITING.getStatus())
|
||||||
.eq(DivideDO::getUnfreezeStatus,"0")
|
.eq(DivideDO::getUnfreezeStatus,"0")
|
||||||
@ -374,10 +382,19 @@ public class DivideServiceImpl implements DivideService {
|
|||||||
throw new ServiceException(WX_ACCOUNT_NO);
|
throw new ServiceException(WX_ACCOUNT_NO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//判断是否有金额可退款
|
||||||
|
|
||||||
int money = wxAmount.multiply(new BigDecimal("100")).intValue();
|
int money = wxAmount.multiply(new BigDecimal("100")).intValue();
|
||||||
if (money <= 0) {
|
if (money <= 0 ) {
|
||||||
throw new ServiceException(WX_ACCOUNT_NO);
|
throw new ServiceException(WX_ACCOUNT_NO);
|
||||||
}
|
}
|
||||||
|
//指定金额
|
||||||
|
if(drawMoneyVO.getTotalPrice()!=null){
|
||||||
|
if (money < drawMoneyVO.getTotalPrice() ) {
|
||||||
|
throw new ServiceException(WX_ACCOUNT_NO);
|
||||||
|
}
|
||||||
|
money = drawMoneyVO.getTotalPrice();
|
||||||
|
}
|
||||||
LocalDateTime now = LocalDateTime.now(); // 获取当前时间
|
LocalDateTime now = LocalDateTime.now(); // 获取当前时间
|
||||||
LocalDateTime threeYearsAgo = now.minusDays(365);
|
LocalDateTime threeYearsAgo = now.minusDays(365);
|
||||||
|
|
||||||
@ -712,6 +729,7 @@ public class DivideServiceImpl implements DivideService {
|
|||||||
DivideCardDO lastCardDO = divideCardMapper.selectOne(Wrappers.<DivideCardDO>lambdaQuery()
|
DivideCardDO lastCardDO = divideCardMapper.selectOne(Wrappers.<DivideCardDO>lambdaQuery()
|
||||||
.eq(DivideCardDO::getUserId, userId)
|
.eq(DivideCardDO::getUserId, userId)
|
||||||
.orderByDesc(DivideCardDO::getCreateTime)
|
.orderByDesc(DivideCardDO::getCreateTime)
|
||||||
|
.orderByDesc(DivideCardDO::getId)
|
||||||
.last("limit 1"));
|
.last("limit 1"));
|
||||||
|
|
||||||
BigDecimal changeMoney = new BigDecimal(amount).divide(new BigDecimal("100"));
|
BigDecimal changeMoney = new BigDecimal(amount).divide(new BigDecimal("100"));
|
||||||
|
@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.pay.controller.admin.divideinfo.vo.DivideInfoSave
|
|||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.divideinfo.DivideInfoDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.divideinfo.DivideInfoDO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.mysql.divideinfo.DivideInfoMapper;
|
import cn.iocoder.yudao.module.pay.dal.mysql.divideinfo.DivideInfoMapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
@ -72,12 +73,15 @@ public class DivideInfoServiceImpl implements DivideInfoService {
|
|||||||
PageResult<DivideInfoDO> divideInfoDOPageResult = divideInfoMapper.selectPage(pageReqVO);
|
PageResult<DivideInfoDO> divideInfoDOPageResult = divideInfoMapper.selectPage(pageReqVO);
|
||||||
List<DivideInfoDO> list = divideInfoDOPageResult.getList();
|
List<DivideInfoDO> list = divideInfoDOPageResult.getList();
|
||||||
for (DivideInfoDO divideInfoDO:list){
|
for (DivideInfoDO divideInfoDO:list){
|
||||||
// 解析时间字符串
|
if(StringUtils.isNotBlank(divideInfoDO.getDFinishTime())){
|
||||||
ZonedDateTime zonedDateTime = ZonedDateTime.parse(divideInfoDO.getDFinishTime());
|
// 解析时间字符串
|
||||||
// 定义所需的时间格式
|
ZonedDateTime zonedDateTime = ZonedDateTime.parse(divideInfoDO.getDFinishTime());
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
// 定义所需的时间格式
|
||||||
// 格式化时间字符串
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
divideInfoDO.setDFinishTime(zonedDateTime.format(formatter));
|
// 格式化时间字符串
|
||||||
|
divideInfoDO.setDFinishTime(zonedDateTime.format(formatter));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return divideInfoDOPageResult;
|
return divideInfoDOPageResult;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user