'多数量商品售后功能'
This commit is contained in:
parent
3cabf0a32c
commit
71fb4b2b2b
@ -17,7 +17,6 @@ import java.util.List;
|
|||||||
* 售后通知
|
* 售后通知
|
||||||
*
|
*
|
||||||
* @author paulG
|
* @author paulG
|
||||||
* @since 2020/12/9
|
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
|
@ -209,6 +209,7 @@ public enum ResultCode {
|
|||||||
AFTER_STATUS_ERROR(33006, "售后状态错误,请刷新页面"),
|
AFTER_STATUS_ERROR(33006, "售后状态错误,请刷新页面"),
|
||||||
RETURN_MONEY_OFFLINE_BANK_ERROR(33007, "当账号类型为银行转账时,银行信息不能为空"),
|
RETURN_MONEY_OFFLINE_BANK_ERROR(33007, "当账号类型为银行转账时,银行信息不能为空"),
|
||||||
AFTER_SALES_PRICE_ERROR(33004, "申请退款金额错误"),
|
AFTER_SALES_PRICE_ERROR(33004, "申请退款金额错误"),
|
||||||
|
AFTER_GOODS_NUMBER_ERROR(33008, "申请售后商品数量错误"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 投诉
|
* 投诉
|
||||||
|
@ -112,6 +112,12 @@ public class OrderItem extends BaseEntity {
|
|||||||
@ApiModelProperty(value = "交易投诉id")
|
@ApiModelProperty(value = "交易投诉id")
|
||||||
private String complainId;
|
private String complainId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "已退货商品数量")
|
||||||
|
private Integer returnGoodsNumber;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "正在进行退货中的商品数量")
|
||||||
|
private Integer isGoodsNumber;
|
||||||
|
|
||||||
public OrderItem(CartSkuVO cartSkuVO, CartVO cartVO, TradeDTO tradeDTO) {
|
public OrderItem(CartSkuVO cartSkuVO, CartVO cartVO, TradeDTO tradeDTO) {
|
||||||
String oldId = this.getId();
|
String oldId = this.getId();
|
||||||
BeanUtil.copyProperties(cartSkuVO.getGoodsSku(), this);
|
BeanUtil.copyProperties(cartSkuVO.getGoodsSku(), this);
|
||||||
|
@ -14,7 +14,9 @@ public enum OrderItemAfterSaleStatusEnum {
|
|||||||
NEW("新订单,不能申请售后"),
|
NEW("新订单,不能申请售后"),
|
||||||
NOT_APPLIED("未申请"),
|
NOT_APPLIED("未申请"),
|
||||||
ALREADY_APPLIED("已申请"),
|
ALREADY_APPLIED("已申请"),
|
||||||
EXPIRED("已失效不允许申请售后");
|
EXPIRED("已失效不允许申请售后"),
|
||||||
|
PART_AFTER_SALE("部分售后");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private final String description;
|
private final String description;
|
||||||
|
@ -54,5 +54,10 @@ public class AfterSaleApplyVO {
|
|||||||
@ApiModelProperty(value = "是否支持退款")
|
@ApiModelProperty(value = "是否支持退款")
|
||||||
private Boolean returnMoney;
|
private Boolean returnMoney;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "会员ID")
|
||||||
|
private String memberId;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import cn.lili.common.security.enums.UserEnums;
|
|||||||
import cn.lili.common.utils.BeanUtil;
|
import cn.lili.common.utils.BeanUtil;
|
||||||
import cn.lili.common.utils.CurrencyUtil;
|
import cn.lili.common.utils.CurrencyUtil;
|
||||||
import cn.lili.common.utils.SnowFlake;
|
import cn.lili.common.utils.SnowFlake;
|
||||||
|
import cn.lili.common.utils.StringUtils;
|
||||||
import cn.lili.common.vo.PageVO;
|
import cn.lili.common.vo.PageVO;
|
||||||
import cn.lili.modules.order.order.aop.AfterSaleLogPoint;
|
import cn.lili.modules.order.order.aop.AfterSaleLogPoint;
|
||||||
import cn.lili.modules.order.order.entity.dos.AfterSale;
|
import cn.lili.modules.order.order.entity.dos.AfterSale;
|
||||||
@ -156,6 +157,8 @@ public class AfterSaleServiceImpl extends ServiceImpl<AfterSaleMapper, AfterSale
|
|||||||
afterSaleApplyVO.setReturnMoney(true);
|
afterSaleApplyVO.setReturnMoney(true);
|
||||||
afterSaleApplyVO.setReturnGoods(true);
|
afterSaleApplyVO.setReturnGoods(true);
|
||||||
}
|
}
|
||||||
|
//获取可售后商品数量(商品总数量-已退货数量)
|
||||||
|
|
||||||
|
|
||||||
afterSaleApplyVO.setAccountType(order.getPaymentMethod());
|
afterSaleApplyVO.setAccountType(order.getPaymentMethod());
|
||||||
afterSaleApplyVO.setApplyRefundPrice(CurrencyUtil.div(orderItem.getFlowPrice(), orderItem.getNum()));
|
afterSaleApplyVO.setApplyRefundPrice(CurrencyUtil.div(orderItem.getFlowPrice(), orderItem.getNum()));
|
||||||
@ -165,6 +168,7 @@ public class AfterSaleServiceImpl extends ServiceImpl<AfterSaleMapper, AfterSale
|
|||||||
afterSaleApplyVO.setImage(orderItem.getImage());
|
afterSaleApplyVO.setImage(orderItem.getImage());
|
||||||
afterSaleApplyVO.setGoodsPrice(orderItem.getGoodsPrice());
|
afterSaleApplyVO.setGoodsPrice(orderItem.getGoodsPrice());
|
||||||
afterSaleApplyVO.setSkuId(orderItem.getSkuId());
|
afterSaleApplyVO.setSkuId(orderItem.getSkuId());
|
||||||
|
afterSaleApplyVO.setMemberId(order.getMemberId());
|
||||||
return afterSaleApplyVO;
|
return afterSaleApplyVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,8 +226,9 @@ public class AfterSaleServiceImpl extends ServiceImpl<AfterSaleMapper, AfterSale
|
|||||||
afterSale.setAuditRemark(remark);
|
afterSale.setAuditRemark(remark);
|
||||||
|
|
||||||
//根据售后编号修改售后单
|
//根据售后编号修改售后单
|
||||||
updateAfterSale(afterSaleSn, afterSale);
|
this.updateAfterSale(afterSaleSn, afterSale);
|
||||||
|
//获取商品已完成售后或正在进行的售后订单。修改订单售后状态
|
||||||
|
this.getAfterSaleList(afterSale);
|
||||||
//发送售后消息
|
//发送售后消息
|
||||||
this.sendAfterSaleMessage(afterSale);
|
this.sendAfterSaleMessage(afterSale);
|
||||||
|
|
||||||
@ -441,15 +446,55 @@ public class AfterSaleServiceImpl extends ServiceImpl<AfterSaleMapper, AfterSale
|
|||||||
double utilPrice = CurrencyUtil.div(orderItem.getPriceDetailDTO().getFlowPrice(), orderItem.getNum());
|
double utilPrice = CurrencyUtil.div(orderItem.getPriceDetailDTO().getFlowPrice(), orderItem.getNum());
|
||||||
afterSale.setApplyRefundPrice(CurrencyUtil.mul(afterSale.getNum(), utilPrice));
|
afterSale.setApplyRefundPrice(CurrencyUtil.mul(afterSale.getNum(), utilPrice));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//添加售后
|
//添加售后
|
||||||
this.save(afterSale);
|
this.save(afterSale);
|
||||||
//发送售后消息
|
//发送售后消息
|
||||||
this.sendAfterSaleMessage(afterSale);
|
this.sendAfterSaleMessage(afterSale);
|
||||||
//修改订单的售后状态
|
|
||||||
orderItemService.updateAfterSaleStatus(orderItem.getSn(), OrderItemAfterSaleStatusEnum.ALREADY_APPLIED);
|
//根据售后订单修改订单的售后状态
|
||||||
|
this.getAfterSaleList(afterSale);
|
||||||
|
|
||||||
return afterSale;
|
return afterSale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前商品已完成或正在进行中的售后记录修改订单的售后状态
|
||||||
|
*
|
||||||
|
* @author ftyy
|
||||||
|
* @Param afterSale
|
||||||
|
**/
|
||||||
|
private void getAfterSaleList(AfterSale afterSale) {
|
||||||
|
|
||||||
|
//根据商品id及订单sn获取子订单
|
||||||
|
OrderItem orderItem = orderItemService.getOne(new LambdaQueryWrapper<OrderItem>()
|
||||||
|
.eq(OrderItem::getOrderSn, afterSale.getOrderSn())
|
||||||
|
.eq(OrderItem::getGoodsId, afterSale.getGoodsId()));
|
||||||
|
|
||||||
|
//判断当前售后的状态---申请中
|
||||||
|
if (afterSale.getServiceStatus().equals(AfterSaleStatusEnum.APPLY.name())) {
|
||||||
|
orderItem.setIsGoodsNumber(orderItem.getIsGoodsNumber()+afterSale.getNum());
|
||||||
|
}
|
||||||
|
//判断当前售后的状态---已拒绝
|
||||||
|
if(afterSale.getServiceStatus().equals(AfterSaleStatusEnum.REFUSE.name())){
|
||||||
|
orderItem.setIsGoodsNumber(orderItem.getIsGoodsNumber()-afterSale.getNum());
|
||||||
|
}
|
||||||
|
//正在售后商品总数等于商品总数,修改订单售后状态为已申请
|
||||||
|
if (orderItem.getIsGoodsNumber().equals(orderItem.getNum())) {
|
||||||
|
//修改订单的售后状态--已申请
|
||||||
|
orderItem.setAfterSaleStatus(OrderItemAfterSaleStatusEnum.ALREADY_APPLIED.name());
|
||||||
|
} else {
|
||||||
|
//修改订单的售后状态--部分售后
|
||||||
|
orderItem.setAfterSaleStatus(OrderItemAfterSaleStatusEnum.PART_AFTER_SALE.name());
|
||||||
|
}
|
||||||
|
orderItemService.update(new LambdaUpdateWrapper<OrderItem>()
|
||||||
|
.eq(OrderItem::getSn, orderItem.getSn())
|
||||||
|
.set(OrderItem::getIsGoodsNumber, orderItem.getIsGoodsNumber())
|
||||||
|
.set(OrderItem::getAfterSaleStatus, orderItem.getAfterSaleStatus()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查当前订单状态是否为可申请当前售后类型的状态
|
* 检查当前订单状态是否为可申请当前售后类型的状态
|
||||||
*
|
*
|
||||||
@ -465,11 +510,17 @@ public class AfterSaleServiceImpl extends ServiceImpl<AfterSaleMapper, AfterSale
|
|||||||
//获取订单货物判断是否可申请售后
|
//获取订单货物判断是否可申请售后
|
||||||
OrderItem orderItem = orderItemService.getBySn(afterSaleDTO.getOrderItemSn());
|
OrderItem orderItem = orderItemService.getBySn(afterSaleDTO.getOrderItemSn());
|
||||||
|
|
||||||
//未申请售后订单货物才能进行申请
|
//未申请售后或部分售后订单货物才能进行申请
|
||||||
if (!orderItem.getAfterSaleStatus().equals(OrderItemAfterSaleStatusEnum.NOT_APPLIED.name())) {
|
if (!orderItem.getAfterSaleStatus().equals(OrderItemAfterSaleStatusEnum.NOT_APPLIED.name()) && !orderItem.getAfterSaleStatus().equals(OrderItemAfterSaleStatusEnum.PART_AFTER_SALE.name())) {
|
||||||
throw new ServiceException(ResultCode.AFTER_SALES_BAN);
|
throw new ServiceException(ResultCode.AFTER_SALES_BAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//申请商品数量不能超过商品总数量
|
||||||
|
if (afterSaleDTO.getNum() > (orderItem.getNum() - orderItem.getIsGoodsNumber())) {
|
||||||
|
throw new ServiceException(ResultCode.AFTER_GOODS_NUMBER_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//获取售后类型
|
//获取售后类型
|
||||||
Order order = orderService.getBySn(orderItem.getOrderSn());
|
Order order = orderService.getBySn(orderItem.getOrderSn());
|
||||||
AfterSaleTypeEnum afterSaleTypeEnum = AfterSaleTypeEnum.valueOf(afterSaleDTO.getServiceType());
|
AfterSaleTypeEnum afterSaleTypeEnum = AfterSaleTypeEnum.valueOf(afterSaleDTO.getServiceType());
|
||||||
@ -531,11 +582,16 @@ public class AfterSaleServiceImpl extends ServiceImpl<AfterSaleMapper, AfterSale
|
|||||||
* @param afterSale 售后单
|
* @param afterSale 售后单
|
||||||
*/
|
*/
|
||||||
private void updateAfterSale(String afterSaleSn, AfterSale afterSale) {
|
private void updateAfterSale(String afterSaleSn, AfterSale afterSale) {
|
||||||
|
//修改售后单状态
|
||||||
LambdaUpdateWrapper<AfterSale> queryWrapper = Wrappers.lambdaUpdate();
|
LambdaUpdateWrapper<AfterSale> queryWrapper = Wrappers.lambdaUpdate();
|
||||||
queryWrapper.eq(AfterSale::getSn, afterSaleSn);
|
queryWrapper.eq(AfterSale::getSn, afterSaleSn);
|
||||||
this.update(afterSale, queryWrapper);
|
this.update(afterSale, queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateOrderItemAfterSaleStatus() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送售后消息
|
* 发送售后消息
|
||||||
*
|
*
|
||||||
|
@ -139,7 +139,8 @@ public class StoreFlowServiceImpl extends ServiceImpl<StoreFlowMapper, StoreFlow
|
|||||||
|
|
||||||
|
|
||||||
//获取付款信息
|
//获取付款信息
|
||||||
StoreFlow payStoreFlow = this.getOne(new LambdaUpdateWrapper<StoreFlow>().eq(StoreFlow::getOrderItemSn, afterSale.getOrderItemSn()));
|
StoreFlow payStoreFlow = this.getOne(new LambdaUpdateWrapper<StoreFlow>().eq(StoreFlow::getOrderItemSn, afterSale.getOrderItemSn())
|
||||||
|
.eq(StoreFlow::getFlowType,FlowTypeEnum.PAY));
|
||||||
storeFlow.setNum(afterSale.getNum());
|
storeFlow.setNum(afterSale.getNum());
|
||||||
storeFlow.setCategoryId(payStoreFlow.getCategoryId());
|
storeFlow.setCategoryId(payStoreFlow.getCategoryId());
|
||||||
//佣金
|
//佣金
|
||||||
|
@ -4,11 +4,14 @@ import cn.lili.common.utils.SnowFlake;
|
|||||||
import cn.lili.common.utils.SpringContextUtil;
|
import cn.lili.common.utils.SpringContextUtil;
|
||||||
import cn.lili.modules.order.order.entity.dos.AfterSale;
|
import cn.lili.modules.order.order.entity.dos.AfterSale;
|
||||||
import cn.lili.modules.order.order.entity.dos.Order;
|
import cn.lili.modules.order.order.entity.dos.Order;
|
||||||
|
import cn.lili.modules.order.order.entity.dos.OrderItem;
|
||||||
import cn.lili.modules.order.order.service.AfterSaleService;
|
import cn.lili.modules.order.order.service.AfterSaleService;
|
||||||
|
import cn.lili.modules.order.order.service.OrderItemService;
|
||||||
import cn.lili.modules.order.order.service.OrderService;
|
import cn.lili.modules.order.order.service.OrderService;
|
||||||
import cn.lili.modules.order.order.service.StoreFlowService;
|
import cn.lili.modules.order.order.service.StoreFlowService;
|
||||||
import cn.lili.modules.payment.entity.RefundLog;
|
import cn.lili.modules.payment.entity.RefundLog;
|
||||||
import cn.lili.modules.payment.entity.enums.PaymentMethodEnum;
|
import cn.lili.modules.payment.entity.enums.PaymentMethodEnum;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -41,6 +44,11 @@ public class RefundSupport {
|
|||||||
*/
|
*/
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrderService orderService;
|
private OrderService orderService;
|
||||||
|
/**
|
||||||
|
* 子订单
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private OrderItemService orderItemService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 售后退款
|
* 售后退款
|
||||||
@ -69,10 +77,32 @@ public class RefundSupport {
|
|||||||
afterSaleService.update(new LambdaUpdateWrapper<AfterSale>()
|
afterSaleService.update(new LambdaUpdateWrapper<AfterSale>()
|
||||||
.eq(AfterSale::getId, afterSale.getId())
|
.eq(AfterSale::getId, afterSale.getId())
|
||||||
.set(AfterSale::getRefundTime, new Date()));
|
.set(AfterSale::getRefundTime, new Date()));
|
||||||
|
this.updateReturnGoodsNumber(afterSale);
|
||||||
|
|
||||||
//记录退款流水
|
//记录退款流水
|
||||||
storeFlowService.refundOrder(afterSale);
|
storeFlowService.refundOrder(afterSale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能描述: 修改子订单中已售后退款商品数量
|
||||||
|
* @Author ftyy
|
||||||
|
* @Description //TODO
|
||||||
|
* @Date 17:33 2021/11/18
|
||||||
|
* @Param [afterSale]
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
private void updateReturnGoodsNumber(AfterSale afterSale){
|
||||||
|
//根据商品id及订单sn获取子订单
|
||||||
|
OrderItem orderItem = orderItemService.getOne(new LambdaQueryWrapper<OrderItem>()
|
||||||
|
.eq(OrderItem::getOrderSn, afterSale.getOrderSn())
|
||||||
|
.eq(OrderItem::getGoodsId, afterSale.getGoodsId()));
|
||||||
|
//修改子订单订单中的退货数量
|
||||||
|
orderItemService.update(new LambdaUpdateWrapper<OrderItem>()
|
||||||
|
.eq(OrderItem::getOrderSn,afterSale.getOrderSn())
|
||||||
|
.eq(OrderItem::getGoodsId,afterSale.getGoodsId())
|
||||||
|
.set(OrderItem::getReturnGoodsNumber,(afterSale.getNum()+orderItem.getReturnGoodsNumber())));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单取消
|
* 订单取消
|
||||||
*
|
*
|
||||||
|
@ -183,28 +183,9 @@ public class StoreDetail extends BaseIdEntity {
|
|||||||
|
|
||||||
public StoreDetail(Store store, AdminStoreApplyDTO adminStoreApplyDTO) {
|
public StoreDetail(Store store, AdminStoreApplyDTO adminStoreApplyDTO) {
|
||||||
this.storeId = store.getId();
|
this.storeId = store.getId();
|
||||||
//过滤字段值
|
|
||||||
isNotNull(adminStoreApplyDTO);
|
|
||||||
//设置店铺公司信息、设置店铺银行信息、设置店铺其他信息
|
//设置店铺公司信息、设置店铺银行信息、设置店铺其他信息
|
||||||
BeanUtil.copyProperties(adminStoreApplyDTO, this);
|
BeanUtil.copyProperties(adminStoreApplyDTO, this);
|
||||||
this.settlementDay = DateUtil.date();
|
this.settlementDay = DateUtil.date();
|
||||||
this.stockWarning = 10;
|
this.stockWarning = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void isNotNull(AdminStoreApplyDTO adminStoreApplyDTO){
|
|
||||||
if("null".equals(adminStoreApplyDTO.getSalesConsigneeName())){
|
|
||||||
adminStoreApplyDTO.setSalesConsigneeName("");
|
|
||||||
}
|
|
||||||
if("null".equals(adminStoreApplyDTO.getSalesConsigneeMobile())){
|
|
||||||
adminStoreApplyDTO.setSalesConsigneeMobile("");
|
|
||||||
}
|
|
||||||
if("null".equals(adminStoreApplyDTO.getSalesConsigneeDetail())){
|
|
||||||
adminStoreApplyDTO.setSalesConsigneeDetail("");
|
|
||||||
}
|
|
||||||
if("null".equals(adminStoreApplyDTO.getDdCode())){
|
|
||||||
adminStoreApplyDTO.setDdCode("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -75,8 +75,7 @@ public class StoreDetailServiceImpl extends ServiceImpl<StoreDetailMapper, Store
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StoreDetailVO getStoreDetailVO(String storeId) {
|
public StoreDetailVO getStoreDetailVO(String storeId) {
|
||||||
StoreDetailVO storeDetail = this.baseMapper.getStoreDetail(storeId);
|
return this.baseMapper.getStoreDetail(storeId);
|
||||||
return storeDetail;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -115,6 +115,7 @@ public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> implements
|
|||||||
if (Boolean.TRUE.equals(member.getHaveStore())) {
|
if (Boolean.TRUE.equals(member.getHaveStore())) {
|
||||||
throw new ServiceException(ResultCode.STORE_APPLY_DOUBLE_ERROR);
|
throw new ServiceException(ResultCode.STORE_APPLY_DOUBLE_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
//添加店铺
|
//添加店铺
|
||||||
Store store = new Store(member, adminStoreApplyDTO);
|
Store store = new Store(member, adminStoreApplyDTO);
|
||||||
this.save(store);
|
this.save(store);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user