Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
Tankaikai 2024-11-05 09:31:40 +08:00
commit c69cc065a6
42 changed files with 1153 additions and 751 deletions

View File

@ -167,9 +167,15 @@
</properties>
</profile>
<profile>
<id>pro</id>
<id>pre</id>
<properties>
<env>pro</env>
<env>pre</env>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<env>prod</env>
</properties>
</profile>
</profiles>

View File

@ -57,12 +57,17 @@ public interface TableConstant {
@Getter
public enum Status {
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;
Status(String value) {
this.value = value;
}
public boolean equalsVals(String value) {
return this.value.equals(value);
}
}
@Getter

View File

@ -61,6 +61,10 @@ public class TbConsInfo implements Serializable {
@ApiModelProperty(value = "单位换算")
private BigDecimal conUnitTwoConvert;
@Column(name = "`default_unit`")
@ApiModelProperty(value = "默认入库单位")
private String defaultUnit;
@Column(name = "`laster_in_stock`")
@ApiModelProperty(value = "最近一次入库量")
private BigDecimal lasterInStock;
@ -102,9 +106,6 @@ public class TbConsInfo implements Serializable {
@ApiModelProperty(value = "是否检测库存")
private String isCheck;
@Transient
private List<Map<Integer, Object>> product;
public void copy(TbConsInfo source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}

View File

@ -63,6 +63,10 @@ public class TbConsInfoV2 implements Serializable {
@ApiModelProperty(value = "单位换算")
private BigDecimal conUnitTwoConvert;
@Column(name = "`default_unit`")
@ApiModelProperty(value = "默认入库单位")
private String defaultUnit;
@Column(name = "`laster_in_stock`")
@ApiModelProperty(value = "最近一次入库量")

View File

@ -39,6 +39,7 @@ public class TbConsInfoDto implements Serializable {
private String conUnitTwo;
private BigDecimal conUnitTwoConvert;
private String defaultUnit;
/** 最近一次入库量 */
private BigDecimal lasterInStock;
@ -71,5 +72,4 @@ public class TbConsInfoDto implements Serializable {
private String isCheck;
private List<Map<Integer, Object>> product;
}

View File

@ -231,10 +231,18 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
}
BigDecimal changeStock = conInfos.getStockNumber();
//副单位的实际修改值
if (StringUtils.isNotBlank(conInfos.getUnit()) && conInfos.getUnit().equals(info.getConUnitTwo())) {
if(StringUtils.isNotBlank(conInfos.getUnit())){
info.setDefaultUnit(conInfos.getUnit());
if(conInfos.getUnit().equals(info.getConUnitTwo())){
changeStock = conInfos.getStockNumber().multiply(info.getConUnitTwoConvert()).setScale(2, BigDecimal.ROUND_HALF_UP);
}
}else if(info.getConUnitTwo().equals(info.getDefaultUnit())) {
info.setDefaultUnit(info.getConUnitTwo());
changeStock = conInfos.getStockNumber().multiply(info.getConUnitTwoConvert()).setScale(2, BigDecimal.ROUND_HALF_UP);
}
TbConsSuppFlow suppFlow = new TbConsSuppFlow();
TbConsInfoFlow flow = new TbConsInfoFlow();

View File

@ -90,5 +90,11 @@ public class TbShopCouponController {
tbShopCouponService.deleteReceive(ids);
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));
}
}

View File

@ -175,8 +175,14 @@ public class TbPlaceController {
JSONObject userInfo = JSON.parseObject(JSON.toJSONString(redisUtils.get("online-token-" + token)));
String userName = userInfo.getString("userName");
String shopId = userInfo.getString("shopId");
TbPlussShopStaff shopStaff = staffRepository.queryByAccount(userName, shopId);
TbMerchantAccount merchantAccount = tbMerchantAccountMapper.selectOne(Wrappers.<TbMerchantAccount>lambdaQuery().eq(TbMerchantAccount::getAccount, shopStaff.getAccount()));
TbPlussShopStaff shopStaff;
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 staffId = shopStaff.getId();
List<TbToken> onlineUserList = tbTokenRepository.findListByAccountIdAndStaffId(accountId, staffId);

View File

@ -26,7 +26,6 @@ public class SummaryController {
//营业板块
@PostMapping("/trade")
@AnonymousPostMapping
private Object shopSummaryDate(@RequestBody BaseQueryDto param) {
return summaryService.trade(param);
}

View File

@ -1,37 +0,0 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.ysk.cashier.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @website https://eladmin.vip
* @description /
* @author admin
* @date 2023-10-31
**/
@Data
public class BotButtonConfigDto implements Serializable {
private Integer id;
/** 按钮名称 */
private String buttonName;
/** 按钮值 */
private String buttonValue;
}

View File

@ -1,32 +0,0 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.ysk.cashier.dto;
import lombok.Data;
import cn.ysk.cashier.annotation.Query;
/**
* @website https://eladmin.vip
* @author admin
* @date 2023-10-31
**/
@Data
public class BotButtonConfigQueryCriteria{
/** 精确 */
@Query
private String buttonName;
}

View File

@ -1,40 +0,0 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.ysk.cashier.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @website https://eladmin.vip
* @description /
* @author admin
* @date 2023-10-31
**/
@Data
public class BotConfigDto implements Serializable {
private Integer id;
/** 元素键值 */
private String configKey;
/** 元素值 */
private String configValue;
/** 描述 */
private String remark;
}

View File

@ -1,36 +0,0 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.ysk.cashier.dto;
import lombok.Data;
import cn.ysk.cashier.annotation.Query;
/**
* @website https://eladmin.vip
* @author admin
* @date 2023-10-31
**/
@Data
public class BotConfigQueryCriteria{
/** 精确 */
@Query
private String configKey;
/** 精确 */
@Query
private String configValue;
}

View File

@ -1,87 +0,0 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.ysk.cashier.dto;
import lombok.Data;
import java.sql.Timestamp;
import java.math.BigDecimal;
import java.io.Serializable;
/**
* @website https://eladmin.vip
* @description /
* @author admin
* @date 2023-10-30
**/
@Data
public class BotUserDto implements Serializable {
private Integer id;
private Integer fatherId;
/** 父级电报号 */
private String fatherTelegramId;
/** 电报号 */
private String userTelegramId;
/** 用户名称 */
private String userName;
/** 组电报号 */
private String groupTelegramId;
/** 用户代码 */
private String userCode;
private String userPayPass;
private String bombStatus;
/** 用户状态 */
private String botStatus;
/** 总充值 */
private BigDecimal usdtRechargeTotal;
/** 总提现 */
private BigDecimal usdtWithdrawTotal;
/** 总资金 */
private BigDecimal balance;
/** 冻结资金 */
private BigDecimal freezeBalance;
/** 版本号 */
private Integer version;
/** 创建时间 */
private Timestamp createTime;
/** 更新时间 */
private Timestamp updateTime;
/** 语言 */
private String userLanguage;
/** 质押资金 */
private BigDecimal chipBalance;
/** 绑定时间 */
private Timestamp fatherBindTime;
}

View File

@ -1,54 +0,0 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.ysk.cashier.dto;
import lombok.Data;
import java.sql.Timestamp;
import java.math.BigDecimal;
import java.io.Serializable;
/**
* @website https://eladmin.vip
* @description /
* @author admin
* @date 2023-10-30
**/
@Data
public class BotUserFlowDto implements Serializable {
private Integer id;
/** 电报号 */
private String userTelegramId;
/** 用户名称 */
private String userName;
/** 业务代码 */
private String bizCode;
/** 变动金额 */
private BigDecimal amount;
/** 变动前金额 */
private BigDecimal oldBalance;
/** 变动后金额 */
private BigDecimal newBalance;
/** 创建时间 */
private Timestamp createTime;
}

View File

@ -1,40 +0,0 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.ysk.cashier.dto;
import lombok.Data;
import cn.ysk.cashier.annotation.Query;
/**
* @website https://eladmin.vip
* @author admin
* @date 2023-10-30
**/
@Data
public class BotUserFlowQueryCriteria{
/** 精确 */
@Query
private String userTelegramId;
/** 精确 */
@Query
private String userName;
/** 精确 */
@Query
private String bizCode;
}

View File

@ -1,48 +0,0 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.ysk.cashier.dto;
import lombok.Data;
import cn.ysk.cashier.annotation.Query;
/**
* @website https://eladmin.vip
* @author admin
* @date 2023-10-30
**/
@Data
public class BotUserQueryCriteria{
/** 精确 */
@Query
private String fatherTelegramId;
/** 精确 */
@Query
private String userTelegramId;
/** 精确 */
@Query
private String userName;
/** 精确 */
@Query
private String userCode;
/** 精确 */
@Query
private String botStatus;
}

View File

@ -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;
}

View File

@ -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<>();
}

View File

@ -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<>();
}

View File

@ -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;
}

View File

@ -1,7 +1,11 @@
package cn.ysk.cashier.dto.shoptable;
import cn.ysk.cashier.dto.order.UserCouponInfoDTO;
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.NotNull;
import java.util.ArrayList;
@ -19,9 +23,11 @@ public class CreateOrderDTO {
private Integer orderId;
@NotEmpty
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;
}

View File

@ -1,11 +1,15 @@
package cn.ysk.cashier.dto.shoptable;
import cn.ysk.cashier.dto.order.UserCouponInfoDTO;
import lombok.Data;
import javax.validation.Valid;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
@Data
public class PayDTO {
@ -20,6 +24,11 @@ public class PayDTO {
private Double discount;
private Integer vipUserId;
private String code;
private String token;
// 使用的优惠券
@Valid
private List<UserCouponInfoDTO> userCouponInfos = new ArrayList<>();
// 使用的积分抵扣数量
private Integer pointsNum;
}

View File

@ -13,7 +13,7 @@ public class UpdateVipDTO {
private String tableId;
@NotNull
private String masterId;
private Integer orderId;
private Integer vipUserId;
@NotNull
@Range(min = 0, max = 1)

View File

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.ysk.cashier.mybatis.entity.TbActivateInRecord;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.util.List;
@ -17,7 +18,9 @@ import java.util.List;
public interface TbActivateInRecordMapper extends BaseMapper<TbActivateInRecord> {
@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," +
" pro.id as proId," +
" CASE" +
@ -34,14 +37,19 @@ public interface TbActivateInRecordMapper extends BaseMapper<TbActivateInRecord>
" inRecord.vip_user_id = #{vipUserId}" +
" and inRecord.shop_id = #{shopId}" +
" and inRecord.over_num != 0" +
" and inRecord.use_start_time &lt; now()" +
" and inRecord.use_end_time &gt; now()" +
" and inRecord.use_start_time < now()" +
" and inRecord.use_end_time > now()" +
" order by inRecord.use_end_time asc")
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}" +
" where id = #{id}")
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);
}

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
/**
* 活动赠送商品使用记录表(TbActivateOutRecord)表数据库访问层
@ -13,7 +14,7 @@ import org.apache.ibatis.annotations.Select;
*/
public interface TbActivateOutRecordMapper extends BaseMapper<TbActivateOutRecord> {
@Select("update tb_activate_out_record" +
@Update("update tb_activate_out_record" +
" set ref_num = ref_num + #{refNum}" +
" where id = #{id}")
int updateRefNum(@Param("id") Integer id, @Param("refNum") Integer refNum);

View File

@ -64,5 +64,11 @@ public interface MpCashierCartService extends IService<TbCashierCart> {
*/
List<TbCashierCart> selectByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId);
/**
* 根据订单id和状态获取购物车数据
* @param orderId 订单id
* @param status 状态 可为空
*/
List<TbCashierCart> selectByOrderIdAndState(Integer orderId, TableConstant.OrderInfo.Status status);
}

View File

@ -1,5 +1,6 @@
package cn.ysk.cashier.mybatis.service;
import cn.ysk.cashier.cons.TableConstant;
import cn.ysk.cashier.dto.shoptable.ReturnOrderDTO;
import cn.ysk.cashier.enums.OrderStatusEnums;
import cn.ysk.cashier.pojo.order.TbFullOrderDetail;
@ -42,6 +43,11 @@ public interface MpOrderDetailService extends IService<TbOrderDetail> {
*/
List<TbOrderDetail> selectByOrderId(Integer orderId);
/**
* 根据订单id和状态获取订单详情
*/
List<TbOrderDetail> selectByOrderIdAndState(Integer orderId, TableConstant.OrderInfo.Status state);
/**
* 根据购物车id和订单id查询订单详情
* @param shopId 店铺id
@ -49,6 +55,6 @@ public interface MpOrderDetailService extends IService<TbOrderDetail> {
* @param orderId 订单id
* @return 详情信息
*/
List<TbOrderDetail> selectByCartIdOrOrderId(Integer shopId, ArrayList<Integer> cartIdList, Integer orderId);
List<TbOrderDetail> selectByCartIdOrOrderId(Integer shopId, List<Integer> cartIdList, Integer orderId);
}

View File

@ -1,5 +1,6 @@
package cn.ysk.cashier.mybatis.service;
import cn.ysk.cashier.cons.TableConstant;
import cn.ysk.cashier.enums.OrderStatusEnums;
import cn.ysk.cashier.pojo.order.TbOrderDetail;
import cn.ysk.cashier.pojo.order.TbOrderInfo;
@ -15,19 +16,29 @@ import java.util.List;
*/
public interface MpOrderInfoService extends IService<TbOrderInfo> {
/**
* 根据原始订单查询退款订单
* @param orderId 原始订单id
* @return 对应的退款订单
*/
TbOrderInfo selectReturnOrderByOrderId(Integer orderId);
/**
* 根据原始订单查询退款订单
*
* @param orderId 原始订单id
* @return 对应的退款订单
*/
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 useType 就餐类型
* @return 是否成功
* @param status 状态枚举
*/
boolean updateTableIdAndUseTypeById(Integer orderId, String useType, String tableId);
TbOrderInfo selectOrderByIdAndState(Integer orderId, TableConstant.OrderInfo.Status status);
}

View File

@ -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);
}

View File

@ -2,18 +2,26 @@ package cn.ysk.cashier.mybatis.service;
import cn.ysk.cashier.dto.CouponDto;
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.TbCouponProduct;
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.TbUserCouponVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import cn.ysk.cashier.mybatis.entity.TbShopCoupon;
import cn.ysk.cashier.dto.TbShopCouponQueryCriteria;
import org.springframework.http.ResponseEntity;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* 优惠券(TbShopCoupon)表服务接口
@ -30,6 +38,16 @@ public interface TbShopCouponService extends IService<TbShopCoupon> {
boolean update(TbShopCouponVo param);
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);
ResponseEntity<Object> find(CouponDto param);
@ -39,5 +57,20 @@ public interface TbShopCouponService extends IService<TbShopCoupon> {
boolean refund(List<TbActivateOutRecord> param);
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);
}

View File

@ -15,6 +15,7 @@ import cn.ysk.cashier.pojo.shop.TbShopInfo;
import cn.ysk.cashier.pojo.shop.TbShopTable;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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 org.springframework.stereotype.Service;
@ -122,5 +123,14 @@ public class MpCashierCartServiceImpl extends ServiceImpl<TbCashierCartMapper, T
}
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();
}
}

View File

@ -1,5 +1,6 @@
package cn.ysk.cashier.mybatis.service.impl;
import cn.ysk.cashier.cons.TableConstant;
import cn.ysk.cashier.dto.shoptable.ReturnOrderDTO;
import cn.ysk.cashier.enums.OrderStatusEnums;
import cn.ysk.cashier.mybatis.mapper.TbOrderDetailMapper;
@ -48,7 +49,14 @@ public class MpOrderDetailServiceImpl extends ServiceImpl<TbOrderDetailMapper, T
}
@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>()
.and(q -> q.in(TbOrderDetail::getCartId, cartIdList).or().eq(TbOrderDetail::getOrderId, orderId))
.eq(TbOrderDetail::getShopId, shopId));

View File

@ -1,5 +1,6 @@
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.TbOrderInfoMapper;
import cn.ysk.cashier.mybatis.service.MpCashierCartService;
@ -33,5 +34,12 @@ public class MpOrderInfoServiceImpl extends ServiceImpl<TbOrderInfoMapper, TbOrd
.set(TbOrderInfo::getUseType, useType)
.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()));
}
}

View File

@ -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));
}
}

View File

@ -4,17 +4,19 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.ysk.cashier.cons.TableConstant;
import cn.ysk.cashier.dto.CouponDto;
import cn.ysk.cashier.dto.QueryReceiveDto;
import cn.ysk.cashier.dto.TbShopCouponQueryCriteria;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mybatis.entity.*;
import cn.ysk.cashier.mybatis.mapper.TbActivateInRecordMapper;
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.service.TbActivateInRecordService;
import cn.ysk.cashier.mybatis.service.TbCouponProductService;
import cn.ysk.cashier.mybatis.service.TbShopCouponService;
import cn.ysk.cashier.mybatis.service.*;
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.product.TbProduct;
@ -70,6 +72,19 @@ public class TbShopCouponServiceImpl extends ServiceImpl<TbShopCouponMapper, TbS
private TbActivateInRecordMapper inRecordMapper;
@Autowired
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
@ -77,7 +92,7 @@ public class TbShopCouponServiceImpl extends ServiceImpl<TbShopCouponMapper, TbS
Page<TbShopCoupon> page = new Page<>(criteria.getPage(), criteria.getSize());
QueryWrapper<TbShopCoupon> wrapper = new QueryWrapper<>();
wrapper.eq("shop_id", criteria.getShopId());
if (criteria.getType()!=null) {
if (criteria.getType() != null) {
wrapper.eq("type", criteria.getType());
}
wrapper.orderByDesc("create_time");
@ -149,6 +164,72 @@ public class TbShopCouponServiceImpl extends ServiceImpl<TbShopCouponMapper, TbS
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
public ResponseEntity<Object> find(CouponDto param) {
@ -225,14 +306,15 @@ public class TbShopCouponServiceImpl extends ServiceImpl<TbShopCouponMapper, TbS
/**
* 使用券
*
* @param shopId
* @param orderId
* @param vipUserId
* @param param giveId useNum 必传
* @param param giveId useNum 必传
* @return
*/
@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) {
TbActivateInRecord inRecord = inRecordMapper.selectById(outRecord.getGiveId());
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
*/
@Override
public boolean refund(List<TbActivateOutRecord> param) {
for (TbActivateOutRecord outRecord : param) {
outRecord.setUpdateTime(new Date());
outRecordMapper.updateRefNum(outRecord.getId(),outRecord.getRefNum());
outRecordMapper.updateRefNum(outRecord.getId(), outRecord.getRefNum());
TbActivateInRecord inRecord = inRecordMapper.selectById(outRecord.getGiveId());
inRecord.setOverNum(inRecord.getOverNum() + outRecord.getRefNum());
inRecordMapper.updateOverNum(inRecord.getId(), inRecord.getOverNum());
@ -284,5 +367,50 @@ public class TbShopCouponServiceImpl extends ServiceImpl<TbShopCouponMapper, TbS
}
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 && orderInfo.getMemberId() == 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);
}};
}
}

View File

@ -163,6 +163,8 @@ public class TbCashierCart implements Serializable {
private String useType;
@Column(name = "platform_type")
private String platformType;
// 优惠券id
private Integer userCouponId;
public void copy(TbCashierCart source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));

View File

@ -246,9 +246,11 @@ public class TbOrderInfo implements Serializable {
// 使用的积分数量
private Integer pointsNum;
// 用户优惠券id
private String activateInInfoList;
private String couponInfoList;
// 优惠券折扣金额
private BigDecimal activateInDiscountAmount;
private BigDecimal productCouponDiscountAmount;
// 满减抵扣金额
private BigDecimal fullCouponDiscountAmount;
public void copy(TbOrderInfo source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));

View File

@ -38,4 +38,7 @@ public interface TbPlussShopStaffRepository extends JpaRepository<TbPlussShopSta
@Modifying
@Query("update TbPlussShopStaff set name=:name where shopId = :shopId and type='master'")
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);
}

View File

@ -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;
}

View File

@ -2,11 +2,14 @@ package cn.ysk.cashier.vo;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class TbUserCouponVo {
private Integer id;
private BigDecimal fullAmount;
private BigDecimal discountAmount;
private Integer couponId;
private Integer proId;
//优惠券名称
@ -20,6 +23,8 @@ public class TbUserCouponVo {
private Long expireTime;
private String useRestrictions;
private boolean isUse = false;
//当前使用数量
private Integer currentUseNum;
public void setEndTime(Date endTime) {