Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
commit
d9859647b4
|
|
@ -0,0 +1,39 @@
|
|||
package cn.ysk.cashier.controller;
|
||||
|
||||
import cn.ysk.cashier.dto.freedine.UpdateFreeDineConfigDTO;
|
||||
import cn.ysk.cashier.mybatis.entity.TbFreeDineConfig;
|
||||
import cn.ysk.cashier.service.app.TbFreeDineService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 霸王餐相关接口
|
||||
* @author SongZhang
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/freeDine")
|
||||
@AllArgsConstructor
|
||||
public class TbFreeDineController {
|
||||
private final TbFreeDineService freeDineService;
|
||||
|
||||
/**
|
||||
* 获取当前店铺霸王餐配置信息列表
|
||||
* @param shopId 店铺id
|
||||
* @return 霸王餐配置信息 (不存在会新建)
|
||||
*/
|
||||
@GetMapping
|
||||
public ResponseEntity<TbFreeDineConfig> getConfig(@RequestParam Integer shopId) {
|
||||
return ResponseEntity.ok(freeDineService.getConfig(shopId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改霸王餐配置信息
|
||||
* @param updateFreeDineConfigDTO 修改信息
|
||||
* @return 霸王餐配置信息
|
||||
*/
|
||||
@PutMapping
|
||||
public ResponseEntity<TbFreeDineConfig> updateConfig(@RequestBody UpdateFreeDineConfigDTO updateFreeDineConfigDTO) {
|
||||
return ResponseEntity.ok(freeDineService.updateConfig(updateFreeDineConfigDTO));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package cn.ysk.cashier.dto.freedine;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class UpdateFreeDineConfigDTO {
|
||||
@NotNull
|
||||
private Integer shopId;
|
||||
@NotNull
|
||||
private Integer id;
|
||||
private Boolean enable;
|
||||
@Min(1)
|
||||
private Integer rechargeTimes;
|
||||
@Min(value = 0)
|
||||
private BigDecimal rechargeThreshold;
|
||||
private Boolean withCoupon;
|
||||
private Boolean withPoints;
|
||||
private String rechargeDesc;
|
||||
private List<String> useTypeList;
|
||||
|
||||
}
|
||||
|
|
@ -173,7 +173,7 @@ public class TbOrderInfoDto implements Serializable {
|
|||
private Integer seatCount;
|
||||
private BigDecimal seatAmount;
|
||||
private String useType;
|
||||
private TbCashierCart seatInfo;
|
||||
private Object seatInfo;
|
||||
private String refundRemark;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
package cn.ysk.cashier.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum OrderStatusEnums {
|
||||
REFUNDING("refunding"),
|
||||
REFUND("refund"),
|
||||
CLOSED("closed");
|
||||
private final String value;
|
||||
|
||||
OrderStatusEnums(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
package cn.ysk.cashier.mybatis.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class TbFreeDineConfig {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id", nullable = false)
|
||||
private Integer id;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "enable", nullable = false)
|
||||
private Boolean enable = false;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "recharge_times", nullable = false)
|
||||
private Integer rechargeTimes;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "recharge_threshold", nullable = false, precision = 10, scale = 2)
|
||||
private BigDecimal rechargeThreshold;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "with_coupon", nullable = false)
|
||||
private Boolean withCoupon = false;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "with_points", nullable = false)
|
||||
private Boolean withPoints = false;
|
||||
|
||||
@Size(max = 500)
|
||||
@Column(name = "recharge_desc", length = 500)
|
||||
private String rechargeDesc;
|
||||
|
||||
@Size(max = 255)
|
||||
@Column(name = "use_type")
|
||||
private String useType;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "shop_id", nullable = false)
|
||||
private Integer shopId;
|
||||
|
||||
@Column(name = "create_time")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
@Column(name = "update_time")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date updateTime;
|
||||
|
||||
@Size(max = 255)
|
||||
@Column(name = "child_shop_id_list")
|
||||
private String childShopIdList;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<String> useTypeList;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbFreeDineConfig;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【tb_free_dine_config(霸王餐配置信息表)】的数据库操作Mapper
|
||||
* @createDate 2024-10-22 14:49:18
|
||||
* @Entity cn.ysk.cashier.mybatis.entity.TbFreeDineConfig
|
||||
*/
|
||||
public interface TbFreeDineConfigMapper extends BaseMapper<TbFreeDineConfig> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -37,6 +37,6 @@ public interface TbOrderInfoMapper extends BaseMapper<TbOrderInfo> {
|
|||
|
||||
@Update("update tb_order_info set settlement_amount=settlement_amount-#{priceAmount}, pack_fee=pack_fee-#{packAmount}," +
|
||||
"order_amount=order_amount-#{priceAmount}, amount=amount-#{priceAmount}" +
|
||||
" where id=#{orderId} and origin_amount-#{priceAmount} >= 0 and order_amount > 0")
|
||||
" where id=#{orderId} and origin_amount-#{priceAmount} >= 0 and order_amount-#{priceAmount} >= 0")
|
||||
int updateOrderAmount(Integer orderId, BigDecimal priceAmount, BigDecimal packAmount);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import cn.ysk.cashier.dto.shoptable.ReturnOrderDTO;
|
||||
import cn.ysk.cashier.enums.OrderStatusEnums;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (TbShopPermission)表服务接口
|
||||
*
|
||||
|
|
@ -11,5 +15,14 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
*/
|
||||
public interface MpOrderDetailService extends IService<TbOrderDetail> {
|
||||
|
||||
/**
|
||||
* 根据orderId和id修改detail状态
|
||||
* @param oldOrderStatusEnums 原始订单状态
|
||||
* @param orderStatusEnums 状态
|
||||
* @param orderId 订单id
|
||||
* @param orderDetails detailIds
|
||||
* @return 影响数量
|
||||
*/
|
||||
boolean updateStatusByOrderIdAndIds(OrderStatusEnums oldOrderStatusEnums, OrderStatusEnums orderStatusEnums, Integer orderId, List<Integer> orderDetails);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import cn.ysk.cashier.enums.OrderStatusEnums;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (TbShopPermission)表服务接口
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-09-14 17:08:48
|
||||
*/
|
||||
public interface MpOrderInfoService extends IService<TbOrderInfo> {
|
||||
|
||||
/**
|
||||
* 根据原始订单查询退款订单
|
||||
* @param orderId 原始订单id
|
||||
* @return 对应的退款订单
|
||||
*/
|
||||
TbOrderInfo selectReturnOrderByOrderId(Integer orderId);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbFreeDineConfig;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【tb_free_dine_config(霸王餐配置信息表)】的数据库操作Service
|
||||
* @createDate 2024-10-22 14:49:18
|
||||
*/
|
||||
public interface TbFreeDineConfigService extends IService<TbFreeDineConfig> {
|
||||
|
||||
/**
|
||||
* 根据店铺id获取霸王餐配置
|
||||
* @param shopId 店铺id
|
||||
* @return 霸王餐配置
|
||||
*/
|
||||
TbFreeDineConfig getByShopId(Integer shopId);
|
||||
|
||||
/**
|
||||
* 通过shopId和id获取配置
|
||||
* @param id 主键
|
||||
* @param shopId 店铺
|
||||
* @return 信息
|
||||
*/
|
||||
TbFreeDineConfig getByIdAndShopId(Integer id, Integer shopId);
|
||||
}
|
||||
|
|
@ -1,11 +1,16 @@
|
|||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import cn.ysk.cashier.dto.shoptable.ReturnOrderDTO;
|
||||
import cn.ysk.cashier.enums.OrderStatusEnums;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbOrderDetailMapper;
|
||||
import cn.ysk.cashier.mybatis.service.MpOrderDetailService;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (TbShopPermission)表服务实现类
|
||||
*
|
||||
|
|
@ -14,6 +19,16 @@ import org.springframework.stereotype.Service;
|
|||
*/
|
||||
@Service
|
||||
public class MpOrderDetailServiceImpl extends ServiceImpl<TbOrderDetailMapper, TbOrderDetail> implements MpOrderDetailService {
|
||||
|
||||
@Override
|
||||
public boolean updateStatusByOrderIdAndIds(OrderStatusEnums oldOrderStatusEnums, OrderStatusEnums orderStatusEnums, Integer orderId, List<Integer> orderDetails) {
|
||||
LambdaUpdateWrapper<TbOrderDetail> wrapper = new LambdaUpdateWrapper<TbOrderDetail>()
|
||||
.eq(TbOrderDetail::getOrderId, orderId)
|
||||
.in(TbOrderDetail::getId, orderDetails)
|
||||
.set(TbOrderDetail::getStatus, orderStatusEnums.getValue());
|
||||
if (oldOrderStatusEnums != null) {
|
||||
wrapper.eq(TbOrderDetail::getStatus, oldOrderStatusEnums.getValue());
|
||||
}
|
||||
return update(wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import cn.ysk.cashier.mybatis.mapper.TbCashierCartMapper;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbOrderInfoMapper;
|
||||
import cn.ysk.cashier.mybatis.service.MpCashierCartService;
|
||||
import cn.ysk.cashier.mybatis.service.MpOrderInfoService;
|
||||
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* (TbShopPermission)表服务实现类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-09-14 17:08:49
|
||||
*/
|
||||
@Service
|
||||
public class MpOrderInfoServiceImpl extends ServiceImpl<TbOrderInfoMapper, TbOrderInfo> implements MpOrderInfoService {
|
||||
@Override
|
||||
public TbOrderInfo selectReturnOrderByOrderId(Integer orderId) {
|
||||
return getOne(new LambdaQueryWrapper<TbOrderInfo>()
|
||||
.eq(TbOrderInfo::getSource, orderId)
|
||||
.eq(TbOrderInfo::getOrderType, "return"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbFreeDineConfig;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import cn.ysk.cashier.mybatis.service.TbFreeDineConfigService;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbFreeDineConfigMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【tb_free_dine_config(霸王餐配置信息表)】的数据库操作Service实现
|
||||
* @createDate 2024-10-22 14:49:18
|
||||
*/
|
||||
@Service
|
||||
public class TbFreeDineConfigServiceImpl extends ServiceImpl<TbFreeDineConfigMapper, TbFreeDineConfig>
|
||||
implements TbFreeDineConfigService{
|
||||
@Override
|
||||
public TbFreeDineConfig getByShopId(Integer shopId) {
|
||||
return getOne(new LambdaQueryWrapper<TbFreeDineConfig>()
|
||||
.eq(TbFreeDineConfig::getShopId, shopId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TbFreeDineConfig getByIdAndShopId(Integer id, Integer shopId) {
|
||||
return getOne(new LambdaQueryWrapper<TbFreeDineConfig>()
|
||||
.eq(TbFreeDineConfig::getId, id)
|
||||
.eq(TbFreeDineConfig::getShopId, shopId));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package cn.ysk.cashier.service.app;
|
||||
|
||||
import cn.ysk.cashier.dto.freedine.UpdateFreeDineConfigDTO;
|
||||
import cn.ysk.cashier.mybatis.entity.TbFreeDineConfig;
|
||||
|
||||
public interface TbFreeDineService {
|
||||
TbFreeDineConfig getConfig(Integer shopId);
|
||||
|
||||
TbFreeDineConfig updateConfig(UpdateFreeDineConfigDTO updateFreeDineConfigDTO);
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
package cn.ysk.cashier.service.impl.app;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.ysk.cashier.dto.freedine.UpdateFreeDineConfigDTO;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mybatis.entity.TbFreeDineConfig;
|
||||
import cn.ysk.cashier.mybatis.service.TbFreeDineConfigService;
|
||||
import cn.ysk.cashier.service.app.TbFreeDineService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class TbFreeDineServiceImpl implements TbFreeDineService {
|
||||
private final TbFreeDineConfigService freeDineConfigService;
|
||||
|
||||
@Override
|
||||
public TbFreeDineConfig getConfig(Integer shopId) {
|
||||
TbFreeDineConfig freeDineConfig = freeDineConfigService.getByShopId(shopId);
|
||||
if (freeDineConfig == null) {
|
||||
freeDineConfig = new TbFreeDineConfig();
|
||||
freeDineConfig.setShopId(shopId);
|
||||
freeDineConfig.setCreateTime(DateUtil.date());
|
||||
freeDineConfigService.save(freeDineConfig);
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(freeDineConfig.getUseType())) {
|
||||
freeDineConfig.setUseTypeList(JSONObject.parseArray(freeDineConfig.getUseType()).toJavaList(String.class ));
|
||||
}
|
||||
return freeDineConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TbFreeDineConfig updateConfig(UpdateFreeDineConfigDTO updateFreeDineConfigDTO) {
|
||||
TbFreeDineConfig config = freeDineConfigService.getByIdAndShopId(updateFreeDineConfigDTO.getId(), updateFreeDineConfigDTO.getShopId());
|
||||
if (config == null) {
|
||||
throw new BadRequestException("霸王餐信息未配置");
|
||||
}
|
||||
BeanUtil.copyProperties(updateFreeDineConfigDTO, config);
|
||||
config.setUpdateTime(DateUtil.date());
|
||||
if (updateFreeDineConfigDTO.getUseTypeList() != null) {
|
||||
config.setUseType(JSONObject.toJSONString(updateFreeDineConfigDTO.getUseTypeList()));
|
||||
}
|
||||
freeDineConfigService.updateById(config);
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
|
@ -307,7 +307,13 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||
.eq(TbCashierCart::getProductId, TableConstant.CART_SEAT_ID)
|
||||
.orderByDesc(TbCashierCart::getId));
|
||||
TbCashierCart cashierCart = tbCashierCarts.isEmpty() ? null : tbCashierCarts.get(0);
|
||||
dto.setSeatInfo(cashierCart);
|
||||
Map<String, Object> map = BeanUtil.beanToMap(cashierCart, false, false);
|
||||
if (cashierCart != null) {
|
||||
map.put("cartId", cashierCart.getId());
|
||||
TbOrderDetail orderDetail = details.stream().filter(item -> item.getCartId().equals(cashierCart.getId())).findFirst().orElse(null);
|
||||
map.put("id", orderDetail != null ? orderDetail.getId() : null);
|
||||
}
|
||||
dto.setSeatInfo(map);
|
||||
Map<String, Object> data = BeanUtil.beanToMap(tbOrderInfo, false, false);
|
||||
data.putAll(BeanUtil.beanToMap(dto, false, false));
|
||||
data.put("refundAmount", tbOrderInfo.getRefundAmount());
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import cn.ysk.cashier.mapper.shop.TbShopTableMapper;
|
|||
import cn.ysk.cashier.mybatis.mapper.*;
|
||||
import cn.ysk.cashier.mybatis.service.MpCashierCartService;
|
||||
import cn.ysk.cashier.mybatis.service.MpOrderDetailService;
|
||||
import cn.ysk.cashier.mybatis.service.MpOrderInfoService;
|
||||
import cn.ysk.cashier.mybatis.service.MpShopTableService;
|
||||
import cn.ysk.cashier.pojo.TbShopPayType;
|
||||
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||
|
|
@ -89,7 +90,6 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
private final TbProducSkutMapper producSkutMapper;
|
||||
private final RabbitTemplate rabbitTemplate;
|
||||
private final TbShopInfoRepository shopInfoRepository;
|
||||
private final TbShopOpenIdMapper shopOpenIdMapper;
|
||||
private final WxMsgUtils wxMsgUtils;
|
||||
private final TbShopPayTypeRepository payTypeRepository;
|
||||
private final MpShopTableMapper mpShopTableMapper;
|
||||
|
|
@ -97,8 +97,6 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
private final MpShopTableService mpShopTableService;
|
||||
private final MpShopUnitMapper mpShopUnitMapper;
|
||||
private final MpProductStockDetailMapper mpProductStockDetailMapper;
|
||||
@Value("${thirdPay.payType}")
|
||||
private String thirdPayType;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -117,6 +115,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
private final MpMerchantThirdApplyMapper mpMerchantThirdApplyMapper;
|
||||
private final PayService payService;
|
||||
private final TbOrderInfoService orderInfoService;
|
||||
private final MpOrderInfoService mpOrderInfoService;
|
||||
|
||||
private TbOrderInfo getCurrentOrder(ShopEatTypeInfoDTO eatTypeInfoDTO) {
|
||||
// 获取当前台桌最新订单,先付款模式不获取
|
||||
|
|
@ -382,7 +381,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
}
|
||||
|
||||
if (updateCartDTO.getIsGift() != null ) {
|
||||
tbCashierCart.setTotalAmount(updateCartDTO.getIsGift() ? BigDecimal.ZERO : tbCashierCart.getTotalAmount());
|
||||
tbCashierCart.setTotalAmount(updateCartDTO.getIsGift() ? tbCashierCart.getPackFee() : tbCashierCart.getTotalAmount());
|
||||
tbCashierCart.setIsGift(updateCartDTO.getIsGift() ? "true" : "false");
|
||||
}
|
||||
|
||||
|
|
@ -667,7 +666,8 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
returnCart.setNumber(removeCartDTO.getNum());
|
||||
returnCart.setId(null);
|
||||
returnCart.setTotalNumber(removeCartDTO.getNum());
|
||||
returnCart.setTotalAmount(returnCart.getSalePrice().multiply(BigDecimal.valueOf(returnCart.getNumber())));
|
||||
BigDecimal returnCartAmount = returnCart.getSalePrice().multiply(BigDecimal.valueOf(returnCart.getNumber()));
|
||||
returnCart.setTotalAmount(returnCartAmount);
|
||||
returnCart.setStatus("return");
|
||||
cashierCartMapper.insert(returnCart);
|
||||
|
||||
|
|
@ -691,7 +691,9 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
|
||||
if (cashierCart.getOrderId() != null) {
|
||||
// 减少订单金额
|
||||
orderInfoMapper.updateOrderAmount(cashierCart.getOrderId(), orderDetail.getPriceAmount(), orderDetail.getPackAmount());
|
||||
orderInfoMapper.updateOrderAmount(cashierCart.getOrderId(), orderDetail.getPriceAmount().divide(BigDecimal.valueOf(orderDetail.getNum()), RoundingMode.HALF_UP)
|
||||
.multiply(BigDecimal.valueOf(removeCartDTO.getNum())), orderDetail.getPackAmount().divide(BigDecimal.valueOf(orderDetail.getNum()), RoundingMode.HALF_UP)
|
||||
.multiply(BigDecimal.valueOf(removeCartDTO.getNum())));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1996,18 +1998,36 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
.eq(TbOrderDetail::getStatus, "closed")
|
||||
.eq(TbOrderDetail::getOrderId, returnOrderDTO.getOrderId())
|
||||
.in(TbOrderDetail::getId, detailIds));
|
||||
if (detailIds.size() != returnOrderDTO.getOrderDetails().size()) {
|
||||
if (detailList.size() != returnOrderDTO.getOrderDetails().size()) {
|
||||
throw new BadRequestException("订单明细数量不一致");
|
||||
}
|
||||
|
||||
BigDecimal returnAmount = BigDecimal.ZERO;
|
||||
BigDecimal packAMount = BigDecimal.ZERO;
|
||||
BigDecimal saleAmount = BigDecimal.ZERO;
|
||||
|
||||
List<TbOrderDetail> returnDetail = new ArrayList<>();
|
||||
|
||||
ArrayList<TbOrderDetail> remainOrderDetailList = new ArrayList<>();
|
||||
for (TbOrderDetail orderDetail : detailList) {
|
||||
Integer returnNum = returnNumMap.get(orderDetail.getId().toString());
|
||||
int remainNum = orderDetail.getNum() - returnNum;
|
||||
if (remainNum < 0) {
|
||||
throw new BadRequestException("{}最多可退数量为: {}", orderDetail.getProductName(), orderDetail.getNum());
|
||||
}
|
||||
|
||||
// 将未退款的剩余订单详情重新生成记录
|
||||
BigDecimal packFee = orderDetail.getPackAmount().divide(BigDecimal.valueOf(orderDetail.getNum()), RoundingMode.HALF_UP);
|
||||
if (remainNum > 0) {
|
||||
// 单个打包费
|
||||
BigDecimal remainPackFee = packFee.multiply(BigDecimal.valueOf(remainNum));
|
||||
TbOrderDetail remainOrderDetail = BeanUtil.copyProperties(orderDetail, TbOrderDetail.class);
|
||||
remainOrderDetail.setNum(remainNum);
|
||||
remainOrderDetail.setPriceAmount(BigDecimal.valueOf(remainNum).multiply(orderDetail.getPrice())
|
||||
.add(remainPackFee));
|
||||
remainOrderDetail.setPackAmount(remainPackFee);
|
||||
remainOrderDetail.setReturnNum("0");
|
||||
remainOrderDetail.setId(null);
|
||||
remainOrderDetailList.add(remainOrderDetail);
|
||||
}
|
||||
|
||||
returnAmount = returnAmount.add(orderDetail.getPriceAmount()
|
||||
.divide(new BigDecimal(orderDetail.getNum()), 2, RoundingMode.DOWN)
|
||||
.multiply(BigDecimal.valueOf(returnNum)));
|
||||
|
|
@ -2016,12 +2036,24 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
.divide(new BigDecimal(orderDetail.getNum()), 2, RoundingMode.DOWN)
|
||||
.multiply(BigDecimal.valueOf(returnNum)));
|
||||
|
||||
BigDecimal returnPackFee = packFee.multiply(BigDecimal.valueOf(returnNum));
|
||||
orderDetail.setNum(returnNum);
|
||||
orderDetail.setPriceAmount(BigDecimal.valueOf(returnNum).multiply(orderDetail.getPrice())
|
||||
.add(returnPackFee));
|
||||
orderDetail.setPackAmount(returnPackFee);
|
||||
orderDetail.setRefundNumber(returnNum);
|
||||
orderDetail.setStatus("refunding");
|
||||
}
|
||||
|
||||
// 保存剩余未退款的订单详情
|
||||
if (!remainOrderDetailList.isEmpty()) {
|
||||
mpOrderDetailService.saveBatch(remainOrderDetailList);
|
||||
}
|
||||
|
||||
TbOrderInfo returnOrder = mpOrderInfoService.selectReturnOrderByOrderId(returnOrderDTO.getOrderId());
|
||||
if (returnOrder == null) {
|
||||
String orderNo = generateOrderNumber(isOnline ? "OLRO" : "RO");
|
||||
TbOrderInfo returnOrder = BeanUtil.copyProperties(oldOrderInfo, TbOrderInfo.class);
|
||||
returnOrder = BeanUtil.copyProperties(oldOrderInfo, TbOrderInfo.class);
|
||||
returnOrder.setId(null);
|
||||
returnOrder.setOrderNo(orderNo);
|
||||
returnOrder.setRefundAmount(returnAmount);
|
||||
|
|
@ -2034,9 +2066,16 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
returnOrder.setSource(oldOrderInfo.getId());
|
||||
returnOrder.setRefundRemark(returnOrderDTO.getNote());
|
||||
orderInfoMapper.insert(returnOrder);
|
||||
}else {
|
||||
returnOrder.setUpdatedAt(DateUtil.current());
|
||||
returnOrder.setRefundRemark(returnOrderDTO.getNote());
|
||||
returnOrder.setRefundAmount(returnOrder.getRefundAmount().add(returnAmount));
|
||||
orderInfoMapper.updateById(returnOrder);
|
||||
}
|
||||
|
||||
|
||||
updateStockAndRecord(detailList);
|
||||
|
||||
mpOrderDetailService.updateBatchById(detailList);
|
||||
return returnOrder;
|
||||
}
|
||||
|
||||
|
|
@ -2081,9 +2120,11 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
public Object returnOrder(ReturnOrderDTO returnOrderDTO) {
|
||||
TbOrderInfo orderInfo = orderInfoMapper.selectOne(new LambdaQueryWrapper<TbOrderInfo>()
|
||||
.eq(TbOrderInfo::getId, returnOrderDTO.getOrderId())
|
||||
.eq(TbOrderInfo::getStatus, "closed"));
|
||||
.in(TbOrderInfo::getStatus, OrderStatusEnums.REFUND.getValue(), OrderStatusEnums.CLOSED.getValue())
|
||||
// .eq(TbOrderInfo::getStatus, "closed")
|
||||
);
|
||||
if (orderInfo == null) {
|
||||
throw new BadRequestException("订单非完单状态");
|
||||
throw new BadRequestException("订单不处于可退款状态");
|
||||
}
|
||||
|
||||
TbShopInfo shopInfo = mpShopInfoMapper.selectById(orderInfo.getShopId());
|
||||
|
|
@ -2109,8 +2150,12 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
} else if ("deposit".equals(payType)) {
|
||||
orderInfoService.depositReturn(Integer.valueOf(orderInfo.getUserId()), Integer.valueOf(orderInfo.getShopId()), returnOrderInfo.getRefundAmount());
|
||||
orderInfo.setStatus("refund");
|
||||
mpOrderDetailService.updateStatusByOrderIdAndIds(OrderStatusEnums.REFUNDING, OrderStatusEnums.REFUND,
|
||||
returnOrderDTO.getOrderId(), returnOrderDTO.getOrderDetails().stream().map(ReturnOrderDTO.OrderDetail::getId).collect(Collectors.toList()));
|
||||
} else if ("cash".equals(payType)) {
|
||||
orderInfo.setStatus("refund");
|
||||
mpOrderDetailService.updateStatusByOrderIdAndIds(OrderStatusEnums.REFUNDING, OrderStatusEnums.REFUND,
|
||||
returnOrderDTO.getOrderId(), returnOrderDTO.getOrderDetails().stream().map(ReturnOrderDTO.OrderDetail::getId).collect(Collectors.toList()));
|
||||
}
|
||||
orderInfoMapper.updateById(orderInfo);
|
||||
// 打印退款小票
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.ysk.cashier.mybatis.mapper.TbFreeDineConfigMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="cn.ysk.cashier.mybatis.entity.TbFreeDineConfig">
|
||||
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="enable" column="enable" jdbcType="TINYINT"/>
|
||||
<result property="recharge_times" column="recharge_times" jdbcType="INTEGER"/>
|
||||
<result property="recharge_threshold" column="recharge_threshold" jdbcType="DECIMAL"/>
|
||||
<result property="with_coupon" column="with_coupon" jdbcType="TINYINT"/>
|
||||
<result property="with_points" column="with_points" jdbcType="TINYINT"/>
|
||||
<result property="recharge_desc" column="recharge_desc" jdbcType="VARCHAR"/>
|
||||
<result property="use_type" column="use_type" jdbcType="VARCHAR"/>
|
||||
<result property="shop_id" column="shop_id" jdbcType="INTEGER"/>
|
||||
<result property="create_time" column="create_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="update_time" column="update_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="child_shop_id_list" column="child_shop_id_list" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,enable,recharge_times,
|
||||
recharge_threshold,with_coupon,with_points,
|
||||
recharge_desc,use_type,shop_id,
|
||||
create_time,update_time,child_shop_id_list
|
||||
</sql>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue