交班相关代码
This commit is contained in:
parent
166634e3f0
commit
8cbfbe265f
|
|
@ -0,0 +1,37 @@
|
|||
package com.czg.controller.admin;
|
||||
|
||||
import com.czg.account.service.HandoverRecordService;
|
||||
import com.czg.account.vo.HandoverTotalVo;
|
||||
import com.czg.log.annotation.OperationLog;
|
||||
import com.czg.resp.CzgResult;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
/**
|
||||
* 交班
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-27
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/admin/handover-record")
|
||||
public class HandoverRecordController {
|
||||
private final HandoverRecordService handoverRecordService;
|
||||
|
||||
|
||||
/**
|
||||
* 收银机-交班数据统计
|
||||
*/
|
||||
@GetMapping("total")
|
||||
@OperationLog("收银机-交班数据统计")
|
||||
//@SaAdminCheckPermission("handoverRecord:total")
|
||||
public CzgResult<HandoverTotalVo> total() {
|
||||
HandoverTotalVo data = handoverRecordService.totalHandoverData();
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -13,6 +13,14 @@ spring:
|
|||
logging:
|
||||
config: classpath:logback.xml
|
||||
|
||||
# MyBatis-Flex
|
||||
mybatis-flex:
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
cache-enabled: false
|
||||
call-setters-on-nulls: true
|
||||
jdbc-type-for-null: 'null'
|
||||
|
||||
wx:
|
||||
appId: wxd88fffa983758a30
|
||||
secrete: a34a61adc0602118b49400baa8812454
|
||||
|
|
|
|||
|
|
@ -10,3 +10,17 @@ spring:
|
|||
|
||||
logging:
|
||||
config: classpath:logback.xml
|
||||
|
||||
# MyBatis-Flex
|
||||
mybatis-flex:
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
cache-enabled: false
|
||||
call-setters-on-nulls: true
|
||||
jdbc-type-for-null: 'null'
|
||||
|
||||
dubbo:
|
||||
consumer:
|
||||
check: false
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,100 @@
|
|||
package com.czg.account.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 交班记录表
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-27
|
||||
*/
|
||||
@Data
|
||||
public class HandoverRecordDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
/**
|
||||
* 店铺 id
|
||||
*/
|
||||
private Long shopId;
|
||||
/**
|
||||
* 店铺 id
|
||||
*/
|
||||
private String shopName;
|
||||
/**
|
||||
* 登录时间
|
||||
*/
|
||||
private LocalDateTime loginTime;
|
||||
/**
|
||||
* 交班时间
|
||||
*/
|
||||
private LocalDateTime handoverTime;
|
||||
/**
|
||||
* 账户类型 merchant-商户 staff-员工
|
||||
*/
|
||||
private String accountType;
|
||||
/**
|
||||
* 员工 id
|
||||
*/
|
||||
private Long staffId;
|
||||
/**
|
||||
* 员工姓名
|
||||
*/
|
||||
private String staffName;
|
||||
/**
|
||||
* 当班总收入
|
||||
*/
|
||||
private BigDecimal handAmount;
|
||||
/**
|
||||
* 现金收入
|
||||
*/
|
||||
private BigDecimal cashAmount;
|
||||
/**
|
||||
* 微信收入
|
||||
*/
|
||||
private BigDecimal wechatAmount;
|
||||
/**
|
||||
* 支付宝收入
|
||||
*/
|
||||
private BigDecimal alipayAmount;
|
||||
/**
|
||||
* 会员支付
|
||||
*/
|
||||
private BigDecimal vipPay;
|
||||
/**
|
||||
* 会员充值
|
||||
*/
|
||||
private BigDecimal vipRecharge;
|
||||
/**
|
||||
* 分类数据 json
|
||||
*/
|
||||
private String categoryData;
|
||||
/**
|
||||
* 商品数据 json
|
||||
*/
|
||||
private String productData;
|
||||
/**
|
||||
* 快捷收款金额
|
||||
*/
|
||||
private BigDecimal quickInAmount;
|
||||
/**
|
||||
* 退款金额
|
||||
*/
|
||||
private BigDecimal refundAmount;
|
||||
/**
|
||||
* 挂账金额
|
||||
*/
|
||||
private BigDecimal creditAmount;
|
||||
/**
|
||||
* 订单数量
|
||||
*/
|
||||
private Integer orderCount;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
package com.czg.account.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 交班记录表
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-27
|
||||
*/
|
||||
@Data
|
||||
@Table("tb_handover_record")
|
||||
public class HandoverRecord implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
/**
|
||||
* 店铺 id
|
||||
*/
|
||||
private Long shopId;
|
||||
/**
|
||||
* 店铺名称
|
||||
*/
|
||||
private String shopName;
|
||||
/**
|
||||
* 登录时间
|
||||
*/
|
||||
private LocalDateTime loginTime;
|
||||
/**
|
||||
* 交班时间
|
||||
*/
|
||||
private LocalDateTime handoverTime;
|
||||
/**
|
||||
* 账户类型 merchant-商户 staff-员工
|
||||
*/
|
||||
private String accountType;
|
||||
/**
|
||||
* 员工 id
|
||||
*/
|
||||
private Long staffId;
|
||||
/**
|
||||
* 员工姓名
|
||||
*/
|
||||
private String staffName;
|
||||
/**
|
||||
* 当班总收入
|
||||
*/
|
||||
private BigDecimal handAmount;
|
||||
/**
|
||||
* 现金收入
|
||||
*/
|
||||
private BigDecimal cashAmount;
|
||||
/**
|
||||
* 微信收入
|
||||
*/
|
||||
private BigDecimal wechatAmount;
|
||||
/**
|
||||
* 支付宝收入
|
||||
*/
|
||||
private BigDecimal alipayAmount;
|
||||
/**
|
||||
* 会员支付
|
||||
*/
|
||||
private BigDecimal vipPay;
|
||||
/**
|
||||
* 会员充值
|
||||
*/
|
||||
private BigDecimal vipRecharge;
|
||||
/**
|
||||
* 分类数据 json
|
||||
*/
|
||||
private String categoryData;
|
||||
/**
|
||||
* 商品数据 json
|
||||
*/
|
||||
private String productData;
|
||||
/**
|
||||
* 快捷收款金额
|
||||
*/
|
||||
private BigDecimal quickInAmount;
|
||||
/**
|
||||
* 退款金额
|
||||
*/
|
||||
private BigDecimal refundAmount;
|
||||
/**
|
||||
* 挂账金额
|
||||
*/
|
||||
private BigDecimal creditAmount;
|
||||
/**
|
||||
* 订单数量
|
||||
*/
|
||||
private Integer orderCount;
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@ import com.mybatisflex.annotation.Column;
|
|||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.mybatisflex.core.keygen.KeyGenerators;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
|
|
@ -27,7 +26,7 @@ public class PictureClassify implements Serializable {
|
|||
/**
|
||||
* id
|
||||
*/
|
||||
@Id(keyType = KeyType.Generator, value = KeyGenerators.snowFlakeId)
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
/**
|
||||
* 店铺id
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
package com.czg.account.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 交班账户类型
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2025-02-27 14:39
|
||||
*/
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum HandoverAccountTypeEnum {
|
||||
/**
|
||||
* 商户
|
||||
*/
|
||||
MERCHANT("merchant", "商户"),
|
||||
|
||||
/**
|
||||
* 员工
|
||||
*/
|
||||
STAFF("staff", "员工");
|
||||
|
||||
private final String value;
|
||||
private final String text;
|
||||
|
||||
|
||||
public static List<String> getValues() {
|
||||
return Arrays.stream(values()).map(HandoverAccountTypeEnum::getValue).toList();
|
||||
}
|
||||
|
||||
public static String getText(String value) {
|
||||
HandoverAccountTypeEnum item = Arrays.stream(values()).filter(obj -> value.equals(obj.getValue())).findFirst().orElse(null);
|
||||
if (item != null) {
|
||||
return item.getText();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.czg.account.service;
|
||||
|
||||
import com.czg.account.entity.HandoverRecord;
|
||||
import com.czg.account.vo.HandoverTotalVo;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
/**
|
||||
* 交班记录表
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-27
|
||||
*/
|
||||
public interface HandoverRecordService extends IService<HandoverRecord> {
|
||||
/**
|
||||
* 统计交班数据
|
||||
*
|
||||
* @return 交班数据
|
||||
*/
|
||||
HandoverTotalVo totalHandoverData();
|
||||
|
||||
/**
|
||||
* 初始化交班记录
|
||||
*/
|
||||
void initHandoverRecord(HandoverRecord entity);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package com.czg.account.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 交班售出商品
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2025-02-27 15:34
|
||||
*/
|
||||
@Data
|
||||
public class HandoverProductListVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
private Long productId;
|
||||
/**
|
||||
* sku id
|
||||
*/
|
||||
private Long skuId;
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
private String productName;
|
||||
/**
|
||||
* 规格名称
|
||||
*/
|
||||
private String skuName;
|
||||
/**
|
||||
* 商品数量
|
||||
*/
|
||||
private BigDecimal num;
|
||||
/**
|
||||
* 小计(商品金额)
|
||||
*/
|
||||
private BigDecimal amount;
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
package com.czg.account.vo;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 交班数据统计
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2025-02-27 15:34
|
||||
*/
|
||||
@Data
|
||||
public class HandoverTotalVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 当班记录id
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
/**
|
||||
* 店铺名称
|
||||
*/
|
||||
private String shopName;
|
||||
/**
|
||||
* 账户类型 merchant-商户 staff-员工
|
||||
*/
|
||||
private String accountType;
|
||||
/**
|
||||
* 员工id
|
||||
*/
|
||||
private Long staffId;
|
||||
/**
|
||||
* 员工名称(营业员)
|
||||
*/
|
||||
private String staffName;
|
||||
/**
|
||||
* 上岗时间
|
||||
*/
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime loginTime;
|
||||
/**
|
||||
* 交班时间
|
||||
*/
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime handoverTime;
|
||||
/**
|
||||
* 现金支付
|
||||
*/
|
||||
private BigDecimal cashAmount;
|
||||
/**
|
||||
* 退款金额
|
||||
*/
|
||||
private BigDecimal refundAmount;
|
||||
/**
|
||||
* 当班总收入(营业额)
|
||||
*/
|
||||
private BigDecimal handAmount;
|
||||
/**
|
||||
* 订单数量
|
||||
*/
|
||||
private Integer orderCount;
|
||||
/**
|
||||
* 售出商品列表
|
||||
*/
|
||||
private List<HandoverProductListVo> detailList;
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.czg.order.service;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.account.vo.HandoverProductListVo;
|
||||
import com.czg.order.dto.CheckOrderPay;
|
||||
import com.czg.order.dto.OrderInfoAddDTO;
|
||||
import com.czg.order.dto.OrderInfoQueryDTO;
|
||||
|
|
@ -15,6 +16,7 @@ import org.jetbrains.annotations.NotNull;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单表 服务层。
|
||||
|
|
@ -37,4 +39,54 @@ public interface OrderInfoService extends IService<OrderInfo> {
|
|||
void upOrderInfo(OrderInfo orderInfo, BigDecimal payAmount, LocalDateTime payTime, Long payOrderId, PayEnums payType);
|
||||
|
||||
void expired(Long orderId);
|
||||
|
||||
/**
|
||||
* 交班现金支付统计
|
||||
*
|
||||
* @param shopId 店铺id
|
||||
* @param loginTime 上岗时间
|
||||
* @param handoverTime 交班时间
|
||||
* @return 现金支付总额
|
||||
*/
|
||||
BigDecimal getHandoverCashAmount(Long shopId, String loginTime, String handoverTime);
|
||||
|
||||
/**
|
||||
* 交班退款统计
|
||||
*
|
||||
* @param shopId 店铺id
|
||||
* @param loginTime 上岗时间
|
||||
* @param handoverTime 交班时间
|
||||
* @return 退款总额
|
||||
*/
|
||||
BigDecimal getHandoverRefundAmount(Long shopId, String loginTime, String handoverTime);
|
||||
|
||||
/**
|
||||
* 交班营业额统计
|
||||
*
|
||||
* @param shopId 店铺id
|
||||
* @param loginTime 上岗时间
|
||||
* @param handoverTime 交班时间
|
||||
* @return 营业额
|
||||
*/
|
||||
BigDecimal getHandoverTotalAmount(Long shopId, String loginTime, String handoverTime);
|
||||
|
||||
/**
|
||||
* 交班订单数统计
|
||||
*
|
||||
* @param shopId 店铺id
|
||||
* @param loginTime 上岗时间
|
||||
* @param handoverTime 交班时间
|
||||
* @return 交班订单数
|
||||
*/
|
||||
int getHandoverOrderNum(Long shopId, String loginTime, String handoverTime);
|
||||
|
||||
/**
|
||||
* 交班售出商品明细
|
||||
*
|
||||
* @param shopId 店铺id
|
||||
* @param loginTime 上岗时间
|
||||
* @param handoverTime 交班时间
|
||||
* @return 交班售出商品明细
|
||||
*/
|
||||
List<HandoverProductListVo> getHandoverDetailList(Long shopId, String loginTime, String handoverTime);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
package com.czg.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 平台类型枚举
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2025-02-27 14:39
|
||||
*/
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum PlatformTypeEnum {
|
||||
/**
|
||||
* 收银机客户端
|
||||
*/
|
||||
PC_CLIENT("PC", "收银机客户端"),
|
||||
/**
|
||||
* 微信小程序
|
||||
*/
|
||||
WECHAT("WX", "微信小程序"),
|
||||
/**
|
||||
* 支付宝小程序
|
||||
*/
|
||||
ALIPAY("ALI", "支付宝小程序"),
|
||||
/**
|
||||
* PC管理端
|
||||
*/
|
||||
WEB_ADMIN("WEB", "PC管理端"),
|
||||
/**
|
||||
* APP管理端
|
||||
*/
|
||||
APP_ADMIN("APP", "APP管理端");
|
||||
|
||||
private final String value;
|
||||
private final String text;
|
||||
|
||||
|
||||
public static List<String> getValues() {
|
||||
return Arrays.stream(values()).map(PlatformTypeEnum::getValue).toList();
|
||||
}
|
||||
|
||||
public static String getText(String value) {
|
||||
PlatformTypeEnum item = Arrays.stream(values()).filter(obj -> value.equals(obj.getValue())).findFirst().orElse(null);
|
||||
if (item != null) {
|
||||
return item.getText();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.czg.account.entity.HandoverRecord;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 交班记录表
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-27
|
||||
*/
|
||||
@Mapper
|
||||
public interface HandoverRecordMapper extends BaseMapper<HandoverRecord> {
|
||||
|
||||
}
|
||||
|
|
@ -6,20 +6,23 @@ import cn.hutool.core.util.StrUtil;
|
|||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.czg.account.dto.SysLoginDTO;
|
||||
import com.czg.account.entity.*;
|
||||
import com.czg.account.enums.HandoverAccountTypeEnum;
|
||||
import com.czg.account.service.*;
|
||||
import com.czg.account.vo.LoginVO;
|
||||
import com.czg.config.RedisCst;
|
||||
import com.czg.enums.PlatformTypeEnum;
|
||||
import com.czg.enums.StatusEnum;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.czg.sa.MyStpLogic;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.RedisService;
|
||||
import com.czg.service.account.mapper.SysMenuMapper;
|
||||
import com.czg.utils.ServletUtil;
|
||||
import com.wf.captcha.SpecCaptcha;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -44,6 +47,8 @@ public class AuthorizationServiceImpl implements AuthorizationService {
|
|||
private SysRoleService sysRoleService;
|
||||
@Resource
|
||||
private SysMenuMapper sysMenuMapper;
|
||||
@Resource
|
||||
private HandoverRecordService handoverRecordService;
|
||||
|
||||
|
||||
@Override
|
||||
|
|
@ -83,8 +88,8 @@ public class AuthorizationServiceImpl implements AuthorizationService {
|
|||
}
|
||||
|
||||
user = sysUserService.queryChain().eq(SysUser::getAccount, sysUser.getId() + "@" + loginDTO.staffUserName()).one();
|
||||
}else {
|
||||
user = sysUserService.queryChain().eq(SysUser::getAccount,loginDTO.username()).one();
|
||||
} else {
|
||||
user = sysUserService.queryChain().eq(SysUser::getAccount, loginDTO.username()).one();
|
||||
}
|
||||
|
||||
if (user == null) {
|
||||
|
|
@ -97,11 +102,12 @@ public class AuthorizationServiceImpl implements AuthorizationService {
|
|||
}
|
||||
|
||||
ShopInfo shopInfo;
|
||||
ShopStaff shopStaff = null;
|
||||
boolean isStaff = false;
|
||||
List<String> shopStaffPromissionList = null;
|
||||
// 商户员工登录
|
||||
if (loginDTO.loginType() == 1) {
|
||||
ShopStaff shopStaff = shopStaffService.queryChain().eq(ShopStaff::getStatus, 1)
|
||||
shopStaff = shopStaffService.queryChain().eq(ShopStaff::getStatus, 1)
|
||||
.eq(ShopStaff::getIsManage, 1)
|
||||
.eq(ShopStaff::getId, user.getId()).one();
|
||||
if (shopStaff == null) {
|
||||
|
|
@ -112,7 +118,7 @@ public class AuthorizationServiceImpl implements AuthorizationService {
|
|||
|
||||
// 查询员工权限
|
||||
shopStaffPromissionList = shopStaffPermissionService.getPermissionByStaffId(shopInfo.getId(), shopStaff.getId(), user.getId()).stream().map(ShopPermission::getCode).toList();
|
||||
}else {
|
||||
} else {
|
||||
shopInfo = shopInfoService.getById(user.getId());
|
||||
}
|
||||
|
||||
|
|
@ -126,7 +132,7 @@ public class AuthorizationServiceImpl implements AuthorizationService {
|
|||
}
|
||||
}
|
||||
|
||||
StpKit.USER.login(user.getId(), user.getAccount(), shopInfo.getId(), isStaff ? MyStpLogic.LoginType.STAFF :MyStpLogic.LoginType.MANAGER, user.getIsAdmin());
|
||||
StpKit.USER.login(user.getId(), user.getAccount(), shopInfo.getId(), isStaff ? MyStpLogic.LoginType.STAFF : MyStpLogic.LoginType.MANAGER, user.getIsAdmin());
|
||||
// 查询角色
|
||||
List<SysRole> roleList = sysRoleService.getByUserId(user.getId());
|
||||
List<String> roleNames = roleList.stream().map(SysRole::getName).collect(Collectors.toList());
|
||||
|
|
@ -138,6 +144,30 @@ public class AuthorizationServiceImpl implements AuthorizationService {
|
|||
promissionList.addAll(shopStaffPromissionList);
|
||||
}
|
||||
StpKit.USER.addPermissionList(promissionList);
|
||||
String platformType = ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType");
|
||||
if (PlatformTypeEnum.PC_CLIENT.getValue().equals(platformType)) {
|
||||
// 初始化交班记录
|
||||
HandoverRecord entity = getHandoverRecord(isStaff, shopInfo, shopStaff);
|
||||
handoverRecordService.initHandoverRecord(entity);
|
||||
}
|
||||
return new LoginVO(StpKit.USER.getTokenInfo(), promissionList, loginDTO.loginType(), shopInfo);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static HandoverRecord getHandoverRecord(boolean isStaff, ShopInfo shopInfo, ShopStaff shopStaff) {
|
||||
HandoverRecord entity = new HandoverRecord();
|
||||
if (isStaff) {
|
||||
entity.setAccountType(HandoverAccountTypeEnum.STAFF.getValue());
|
||||
entity.setStaffId(shopStaff.getId());
|
||||
entity.setStaffName(shopStaff.getName());
|
||||
} else {
|
||||
entity.setAccountType(HandoverAccountTypeEnum.MERCHANT.getValue());
|
||||
|
||||
entity.setStaffId(shopInfo.getId());
|
||||
entity.setStaffName(shopInfo.getShopName());
|
||||
}
|
||||
entity.setShopId(shopInfo.getId());
|
||||
entity.setShopName(shopInfo.getShopName());
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,103 @@
|
|||
package com.czg.service.account.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import com.czg.account.dto.HandoverRecordDTO;
|
||||
import com.czg.account.entity.HandoverRecord;
|
||||
import com.czg.account.service.HandoverRecordService;
|
||||
import com.czg.account.vo.HandoverProductListVo;
|
||||
import com.czg.account.vo.HandoverTotalVo;
|
||||
import com.czg.order.service.OrderInfoService;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.account.mapper.HandoverRecordMapper;
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 交班记录表
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-27
|
||||
*/
|
||||
@Service
|
||||
public class HandoverRecordServiceImpl extends ServiceImpl<HandoverRecordMapper, HandoverRecord> implements HandoverRecordService {
|
||||
|
||||
@DubboReference
|
||||
private OrderInfoService orderInfoService;
|
||||
|
||||
private QueryWrapper buildQueryWrapper(HandoverRecordDTO param) {
|
||||
QueryWrapper queryWrapper = PageUtil.buildSortQueryWrapper();
|
||||
/*if (StrUtil.isNotEmpty(param.getName())) {
|
||||
queryWrapper.like(HandoverRecord::getName, param.getName());
|
||||
}*/
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
queryWrapper.eq(HandoverRecord::getShopId, shopId);
|
||||
queryWrapper.orderBy(HandoverRecord::getId, false);
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public HandoverTotalVo totalHandoverData() {
|
||||
orderInfoService.historyOrder(0L, "11");
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
LocalDateTime handoverTime = LocalDateTime.now();
|
||||
HandoverRecord record = super.getOne(query().eq(HandoverRecord::getShopId, shopId).isNull(HandoverRecord::getHandoverTime));
|
||||
HandoverTotalVo data = new HandoverTotalVo();
|
||||
data.setId(record.getId());
|
||||
data.setShopId(record.getShopId());
|
||||
data.setShopName(record.getShopName());
|
||||
data.setAccountType(record.getAccountType());
|
||||
data.setStaffId(record.getStaffId());
|
||||
data.setStaffName(record.getStaffName());
|
||||
data.setLoginTime(record.getLoginTime());
|
||||
data.setHandoverTime(handoverTime);
|
||||
String loginTimeStr = LocalDateTimeUtil.formatNormal(record.getLoginTime());
|
||||
String handoverTimeStr = LocalDateTimeUtil.formatNormal(handoverTime);
|
||||
data.setCashAmount(sumCashAmount(shopId, loginTimeStr, handoverTimeStr));
|
||||
data.setRefundAmount(sumRefundAmount(shopId, loginTimeStr, handoverTimeStr));
|
||||
data.setHandAmount(sumHandAmount(shopId, loginTimeStr, handoverTimeStr));
|
||||
data.setOrderCount(countOrderNum(shopId, loginTimeStr, handoverTimeStr));
|
||||
data.setDetailList(getDetailList(shopId, loginTimeStr, handoverTimeStr));
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initHandoverRecord(HandoverRecord entity) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
List<HandoverRecord> list = super.list(query().eq(HandoverRecord::getShopId, shopId).isNull(HandoverRecord::getHandoverTime));
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
return;
|
||||
}
|
||||
entity.setShopId(shopId);
|
||||
entity.setLoginTime(LocalDateTime.now());
|
||||
super.save(entity);
|
||||
}
|
||||
|
||||
private BigDecimal sumCashAmount(Long shopId, String loginTime, String handoverTime) {
|
||||
return orderInfoService.getHandoverCashAmount(shopId, loginTime, handoverTime);
|
||||
}
|
||||
|
||||
private BigDecimal sumRefundAmount(Long shopId, String loginTime, String handoverTime) {
|
||||
return orderInfoService.getHandoverRefundAmount(shopId, loginTime, handoverTime);
|
||||
}
|
||||
|
||||
private BigDecimal sumHandAmount(Long shopId, String loginTime, String handoverTime) {
|
||||
return orderInfoService.getHandoverTotalAmount(shopId, loginTime, handoverTime);
|
||||
}
|
||||
|
||||
private int countOrderNum(Long shopId, String loginTime, String handoverTime) {
|
||||
return orderInfoService.getHandoverOrderNum(shopId, loginTime, handoverTime);
|
||||
}
|
||||
|
||||
private List<HandoverProductListVo> getDetailList(Long shopId, String loginTime, String handoverTime) {
|
||||
return orderInfoService.getHandoverDetailList(shopId, loginTime, handoverTime);
|
||||
}
|
||||
}
|
||||
|
|
@ -32,7 +32,7 @@ public class PictureClassifyServiceImpl extends ServiceImpl<PictureClassifyMappe
|
|||
if (StrUtil.isNotEmpty(param.getName())) {
|
||||
queryWrapper.like(PictureClassify::getName, param.getName());
|
||||
}
|
||||
Long shopId = StpKit.USER.getLoginIdAsLong();
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
queryWrapper.and(q -> {
|
||||
q.eq(PictureClassify::getShopId, shopId).or(q1 -> {
|
||||
q1.eq(PictureClassify::getShopId, 0).eq(PictureClassify::getIsSystem, YesNoEnum.YES.value());
|
||||
|
|
@ -52,7 +52,7 @@ public class PictureClassifyServiceImpl extends ServiceImpl<PictureClassifyMappe
|
|||
|
||||
@Override
|
||||
public void addPictureClassify(PictureClassifyDTO dto) {
|
||||
Long shopId = StpKit.USER.getLoginIdAsLong();
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
boolean exists = super.exists(query().eq(PictureClassify::getName, dto.getName())
|
||||
.and(q -> {
|
||||
q.eq(PictureClassify::getShopId, shopId).or(q1 -> {
|
||||
|
|
@ -72,7 +72,7 @@ public class PictureClassifyServiceImpl extends ServiceImpl<PictureClassifyMappe
|
|||
@Override
|
||||
public void updatePictureClassify(PictureClassifyDTO dto) {
|
||||
checkPictureClassify(dto.getId());
|
||||
Long shopId = StpKit.USER.getLoginIdAsLong();
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
dto.setShopId(shopId);
|
||||
boolean exists = super.exists(query().eq(PictureClassify::getName, dto.getName())
|
||||
.ne(PictureClassify::getId, dto.getId())
|
||||
|
|
@ -93,7 +93,7 @@ public class PictureClassifyServiceImpl extends ServiceImpl<PictureClassifyMappe
|
|||
@Override
|
||||
public void deletePictureClassify(Long id) {
|
||||
checkPictureClassify(id);
|
||||
Long shopId = StpKit.USER.getLoginIdAsLong();
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
UpdateChain.of(PictureClassify.class)
|
||||
.set(PictureClassify::getIsDel, DeleteEnum.DELETED.value())
|
||||
.eq(PictureClassify::getShopId, shopId)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class PictureGalleryServiceImpl extends ServiceImpl<PictureGalleryMapper,
|
|||
if (ObjUtil.isNotNull(param.getPictureClassifyId())) {
|
||||
queryWrapper.eq(PictureGallery::getPictureClassifyId, param.getPictureClassifyId());
|
||||
}
|
||||
Long shopId = StpKit.USER.getLoginIdAsLong();
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
queryWrapper.eq(PictureGallery::getShopId, shopId);
|
||||
queryWrapper.eq(PictureGallery::getIsDel, DeleteEnum.NORMAL.value());
|
||||
queryWrapper.orderBy(PictureGallery::getId, false);
|
||||
|
|
@ -48,7 +48,7 @@ public class PictureGalleryServiceImpl extends ServiceImpl<PictureGalleryMapper,
|
|||
|
||||
@Override
|
||||
public void addPictureGallery(PictureGalleryParam param) {
|
||||
Long shopId = StpKit.USER.getLoginIdAsLong();
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
for (String url : param.getUrls()) {
|
||||
PictureGallery entity = new PictureGallery();
|
||||
entity.setShopId(shopId);
|
||||
|
|
@ -61,7 +61,7 @@ public class PictureGalleryServiceImpl extends ServiceImpl<PictureGalleryMapper,
|
|||
|
||||
@Override
|
||||
public void deletePictureGallery(Long id) {
|
||||
Long shopId = StpKit.USER.getLoginIdAsLong();
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
UpdateChain.of(PictureGallery.class)
|
||||
.set(PictureGallery::getIsDel, DeleteEnum.DELETED.value())
|
||||
.eq(PictureGallery::getShopId, shopId)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
<?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="com.czg.service.account.mapper.HandoverRecordMapper">
|
||||
|
||||
</mapper>
|
||||
|
|
@ -1,7 +1,11 @@
|
|||
package com.czg.service.order.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.account.vo.HandoverProductListVo;
|
||||
import com.czg.order.entity.OrderInfo;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单表 映射层。
|
||||
|
|
@ -11,4 +15,54 @@ import com.czg.order.entity.OrderInfo;
|
|||
*/
|
||||
public interface OrderInfoMapper extends BaseMapper<OrderInfo> {
|
||||
|
||||
/**
|
||||
* 交班现金支付统计
|
||||
*
|
||||
* @param shopId 店铺id
|
||||
* @param loginTime 上岗时间
|
||||
* @param handoverTime 交班时间
|
||||
* @return 现金支付总额
|
||||
*/
|
||||
BigDecimal getHandoverCashAmount(Long shopId, String loginTime, String handoverTime);
|
||||
|
||||
/**
|
||||
* 交班退款统计
|
||||
*
|
||||
* @param shopId 店铺id
|
||||
* @param loginTime 上岗时间
|
||||
* @param handoverTime 交班时间
|
||||
* @return 退款总额
|
||||
*/
|
||||
BigDecimal getHandoverRefundAmount(Long shopId, String loginTime, String handoverTime);
|
||||
|
||||
/**
|
||||
* 交班营业额统计
|
||||
*
|
||||
* @param shopId 店铺id
|
||||
* @param loginTime 上岗时间
|
||||
* @param handoverTime 交班时间
|
||||
* @return 营业额
|
||||
*/
|
||||
BigDecimal getHandoverTotalAmount(Long shopId, String loginTime, String handoverTime);
|
||||
|
||||
/**
|
||||
* 交班订单数统计
|
||||
*
|
||||
* @param shopId 店铺id
|
||||
* @param loginTime 上岗时间
|
||||
* @param handoverTime 交班时间
|
||||
* @return 交班订单数
|
||||
*/
|
||||
int getHandoverOrderNum(Long shopId, String loginTime, String handoverTime);
|
||||
|
||||
/**
|
||||
* 交班售出商品明细
|
||||
*
|
||||
* @param shopId 店铺id
|
||||
* @param loginTime 上岗时间
|
||||
* @param handoverTime 交班时间
|
||||
* @return 交班售出商品明细
|
||||
*/
|
||||
List<HandoverProductListVo> getHandoverDetailList(Long shopId, String loginTime, String handoverTime);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import com.alibaba.fastjson2.JSONObject;
|
|||
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
|
||||
import com.czg.account.entity.*;
|
||||
import com.czg.account.service.*;
|
||||
import com.czg.account.vo.HandoverProductListVo;
|
||||
import com.czg.config.RabbitPublisher;
|
||||
import com.czg.config.RedisCst;
|
||||
import com.czg.entity.notify.CzgPayNotifyDTO;
|
||||
|
|
@ -566,6 +567,31 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getHandoverCashAmount(Long shopId, String loginTime, String handoverTime) {
|
||||
return super.mapper.getHandoverCashAmount(shopId, loginTime, handoverTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getHandoverRefundAmount(Long shopId, String loginTime, String handoverTime) {
|
||||
return super.mapper.getHandoverRefundAmount(shopId, loginTime, handoverTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getHandoverTotalAmount(Long shopId, String loginTime, String handoverTime) {
|
||||
return super.mapper.getHandoverTotalAmount(shopId, loginTime, handoverTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHandoverOrderNum(Long shopId, String loginTime, String handoverTime) {
|
||||
return super.mapper.getHandoverOrderNum(shopId, loginTime, handoverTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HandoverProductListVo> getHandoverDetailList(Long shopId, String loginTime, String handoverTime) {
|
||||
return super.mapper.getHandoverDetailList(shopId, loginTime, handoverTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化订单信息
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -4,4 +4,82 @@
|
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.service.order.mapper.OrderInfoMapper">
|
||||
|
||||
<sql id="handoverCommonWhere">
|
||||
AND t1.shop_id =
|
||||
#{shopId}
|
||||
<![CDATA[
|
||||
AND
|
||||
t1
|
||||
.
|
||||
paid_time
|
||||
>=
|
||||
str_to_date
|
||||
(
|
||||
#{loginTime},
|
||||
'%Y-%m-%d %H:%i:%s'
|
||||
)
|
||||
AND
|
||||
t1
|
||||
.
|
||||
paid_time
|
||||
<=
|
||||
str_to_date
|
||||
(
|
||||
#{handoverTime},
|
||||
'%Y-%m-%d %H:%i:%s'
|
||||
)
|
||||
]]>
|
||||
</sql>
|
||||
|
||||
<select id="getHandoverCashAmount" resultType="java.math.BigDecimal">
|
||||
SELECT
|
||||
ifnull(sum(pay_amount),0)
|
||||
FROM tb_order_info t1
|
||||
<where>
|
||||
<include refid="handoverCommonWhere"/>
|
||||
and t1.pay_type = 'cash-pay'
|
||||
</where>
|
||||
</select>
|
||||
<select id="getHandoverRefundAmount" resultType="java.math.BigDecimal">
|
||||
SELECT
|
||||
ifnull(sum(refund_amount),0)
|
||||
FROM tb_order_info t1
|
||||
<where>
|
||||
<include refid="handoverCommonWhere"/>
|
||||
</where>
|
||||
</select>
|
||||
<select id="getHandoverTotalAmount" resultType="java.math.BigDecimal">
|
||||
SELECT
|
||||
ifnull(sum(pay_amount),0)
|
||||
FROM tb_order_info t1
|
||||
<where>
|
||||
<include refid="handoverCommonWhere"/>
|
||||
</where>
|
||||
</select>
|
||||
<select id="getHandoverOrderNum" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
count(*)
|
||||
FROM tb_order_info t1
|
||||
<where>
|
||||
<include refid="handoverCommonWhere"/>
|
||||
</where>
|
||||
</select>
|
||||
<select id="getHandoverDetailList" resultType="com.czg.account.vo.HandoverProductListVo">
|
||||
SELECT
|
||||
t2.product_id,
|
||||
t2.sku_id,
|
||||
GROUP_CONCAT( DISTINCT t2.product_name ) AS product_name,
|
||||
GROUP_CONCAT( DISTINCT t2.sku_name ) AS sku_name,
|
||||
sum( ifnull(t2.num,0) ) AS num,
|
||||
sum( ifnull(t2.pay_amount,0) ) amount
|
||||
FROM
|
||||
tb_order_detail t2
|
||||
LEFT JOIN tb_order_info t1 ON t1.id = t2.order_id
|
||||
<where>
|
||||
<include refid="handoverCommonWhere"/>
|
||||
</where>
|
||||
GROUP BY
|
||||
t2.product_id,
|
||||
t2.sku_id
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ public class ShopVendorServiceImpl extends ServiceImpl<ShopVendorMapper, ShopVen
|
|||
}
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
queryWrapper.eq(ShopVendor::getShopId, shopId);
|
||||
queryWrapper.eq(ShopVendor::getIsDel, DeleteEnum.NORMAL.value());
|
||||
queryWrapper.orderBy(ShopVendor::getSort, true);
|
||||
queryWrapper.orderBy(ShopVendor::getId, false);
|
||||
return queryWrapper;
|
||||
|
|
@ -48,7 +49,6 @@ public class ShopVendorServiceImpl extends ServiceImpl<ShopVendorMapper, ShopVen
|
|||
@Override
|
||||
public List<ShopVendorDTO> getShopVendorList(ShopVendorDTO param) {
|
||||
QueryWrapper queryWrapper = buildQueryWrapper(param);
|
||||
queryWrapper.eq(ShopVendor::getIsDel, DeleteEnum.NORMAL.value());
|
||||
return super.listAs(queryWrapper, ShopVendorDTO.class);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue