feat: 新增支付积分优惠券支持
This commit is contained in:
parent
8aad5da104
commit
7c572d7384
|
|
@ -57,12 +57,17 @@ public interface TableConstant {
|
||||||
@Getter
|
@Getter
|
||||||
public enum Status {
|
public enum Status {
|
||||||
REFUNDING("refunding"), REFUND("refund"), CLOSED("closed"), CREATE("create"),
|
REFUNDING("refunding"), REFUND("refund"), CLOSED("closed"), CREATE("create"),
|
||||||
UNPAID("unpaid"), PAYING("paying"), RETURN("return");
|
UNPAID("unpaid"), PAYING("paying"), RETURN("return"), FINAL("final");
|
||||||
private final String value;
|
private final String value;
|
||||||
|
|
||||||
Status(String value) {
|
Status(String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean equalsVals(String value) {
|
||||||
|
return this.value.equals(value);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
|
|
||||||
|
|
@ -90,5 +90,11 @@ public class TbShopCouponController {
|
||||||
tbShopCouponService.deleteReceive(ids);
|
tbShopCouponService.deleteReceive(ids);
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("activateByOrderId")
|
||||||
|
@ApiOperation("根据订单id获取可用优惠券信息")
|
||||||
|
public ResponseEntity<Object> activateByOrderIds(@RequestParam Integer shopId, @RequestParam Integer orderId, @RequestParam(required = false) Integer memberId) {
|
||||||
|
return ResponseEntity.ok(tbShopCouponService.getActivateByOrderIds(shopId, orderId, memberId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -175,8 +175,14 @@ public class TbPlaceController {
|
||||||
JSONObject userInfo = JSON.parseObject(JSON.toJSONString(redisUtils.get("online-token-" + token)));
|
JSONObject userInfo = JSON.parseObject(JSON.toJSONString(redisUtils.get("online-token-" + token)));
|
||||||
String userName = userInfo.getString("userName");
|
String userName = userInfo.getString("userName");
|
||||||
String shopId = userInfo.getString("shopId");
|
String shopId = userInfo.getString("shopId");
|
||||||
TbPlussShopStaff shopStaff = staffRepository.queryByAccount(userName, shopId);
|
TbPlussShopStaff shopStaff;
|
||||||
TbMerchantAccount merchantAccount = tbMerchantAccountMapper.selectOne(Wrappers.<TbMerchantAccount>lambdaQuery().eq(TbMerchantAccount::getAccount, shopStaff.getAccount()));
|
if (userName.contains("@")) {
|
||||||
|
shopStaff = staffRepository.queryMasterAccount(shopId);
|
||||||
|
}else {
|
||||||
|
shopStaff = staffRepository.queryByAccount(userName, shopId);
|
||||||
|
}
|
||||||
|
TbMerchantAccount merchantAccount = tbMerchantAccountMapper.selectOne(Wrappers.<TbMerchantAccount>lambdaQuery()
|
||||||
|
.eq(TbMerchantAccount::getAccount, shopStaff.getAccount()));
|
||||||
Integer accountId = merchantAccount.getId();
|
Integer accountId = merchantAccount.getId();
|
||||||
Integer staffId = shopStaff.getId();
|
Integer staffId = shopStaff.getId();
|
||||||
List<TbToken> onlineUserList = tbTokenRepository.findListByAccountIdAndStaffId(accountId, staffId);
|
List<TbToken> onlineUserList = tbTokenRepository.findListByAccountIdAndStaffId(accountId, staffId);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package cn.ysk.cashier.dto.order;
|
||||||
|
|
||||||
|
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class OrderCartInfoDTO {
|
||||||
|
private BigDecimal totalAmount = BigDecimal.ZERO;
|
||||||
|
private BigDecimal newAddTotalAmount = BigDecimal.ZERO;
|
||||||
|
private List<TbCashierCart> newCashierCarts = new ArrayList<>();
|
||||||
|
private List<TbCashierCart> cashierCarts = new ArrayList<>();
|
||||||
|
private List<Integer> cashierCartIds = new ArrayList<>();
|
||||||
|
private Integer orderId;
|
||||||
|
private TbCashierCart seatCart;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package cn.ysk.cashier.dto.order;
|
||||||
|
|
||||||
|
import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord;
|
||||||
|
import cn.ysk.cashier.pojo.shop.TbShopUser;
|
||||||
|
import cn.ysk.cashier.vo.TbUserCouponVo;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class OrderCouponInfoDTO {
|
||||||
|
private TbShopUser shopUser;
|
||||||
|
private List<TbActivateOutRecord> outRecordList = new ArrayList<>();
|
||||||
|
// 满减优惠券
|
||||||
|
private HashMap<Integer, TbUserCouponVo> fullReductionCouponMap = new HashMap<>();
|
||||||
|
// 商品优惠券
|
||||||
|
private HashMap<Integer, TbUserCouponVo> productCouponMap = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package cn.ysk.cashier.dto.order;
|
||||||
|
|
||||||
|
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class OrderPriceDTO {
|
||||||
|
private BigDecimal originAmount = BigDecimal.ZERO;
|
||||||
|
private BigDecimal totalAmount = BigDecimal.ZERO;
|
||||||
|
private BigDecimal packAmount = BigDecimal.ZERO;
|
||||||
|
private boolean hasNewInfo = false;
|
||||||
|
private List<TbOrderDetail> newOrderDetailList = new ArrayList<>();
|
||||||
|
private List<TbOrderDetail> removeOrderDetailList = new ArrayList<>();
|
||||||
|
private List<Integer> removeOrderDetailIds = new ArrayList<>();
|
||||||
|
private List<TbOrderDetail> orderDetailList = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package cn.ysk.cashier.dto.order;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Min;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UserCouponInfoDTO {
|
||||||
|
private Integer userCouponId;
|
||||||
|
@Min(1)
|
||||||
|
private Integer num;
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
package cn.ysk.cashier.dto.shoptable;
|
package cn.ysk.cashier.dto.shoptable;
|
||||||
|
|
||||||
|
import cn.ysk.cashier.dto.order.UserCouponInfoDTO;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.Min;
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -19,9 +23,11 @@ public class CreateOrderDTO {
|
||||||
private Integer orderId;
|
private Integer orderId;
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private String useType;
|
private String useType;
|
||||||
private String vipUserId;
|
private Integer vipUserId;
|
||||||
// 使用的优惠券
|
// 使用的优惠券
|
||||||
private List<Integer> userCouponIds = new ArrayList<>();
|
@Valid
|
||||||
|
private List<UserCouponInfoDTO> userCouponInfos = new ArrayList<>();
|
||||||
// 使用的积分抵扣数量
|
// 使用的积分抵扣数量
|
||||||
private Integer pointsNum ;
|
private Integer pointsNum;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,15 @@
|
||||||
package cn.ysk.cashier.dto.shoptable;
|
package cn.ysk.cashier.dto.shoptable;
|
||||||
|
|
||||||
|
import cn.ysk.cashier.dto.order.UserCouponInfoDTO;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.Max;
|
import javax.validation.constraints.Max;
|
||||||
import javax.validation.constraints.Min;
|
import javax.validation.constraints.Min;
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class PayDTO {
|
public class PayDTO {
|
||||||
|
|
@ -20,6 +24,11 @@ public class PayDTO {
|
||||||
private Double discount;
|
private Double discount;
|
||||||
private Integer vipUserId;
|
private Integer vipUserId;
|
||||||
private String code;
|
private String code;
|
||||||
|
|
||||||
private String token;
|
private String token;
|
||||||
|
// 使用的优惠券
|
||||||
|
@Valid
|
||||||
|
private List<UserCouponInfoDTO> userCouponInfos = new ArrayList<>();
|
||||||
|
// 使用的积分抵扣数量
|
||||||
|
private Integer pointsNum;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ public class UpdateVipDTO {
|
||||||
private String tableId;
|
private String tableId;
|
||||||
@NotNull
|
@NotNull
|
||||||
private String masterId;
|
private String masterId;
|
||||||
|
private Integer orderId;
|
||||||
private Integer vipUserId;
|
private Integer vipUserId;
|
||||||
@NotNull
|
@NotNull
|
||||||
@Range(min = 0, max = 1)
|
@Range(min = 0, max = 1)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import cn.ysk.cashier.mybatis.entity.TbActivateInRecord;
|
import cn.ysk.cashier.mybatis.entity.TbActivateInRecord;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
import org.apache.ibatis.annotations.Update;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -17,7 +18,9 @@ import java.util.List;
|
||||||
public interface TbActivateInRecordMapper extends BaseMapper<TbActivateInRecord> {
|
public interface TbActivateInRecordMapper extends BaseMapper<TbActivateInRecord> {
|
||||||
|
|
||||||
@Select("SELECT" +
|
@Select("SELECT" +
|
||||||
" inRecord.coupon_id as id," +
|
" inRecord.id as id," +
|
||||||
|
" inRecord.full_amount as fullAmount," +
|
||||||
|
" inRecord.discount_amount as discountAmount," +
|
||||||
" inRecord.coupon_id as couponId," +
|
" inRecord.coupon_id as couponId," +
|
||||||
" pro.id as proId," +
|
" pro.id as proId," +
|
||||||
" CASE" +
|
" CASE" +
|
||||||
|
|
@ -34,14 +37,19 @@ public interface TbActivateInRecordMapper extends BaseMapper<TbActivateInRecord>
|
||||||
" inRecord.vip_user_id = #{vipUserId}" +
|
" inRecord.vip_user_id = #{vipUserId}" +
|
||||||
" and inRecord.shop_id = #{shopId}" +
|
" and inRecord.shop_id = #{shopId}" +
|
||||||
" and inRecord.over_num != 0" +
|
" and inRecord.over_num != 0" +
|
||||||
" and inRecord.use_start_time < now()" +
|
" and inRecord.use_start_time < now()" +
|
||||||
" and inRecord.use_end_time > now()" +
|
" and inRecord.use_end_time > now()" +
|
||||||
" order by inRecord.use_end_time asc")
|
" order by inRecord.use_end_time asc")
|
||||||
List<TbUserCouponVo> queryByVipIdAndShopId(@Param("vipUserId") Integer vipUserId, @Param("shopId") Integer shopId);
|
List<TbUserCouponVo> queryByVipIdAndShopId(@Param("vipUserId") Integer vipUserId, @Param("shopId") Integer shopId);
|
||||||
|
|
||||||
@Select("update tb_activate_in_record" +
|
@Update("update tb_activate_in_record" +
|
||||||
" set over_num = #{overNum}" +
|
" set over_num = #{overNum}" +
|
||||||
" where id = #{id}")
|
" where id = #{id}")
|
||||||
int updateOverNum(@Param("id") Integer id, @Param("overNum") Integer overNum);
|
int updateOverNum(@Param("id") Integer id, @Param("overNum") Integer overNum);
|
||||||
|
|
||||||
|
@Update("update tb_activate_in_record" +
|
||||||
|
" set over_num = over_num-#{overNum}" +
|
||||||
|
" where id = #{id} and over_num-#{overNum} >= 0")
|
||||||
|
int decrOverNum(@Param("id") Integer id, @Param("overNum") Integer decrOverNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord;
|
import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
import org.apache.ibatis.annotations.Update;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 活动赠送商品使用记录表(TbActivateOutRecord)表数据库访问层
|
* 活动赠送商品使用记录表(TbActivateOutRecord)表数据库访问层
|
||||||
|
|
@ -13,7 +14,7 @@ import org.apache.ibatis.annotations.Select;
|
||||||
*/
|
*/
|
||||||
public interface TbActivateOutRecordMapper extends BaseMapper<TbActivateOutRecord> {
|
public interface TbActivateOutRecordMapper extends BaseMapper<TbActivateOutRecord> {
|
||||||
|
|
||||||
@Select("update tb_activate_out_record" +
|
@Update("update tb_activate_out_record" +
|
||||||
" set ref_num = ref_num + #{refNum}" +
|
" set ref_num = ref_num + #{refNum}" +
|
||||||
" where id = #{id}")
|
" where id = #{id}")
|
||||||
int updateRefNum(@Param("id") Integer id, @Param("refNum") Integer refNum);
|
int updateRefNum(@Param("id") Integer id, @Param("refNum") Integer refNum);
|
||||||
|
|
|
||||||
|
|
@ -64,5 +64,11 @@ public interface MpCashierCartService extends IService<TbCashierCart> {
|
||||||
*/
|
*/
|
||||||
List<TbCashierCart> selectByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId);
|
List<TbCashierCart> selectByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据订单id和状态获取购物车数据
|
||||||
|
* @param orderId 订单id
|
||||||
|
* @param status 状态 可为空
|
||||||
|
*/
|
||||||
|
List<TbCashierCart> selectByOrderIdAndState(Integer orderId, TableConstant.OrderInfo.Status status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package cn.ysk.cashier.mybatis.service;
|
package cn.ysk.cashier.mybatis.service;
|
||||||
|
|
||||||
|
import cn.ysk.cashier.cons.TableConstant;
|
||||||
import cn.ysk.cashier.dto.shoptable.ReturnOrderDTO;
|
import cn.ysk.cashier.dto.shoptable.ReturnOrderDTO;
|
||||||
import cn.ysk.cashier.enums.OrderStatusEnums;
|
import cn.ysk.cashier.enums.OrderStatusEnums;
|
||||||
import cn.ysk.cashier.pojo.order.TbFullOrderDetail;
|
import cn.ysk.cashier.pojo.order.TbFullOrderDetail;
|
||||||
|
|
@ -42,6 +43,11 @@ public interface MpOrderDetailService extends IService<TbOrderDetail> {
|
||||||
*/
|
*/
|
||||||
List<TbOrderDetail> selectByOrderId(Integer orderId);
|
List<TbOrderDetail> selectByOrderId(Integer orderId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据订单id和状态获取订单详情
|
||||||
|
*/
|
||||||
|
List<TbOrderDetail> selectByOrderIdAndState(Integer orderId, TableConstant.OrderInfo.Status state);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据购物车id和订单id查询订单详情
|
* 根据购物车id和订单id查询订单详情
|
||||||
* @param shopId 店铺id
|
* @param shopId 店铺id
|
||||||
|
|
@ -49,6 +55,6 @@ public interface MpOrderDetailService extends IService<TbOrderDetail> {
|
||||||
* @param orderId 订单id
|
* @param orderId 订单id
|
||||||
* @return 详情信息
|
* @return 详情信息
|
||||||
*/
|
*/
|
||||||
List<TbOrderDetail> selectByCartIdOrOrderId(Integer shopId, ArrayList<Integer> cartIdList, Integer orderId);
|
List<TbOrderDetail> selectByCartIdOrOrderId(Integer shopId, List<Integer> cartIdList, Integer orderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package cn.ysk.cashier.mybatis.service;
|
package cn.ysk.cashier.mybatis.service;
|
||||||
|
|
||||||
|
import cn.ysk.cashier.cons.TableConstant;
|
||||||
import cn.ysk.cashier.enums.OrderStatusEnums;
|
import cn.ysk.cashier.enums.OrderStatusEnums;
|
||||||
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
||||||
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||||
|
|
@ -15,19 +16,29 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface MpOrderInfoService extends IService<TbOrderInfo> {
|
public interface MpOrderInfoService extends IService<TbOrderInfo> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据原始订单查询退款订单
|
* 根据原始订单查询退款订单
|
||||||
* @param orderId 原始订单id
|
*
|
||||||
* @return 对应的退款订单
|
* @param orderId 原始订单id
|
||||||
*/
|
* @return 对应的退款订单
|
||||||
TbOrderInfo selectReturnOrderByOrderId(Integer orderId);
|
*/
|
||||||
|
TbOrderInfo selectReturnOrderByOrderId(Integer orderId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改订单的就餐类型和tableId
|
||||||
|
*
|
||||||
|
* @param orderId 订单id
|
||||||
|
* @param useType 就餐类型
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
boolean updateTableIdAndUseTypeById(Integer orderId, String useType, String tableId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改订单的就餐类型和tableId
|
* 根据状态和id获取订单信息
|
||||||
* @param orderId 订单id
|
* @param orderId 订单id
|
||||||
* @param useType 就餐类型
|
* @param status 状态枚举
|
||||||
* @return 是否成功
|
|
||||||
*/
|
*/
|
||||||
boolean updateTableIdAndUseTypeById(Integer orderId, String useType, String tableId);
|
TbOrderInfo selectOrderByIdAndState(Integer orderId, TableConstant.OrderInfo.Status status);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package cn.ysk.cashier.mybatis.service;
|
||||||
|
|
||||||
|
import cn.ysk.cashier.enums.TableStateEnum;
|
||||||
|
import cn.ysk.cashier.pojo.shop.TbShopTable;
|
||||||
|
import cn.ysk.cashier.pojo.shop.TbShopUser;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
public interface MpShopUserService extends IService<TbShopUser> {
|
||||||
|
/**
|
||||||
|
* 根据店铺id和用户id查询会员信息
|
||||||
|
* @param userId 用户id
|
||||||
|
* @param shopId 店铺id
|
||||||
|
* @return 会员信息
|
||||||
|
*/
|
||||||
|
TbShopUser selectByUserIdAndShopId(Integer userId, Integer shopId);
|
||||||
|
}
|
||||||
|
|
@ -2,18 +2,26 @@ package cn.ysk.cashier.mybatis.service;
|
||||||
|
|
||||||
import cn.ysk.cashier.dto.CouponDto;
|
import cn.ysk.cashier.dto.CouponDto;
|
||||||
import cn.ysk.cashier.dto.QueryReceiveDto;
|
import cn.ysk.cashier.dto.QueryReceiveDto;
|
||||||
|
import cn.ysk.cashier.mybatis.entity.TbActivateInRecord;
|
||||||
import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord;
|
import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord;
|
||||||
import cn.ysk.cashier.mybatis.entity.TbCouponProduct;
|
import cn.ysk.cashier.mybatis.entity.TbCouponProduct;
|
||||||
import cn.ysk.cashier.mybatis.vo.TbShopCouponVo;
|
import cn.ysk.cashier.mybatis.vo.TbShopCouponVo;
|
||||||
|
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||||
|
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
||||||
|
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||||
|
import cn.ysk.cashier.pojo.shop.TbShopUser;
|
||||||
import cn.ysk.cashier.vo.QueryReceiveVo;
|
import cn.ysk.cashier.vo.QueryReceiveVo;
|
||||||
|
import cn.ysk.cashier.vo.TbUserCouponVo;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import cn.ysk.cashier.mybatis.entity.TbShopCoupon;
|
import cn.ysk.cashier.mybatis.entity.TbShopCoupon;
|
||||||
import cn.ysk.cashier.dto.TbShopCouponQueryCriteria;
|
import cn.ysk.cashier.dto.TbShopCouponQueryCriteria;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 优惠券(TbShopCoupon)表服务接口
|
* 优惠券(TbShopCoupon)表服务接口
|
||||||
|
|
@ -30,6 +38,16 @@ public interface TbShopCouponService extends IService<TbShopCoupon> {
|
||||||
|
|
||||||
boolean update(TbShopCouponVo param);
|
boolean update(TbShopCouponVo param);
|
||||||
boolean delete(Integer[] ids);
|
boolean delete(Integer[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据金额获取可用优惠券数据
|
||||||
|
* @param tbShopUser 店铺id
|
||||||
|
* @param orderAmount 用户id
|
||||||
|
* @param productIds 商品id
|
||||||
|
* @return 优惠券信息
|
||||||
|
*/
|
||||||
|
List<TbUserCouponVo> getActivateCoupon(TbShopUser tbShopUser, BigDecimal orderAmount, Integer shopId, Set<String> productIds);
|
||||||
|
|
||||||
boolean deleteReceive(Integer[] ids);
|
boolean deleteReceive(Integer[] ids);
|
||||||
|
|
||||||
ResponseEntity<Object> find(CouponDto param);
|
ResponseEntity<Object> find(CouponDto param);
|
||||||
|
|
@ -39,5 +57,20 @@ public interface TbShopCouponService extends IService<TbShopCoupon> {
|
||||||
boolean refund(List<TbActivateOutRecord> param);
|
boolean refund(List<TbActivateOutRecord> param);
|
||||||
|
|
||||||
List<TbCouponProduct> findActivatePros(Integer couponId);
|
List<TbCouponProduct> findActivatePros(Integer couponId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据优惠券id查询优惠券信息
|
||||||
|
* @param couponIds 优惠券id
|
||||||
|
*/
|
||||||
|
List<TbShopCoupon> selectByIds(List<Integer> couponIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据订单id获取当前用户可用优惠券信息
|
||||||
|
* @param shopId 店铺id
|
||||||
|
* @param orderId 订单id
|
||||||
|
* @param memberId 会员id
|
||||||
|
*/
|
||||||
|
Object getActivateByOrderIds(Integer shopId, Integer orderId, Integer memberId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import cn.ysk.cashier.pojo.shop.TbShopInfo;
|
||||||
import cn.ysk.cashier.pojo.shop.TbShopTable;
|
import cn.ysk.cashier.pojo.shop.TbShopTable;
|
||||||
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.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
@ -122,5 +123,14 @@ public class MpCashierCartServiceImpl extends ServiceImpl<TbCashierCartMapper, T
|
||||||
}
|
}
|
||||||
return list(queryWrapper);
|
return list(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TbCashierCart> selectByOrderIdAndState(Integer orderId, TableConstant.OrderInfo.Status status) {
|
||||||
|
LambdaQueryChainWrapper<TbCashierCart> queryChainWrapper = lambdaQuery().eq(TbCashierCart::getOrderId, orderId);
|
||||||
|
if (status != null) {
|
||||||
|
queryChainWrapper.eq(TbCashierCart::getStatus, status.getValue());
|
||||||
|
}
|
||||||
|
return queryChainWrapper.list();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package cn.ysk.cashier.mybatis.service.impl;
|
package cn.ysk.cashier.mybatis.service.impl;
|
||||||
|
|
||||||
|
import cn.ysk.cashier.cons.TableConstant;
|
||||||
import cn.ysk.cashier.dto.shoptable.ReturnOrderDTO;
|
import cn.ysk.cashier.dto.shoptable.ReturnOrderDTO;
|
||||||
import cn.ysk.cashier.enums.OrderStatusEnums;
|
import cn.ysk.cashier.enums.OrderStatusEnums;
|
||||||
import cn.ysk.cashier.mybatis.mapper.TbOrderDetailMapper;
|
import cn.ysk.cashier.mybatis.mapper.TbOrderDetailMapper;
|
||||||
|
|
@ -48,7 +49,14 @@ public class MpOrderDetailServiceImpl extends ServiceImpl<TbOrderDetailMapper, T
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TbOrderDetail> selectByCartIdOrOrderId(Integer shopId, ArrayList<Integer> cartIdList, Integer orderId) {
|
public List<TbOrderDetail> selectByOrderIdAndState(Integer orderId, TableConstant.OrderInfo.Status state) {
|
||||||
|
return list(new LambdaQueryWrapper<TbOrderDetail>()
|
||||||
|
.eq(TbOrderDetail::getStatus, state.getValue())
|
||||||
|
.eq(TbOrderDetail::getOrderId, orderId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TbOrderDetail> selectByCartIdOrOrderId(Integer shopId, List<Integer> cartIdList, Integer orderId) {
|
||||||
return list(new LambdaQueryWrapper<TbOrderDetail>()
|
return list(new LambdaQueryWrapper<TbOrderDetail>()
|
||||||
.and(q -> q.in(TbOrderDetail::getCartId, cartIdList).or().eq(TbOrderDetail::getOrderId, orderId))
|
.and(q -> q.in(TbOrderDetail::getCartId, cartIdList).or().eq(TbOrderDetail::getOrderId, orderId))
|
||||||
.eq(TbOrderDetail::getShopId, shopId));
|
.eq(TbOrderDetail::getShopId, shopId));
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package cn.ysk.cashier.mybatis.service.impl;
|
package cn.ysk.cashier.mybatis.service.impl;
|
||||||
|
|
||||||
|
import cn.ysk.cashier.cons.TableConstant;
|
||||||
import cn.ysk.cashier.mybatis.mapper.TbCashierCartMapper;
|
import cn.ysk.cashier.mybatis.mapper.TbCashierCartMapper;
|
||||||
import cn.ysk.cashier.mybatis.mapper.TbOrderInfoMapper;
|
import cn.ysk.cashier.mybatis.mapper.TbOrderInfoMapper;
|
||||||
import cn.ysk.cashier.mybatis.service.MpCashierCartService;
|
import cn.ysk.cashier.mybatis.service.MpCashierCartService;
|
||||||
|
|
@ -33,5 +34,12 @@ public class MpOrderInfoServiceImpl extends ServiceImpl<TbOrderInfoMapper, TbOrd
|
||||||
.set(TbOrderInfo::getUseType, useType)
|
.set(TbOrderInfo::getUseType, useType)
|
||||||
.set(TbOrderInfo::getTableId, tableId));
|
.set(TbOrderInfo::getTableId, tableId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TbOrderInfo selectOrderByIdAndState(Integer orderId, TableConstant.OrderInfo.Status status) {
|
||||||
|
return getOne(new LambdaQueryWrapper<TbOrderInfo>()
|
||||||
|
.eq(TbOrderInfo::getId, orderId)
|
||||||
|
.eq(TbOrderInfo::getStatus, status.getValue()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
package cn.ysk.cashier.mybatis.service.impl;
|
||||||
|
|
||||||
|
import cn.ysk.cashier.enums.TableStateEnum;
|
||||||
|
import cn.ysk.cashier.mybatis.mapper.MpShopTableMapper;
|
||||||
|
import cn.ysk.cashier.mybatis.mapper.TbShopUserMapper;
|
||||||
|
import cn.ysk.cashier.mybatis.service.MpShopTableService;
|
||||||
|
import cn.ysk.cashier.mybatis.service.MpShopUserService;
|
||||||
|
import cn.ysk.cashier.pojo.shop.TbShopTable;
|
||||||
|
import cn.ysk.cashier.pojo.shop.TbShopUser;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class MpShopUserServiceImpl extends ServiceImpl<TbShopUserMapper, TbShopUser> implements MpShopUserService {
|
||||||
|
@Override
|
||||||
|
public TbShopUser selectByUserIdAndShopId(Integer userId, Integer shopId) {
|
||||||
|
return getOne(new LambdaQueryWrapper<TbShopUser>()
|
||||||
|
.eq(TbShopUser::getUserId, userId)
|
||||||
|
.eq(TbShopUser::getShopId, shopId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,17 +4,19 @@ import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.bean.copier.CopyOptions;
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.ysk.cashier.cons.TableConstant;
|
||||||
import cn.ysk.cashier.dto.CouponDto;
|
import cn.ysk.cashier.dto.CouponDto;
|
||||||
import cn.ysk.cashier.dto.QueryReceiveDto;
|
import cn.ysk.cashier.dto.QueryReceiveDto;
|
||||||
import cn.ysk.cashier.dto.TbShopCouponQueryCriteria;
|
import cn.ysk.cashier.dto.TbShopCouponQueryCriteria;
|
||||||
|
import cn.ysk.cashier.exception.BadRequestException;
|
||||||
import cn.ysk.cashier.mybatis.entity.*;
|
import cn.ysk.cashier.mybatis.entity.*;
|
||||||
import cn.ysk.cashier.mybatis.mapper.TbActivateInRecordMapper;
|
import cn.ysk.cashier.mybatis.mapper.TbActivateInRecordMapper;
|
||||||
import cn.ysk.cashier.mybatis.mapper.TbActivateOutRecordMapper;
|
import cn.ysk.cashier.mybatis.mapper.TbActivateOutRecordMapper;
|
||||||
|
import cn.ysk.cashier.mybatis.mapper.TbMShopUserMapper;
|
||||||
import cn.ysk.cashier.mybatis.mapper.TbShopCouponMapper;
|
import cn.ysk.cashier.mybatis.mapper.TbShopCouponMapper;
|
||||||
import cn.ysk.cashier.mybatis.service.TbActivateInRecordService;
|
import cn.ysk.cashier.mybatis.service.*;
|
||||||
import cn.ysk.cashier.mybatis.service.TbCouponProductService;
|
|
||||||
import cn.ysk.cashier.mybatis.service.TbShopCouponService;
|
|
||||||
import cn.ysk.cashier.mybatis.vo.TbShopCouponVo;
|
import cn.ysk.cashier.mybatis.vo.TbShopCouponVo;
|
||||||
|
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||||
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
||||||
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||||
import cn.ysk.cashier.pojo.product.TbProduct;
|
import cn.ysk.cashier.pojo.product.TbProduct;
|
||||||
|
|
@ -70,6 +72,19 @@ public class TbShopCouponServiceImpl extends ServiceImpl<TbShopCouponMapper, TbS
|
||||||
private TbActivateInRecordMapper inRecordMapper;
|
private TbActivateInRecordMapper inRecordMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private TbActivateOutRecordMapper outRecordMapper;
|
private TbActivateOutRecordMapper outRecordMapper;
|
||||||
|
private final TbMShopUserMapper shopUserMapper;
|
||||||
|
private final MpShopUserService shopUserService;
|
||||||
|
private final MpOrderInfoService mpOrderInfoService;
|
||||||
|
private final MpOrderDetailService mpOrderDetailService;
|
||||||
|
private final MpCashierCartService mpCashierCartService;
|
||||||
|
|
||||||
|
public TbShopCouponServiceImpl(TbMShopUserMapper shopUserMapper, MpShopUserService shopUserService, MpOrderInfoService mpOrderInfoService, MpOrderDetailService mpOrderDetailService, MpCashierCartService mpCashierCartService) {
|
||||||
|
this.shopUserMapper = shopUserMapper;
|
||||||
|
this.shopUserService = shopUserService;
|
||||||
|
this.mpOrderInfoService = mpOrderInfoService;
|
||||||
|
this.mpOrderDetailService = mpOrderDetailService;
|
||||||
|
this.mpCashierCartService = mpCashierCartService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -77,7 +92,7 @@ public class TbShopCouponServiceImpl extends ServiceImpl<TbShopCouponMapper, TbS
|
||||||
Page<TbShopCoupon> page = new Page<>(criteria.getPage(), criteria.getSize());
|
Page<TbShopCoupon> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
QueryWrapper<TbShopCoupon> wrapper = new QueryWrapper<>();
|
QueryWrapper<TbShopCoupon> wrapper = new QueryWrapper<>();
|
||||||
wrapper.eq("shop_id", criteria.getShopId());
|
wrapper.eq("shop_id", criteria.getShopId());
|
||||||
if (criteria.getType()!=null) {
|
if (criteria.getType() != null) {
|
||||||
wrapper.eq("type", criteria.getType());
|
wrapper.eq("type", criteria.getType());
|
||||||
}
|
}
|
||||||
wrapper.orderByDesc("create_time");
|
wrapper.orderByDesc("create_time");
|
||||||
|
|
@ -149,6 +164,72 @@ public class TbShopCouponServiceImpl extends ServiceImpl<TbShopCouponMapper, TbS
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TbUserCouponVo> getActivateCoupon(TbShopUser tbShopUser, BigDecimal orderAmount, Integer shopId, Set<String> productIds) {
|
||||||
|
List<TbUserCouponVo> tbUserCouponVos = inRecordMapper.queryByVipIdAndShopId(tbShopUser.getId(), shopId);
|
||||||
|
if (tbUserCouponVos.isEmpty()) {
|
||||||
|
return tbUserCouponVos;
|
||||||
|
}
|
||||||
|
String week = DateUtil.dayOfWeekEnum(new Date()).toChinese("周");
|
||||||
|
LocalTime now = LocalTime.now();
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
|
||||||
|
//券id 券使用描述
|
||||||
|
Map<Integer, JsonObject> coupons = new HashMap<>();
|
||||||
|
for (TbUserCouponVo tbUserCouponVo : tbUserCouponVos) {
|
||||||
|
if (!coupons.containsKey(tbUserCouponVo.getCouponId())) {
|
||||||
|
setCouponInfo(coupons, tbUserCouponVo, orderAmount, week, now, formatter);
|
||||||
|
}
|
||||||
|
JsonObject couponJson = coupons.get(tbUserCouponVo.getCouponId());
|
||||||
|
tbUserCouponVo.setUseRestrictions(couponJson.get("useRestrictions").toString());
|
||||||
|
if (tbUserCouponVo.getType().equals(1)) {
|
||||||
|
tbUserCouponVo.setUse(couponJson.get("isUse").getAsBoolean());
|
||||||
|
} else if (tbUserCouponVo.getType().equals(2) && couponJson.get("isUse").getAsBoolean()) {
|
||||||
|
if (!productIds.contains(tbUserCouponVo.getProId().toString())) {
|
||||||
|
tbUserCouponVo.setUse(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tbUserCouponVos.sort(Comparator.comparing(TbUserCouponVo::isUse).reversed().thenComparing(TbUserCouponVo::getExpireTime));
|
||||||
|
return tbUserCouponVos;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setCouponInfo(Map<Integer, JsonObject> coupons, TbUserCouponVo tbUserCouponVo, BigDecimal amount, String week, LocalTime now, DateTimeFormatter formatter) {
|
||||||
|
JsonObject json = new JsonObject();
|
||||||
|
boolean isUse = true;
|
||||||
|
TbShopCoupon tbShopCoupon = getById(tbUserCouponVo.getCouponId());
|
||||||
|
StringBuilder useRestrictions = new StringBuilder("每天 ");
|
||||||
|
if (tbShopCoupon.getType().equals(1)) {
|
||||||
|
if (amount.compareTo(new BigDecimal(tbShopCoupon.getFullAmount())) < 0) {
|
||||||
|
isUse = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(tbShopCoupon.getUserDays())) {
|
||||||
|
String[] split = tbShopCoupon.getUserDays().split(",");
|
||||||
|
if (split.length != 7) {
|
||||||
|
useRestrictions = new StringBuilder(tbShopCoupon.getUserDays() + " ");
|
||||||
|
}
|
||||||
|
if (!tbShopCoupon.getUserDays().contains(week)) {
|
||||||
|
isUse = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (tbShopCoupon.getUseTimeType().equals("custom")) {
|
||||||
|
if (now.isBefore(tbShopCoupon.getUseStartTime()) || now.isAfter(tbShopCoupon.getUseEndTime())) {
|
||||||
|
isUse = false;
|
||||||
|
}
|
||||||
|
useRestrictions.append(
|
||||||
|
tbShopCoupon.getUseStartTime().format(formatter)
|
||||||
|
+ "-"
|
||||||
|
+ tbShopCoupon.getUseEndTime().format(formatter));
|
||||||
|
} else {
|
||||||
|
useRestrictions.append("全时段");
|
||||||
|
}
|
||||||
|
useRestrictions.append(" 可用");
|
||||||
|
json.addProperty("isUse", isUse);
|
||||||
|
json.addProperty("useRestrictions", useRestrictions.toString());
|
||||||
|
|
||||||
|
coupons.put(tbUserCouponVo.getCouponId(), json);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Object> find(CouponDto param) {
|
public ResponseEntity<Object> find(CouponDto param) {
|
||||||
|
|
@ -225,14 +306,15 @@ public class TbShopCouponServiceImpl extends ServiceImpl<TbShopCouponMapper, TbS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 使用券
|
* 使用券
|
||||||
|
*
|
||||||
* @param shopId
|
* @param shopId
|
||||||
* @param orderId
|
* @param orderId
|
||||||
* @param vipUserId
|
* @param vipUserId
|
||||||
* @param param giveId 和 useNum 必传
|
* @param param giveId 和 useNum 必传
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean use(Integer shopId,Integer orderId,Integer vipUserId,List<TbActivateOutRecord> param) {
|
public boolean use(Integer shopId, Integer orderId, Integer vipUserId, List<TbActivateOutRecord> param) {
|
||||||
for (TbActivateOutRecord outRecord : param) {
|
for (TbActivateOutRecord outRecord : param) {
|
||||||
TbActivateInRecord inRecord = inRecordMapper.selectById(outRecord.getGiveId());
|
TbActivateInRecord inRecord = inRecordMapper.selectById(outRecord.getGiveId());
|
||||||
inRecord.setOverNum(inRecord.getOverNum() - outRecord.getUseNum());
|
inRecord.setOverNum(inRecord.getOverNum() - outRecord.getUseNum());
|
||||||
|
|
@ -251,14 +333,15 @@ public class TbShopCouponServiceImpl extends ServiceImpl<TbShopCouponMapper, TbS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退还券
|
* 退还券
|
||||||
* @param param giveId和 refNum 必传
|
*
|
||||||
|
* @param param giveId和 refNum 必传
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean refund(List<TbActivateOutRecord> param) {
|
public boolean refund(List<TbActivateOutRecord> param) {
|
||||||
for (TbActivateOutRecord outRecord : param) {
|
for (TbActivateOutRecord outRecord : param) {
|
||||||
outRecord.setUpdateTime(new Date());
|
outRecord.setUpdateTime(new Date());
|
||||||
outRecordMapper.updateRefNum(outRecord.getId(),outRecord.getRefNum());
|
outRecordMapper.updateRefNum(outRecord.getId(), outRecord.getRefNum());
|
||||||
TbActivateInRecord inRecord = inRecordMapper.selectById(outRecord.getGiveId());
|
TbActivateInRecord inRecord = inRecordMapper.selectById(outRecord.getGiveId());
|
||||||
inRecord.setOverNum(inRecord.getOverNum() + outRecord.getRefNum());
|
inRecord.setOverNum(inRecord.getOverNum() + outRecord.getRefNum());
|
||||||
inRecordMapper.updateOverNum(inRecord.getId(), inRecord.getOverNum());
|
inRecordMapper.updateOverNum(inRecord.getId(), inRecord.getOverNum());
|
||||||
|
|
@ -284,5 +367,46 @@ public class TbShopCouponServiceImpl extends ServiceImpl<TbShopCouponMapper, TbS
|
||||||
}
|
}
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TbShopCoupon> selectByIds(List<Integer> couponIds) {
|
||||||
|
return listByIds(couponIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getActivateByOrderIds(Integer shopId, Integer orderId, Integer memberId) {
|
||||||
|
TbOrderInfo orderInfo = mpOrderInfoService.selectOrderByIdAndState(orderId, TableConstant.OrderInfo.Status.UNPAID);
|
||||||
|
if (orderInfo == null) {
|
||||||
|
throw new BadRequestException("订单信息不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (memberId == null) {
|
||||||
|
memberId = Integer.valueOf(orderInfo.getMemberId());
|
||||||
|
}
|
||||||
|
|
||||||
|
TbShopUser shopUser = shopUserService.getById(memberId);
|
||||||
|
if (shopUser == null) {
|
||||||
|
throw new BadRequestException("用户信息不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TbCashierCart> cashierCarts = mpCashierCartService.selectByOrderIdAndState(orderId, TableConstant.OrderInfo.Status.UNPAID);
|
||||||
|
List<TbUserCouponVo> activateCouponList = getActivateCoupon(shopUser, orderInfo.getOrderAmount(), shopId, cashierCarts.stream().map(TbCashierCart::getProductId).collect(Collectors.toSet()));
|
||||||
|
// 将优惠券分类为满减和商品
|
||||||
|
ArrayList<TbUserCouponVo> fullReductionCoupon = new ArrayList<>();
|
||||||
|
ArrayList<TbUserCouponVo> productCoupon = new ArrayList<>();
|
||||||
|
activateCouponList.forEach(item -> {
|
||||||
|
if (TableConstant.ActivateOutRecord.Type.FULL_REDUCTION.equalsVals(item.getType())) {
|
||||||
|
fullReductionCoupon.add(item);
|
||||||
|
} else {
|
||||||
|
productCoupon.add(item);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new HashMap<String, Object>(){{
|
||||||
|
put("fullReductionCoupon", fullReductionCoupon);
|
||||||
|
put("productCoupon", productCoupon);
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -163,6 +163,8 @@ public class TbCashierCart implements Serializable {
|
||||||
private String useType;
|
private String useType;
|
||||||
@Column(name = "platform_type")
|
@Column(name = "platform_type")
|
||||||
private String platformType;
|
private String platformType;
|
||||||
|
// 优惠券id
|
||||||
|
private Integer userCouponId;
|
||||||
|
|
||||||
public void copy(TbCashierCart source){
|
public void copy(TbCashierCart source){
|
||||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,7 @@ public class TbOrderInfo implements Serializable {
|
||||||
// 使用的积分数量
|
// 使用的积分数量
|
||||||
private Integer pointsNum;
|
private Integer pointsNum;
|
||||||
// 用户优惠券id
|
// 用户优惠券id
|
||||||
private String userCouponInfoList;
|
private String couponInfoList;
|
||||||
// 优惠券折扣金额
|
// 优惠券折扣金额
|
||||||
private BigDecimal productCouponDiscountAmount;
|
private BigDecimal productCouponDiscountAmount;
|
||||||
// 满减抵扣金额
|
// 满减抵扣金额
|
||||||
|
|
|
||||||
|
|
@ -38,4 +38,7 @@ public interface TbPlussShopStaffRepository extends JpaRepository<TbPlussShopSta
|
||||||
@Modifying
|
@Modifying
|
||||||
@Query("update TbPlussShopStaff set name=:name where shopId = :shopId and type='master'")
|
@Query("update TbPlussShopStaff set name=:name where shopId = :shopId and type='master'")
|
||||||
void updateNameById(String name, String shopId);
|
void updateNameById(String name, String shopId);
|
||||||
}
|
|
||||||
|
@Query("select staff from TbPlussShopStaff as staff where staff.shopId=:shopId and staff.type='master'")
|
||||||
|
TbPlussShopStaff queryMasterAccount(String shopId);
|
||||||
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,15 @@
|
||||||
|
package cn.ysk.cashier.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class ActivateInInfoVO {
|
||||||
|
private Integer id;
|
||||||
|
private Integer couponId;
|
||||||
|
private Integer num;
|
||||||
|
// 1满减 2商品
|
||||||
|
private Integer type;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -2,11 +2,14 @@ package cn.ysk.cashier.vo;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class TbUserCouponVo {
|
public class TbUserCouponVo {
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
private BigDecimal fullAmount;
|
||||||
|
private BigDecimal discountAmount;
|
||||||
private Integer couponId;
|
private Integer couponId;
|
||||||
private Integer proId;
|
private Integer proId;
|
||||||
//优惠券名称
|
//优惠券名称
|
||||||
|
|
@ -20,6 +23,8 @@ public class TbUserCouponVo {
|
||||||
private Long expireTime;
|
private Long expireTime;
|
||||||
private String useRestrictions;
|
private String useRestrictions;
|
||||||
private boolean isUse = false;
|
private boolean isUse = false;
|
||||||
|
//当前使用数量
|
||||||
|
private Integer currentUseNum;
|
||||||
|
|
||||||
|
|
||||||
public void setEndTime(Date endTime) {
|
public void setEndTime(Date endTime) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue