This commit is contained in:
2025-07-01 17:54:58 +08:00
commit 57dcd609e2
5136 changed files with 346184 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.zhwl</groupId>
<artifactId>zhwl-business</artifactId>
<version>3.8.7</version>
</parent>
<artifactId>zhwl-sales-point</artifactId>
<description>售票点模块</description>
<dependencies>
<dependency>
<groupId>com.zhwl</groupId>
<artifactId>zhwl-device-ticket_machine</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,117 @@
package com.zhwl.sales.point.controller;
import com.zhwl.common.annotation.Log;
import com.zhwl.common.core.controller.BaseController;
import com.zhwl.common.core.domain.AjaxResult;
import com.zhwl.common.core.page.TableDataInfo;
import com.zhwl.common.enums.BusinessType;
import com.zhwl.common.utils.poi.ExcelUtil;
import com.zhwl.sales.point.domain.ZdySalesPoint;
import com.zhwl.sales.point.service.IZdySalesPointService;
import com.zhwl.sales.point.vo.ZdyDeviceTicketMachineVO;
import com.zhwl.sales.point.vo.ZdyTicketSellerVO;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 售票点信息Controller
*
* @author song_xiaowei
* @date 2024-08-15
*/
@RestController
@RequestMapping("/business/salesPoint")
@RequiredArgsConstructor
public class ZdySalesPointController extends BaseController {
private final IZdySalesPointService zdySalesPointService;
/**
* 查询售票点信息列表
*/
@PreAuthorize("@ss.hasPermi('business:salesPoint:list')")
@GetMapping("/list")
public TableDataInfo list(ZdySalesPoint zdySalesPoint) {
startPage();
List<ZdySalesPoint> list = zdySalesPointService.selectZdySalesPointList(zdySalesPoint);
return getDataTable(list);
}
/**
* 导出售票点信息列表
*/
@PreAuthorize("@ss.hasPermi('business:salesPoint:export')")
@Log(title = "售票点信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ZdySalesPoint zdySalesPoint) {
List<ZdySalesPoint> list = zdySalesPointService.selectZdySalesPointList(zdySalesPoint);
ExcelUtil<ZdySalesPoint> util = new ExcelUtil<>(ZdySalesPoint.class);
util.exportExcel(response, list, "售票点信息数据");
}
/**
* 获取售票点信息详细信息
*/
@PreAuthorize("@ss.hasPermi('business:salesPoint:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(zdySalesPointService.selectZdySalesPointById(id));
}
/**
* 新增售票点信息
*/
@PreAuthorize("@ss.hasPermi('business:salesPoint:add')")
@Log(title = "售票点信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ZdySalesPoint zdySalesPoint) {
zdySalesPoint.setDeptId(getDeptId());
zdySalesPoint.setCreatedByUserId(getUserId());
return toAjax(zdySalesPointService.insertZdySalesPoint(zdySalesPoint));
}
/**
* 修改售票点信息
*/
@PreAuthorize("@ss.hasPermi('business:salesPoint:edit')")
@Log(title = "售票点信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ZdySalesPoint zdySalesPoint) {
zdySalesPoint.setUpdatedByUserId(getUserId());
return toAjax(zdySalesPointService.updateZdySalesPoint(zdySalesPoint));
}
/**
* 删除售票点信息
*/
@PreAuthorize("@ss.hasPermi('business:salesPoint:remove')")
@Log(title = "售票点信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(zdySalesPointService.deleteZdySalesPointByIds(ids));
}
/**
* 查询授权自助机设备列表
*/
@PreAuthorize("@ss.hasAnyPermi('business:salesPoint:add,business:salesPoint:edit')")
@GetMapping("/list/auth/ticketMachines")
public AjaxResult listAuthDeviceTicketMachines(ZdySalesPoint zdySalesPoint) {
List<ZdyDeviceTicketMachineVO> voList = zdySalesPointService.listAuthDeviceTicketMachines(zdySalesPoint);
return AjaxResult.success(voList);
}
/**
* 查询授权售票员列表
*/
@PreAuthorize("@ss.hasAnyPermi('business:salesPoint:add,business:salesPoint:edit')")
@GetMapping("/list/auth/users")
public AjaxResult listAuthUsers() {
List<ZdyTicketSellerVO> voList = zdySalesPointService.listAuthUsers(new ZdySalesPoint());
return AjaxResult.success(voList);
}
}

View File

@@ -0,0 +1,90 @@
package com.zhwl.sales.point.domain;
import com.zhwl.common.annotation.Excel;
import com.zhwl.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/**
* 售票点信息对象 zdy_sales_point
*
* @author song_xiaowei
* @date 2024-08-15
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class ZdySalesPoint extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* id
*/
private Long id;
/**
* 售票点名称
*/
@Excel(name = "售票点名称")
private String pointName;
/**
* 销售点类型数据字典sales_point_type
*/
private String salesPointType;
/**
* 销售点类型数据字典sales_point_type
*/
@Excel(name = "销售点类型")
private String salesPointTypeLabel;
/**
* 创建者
*/
@Excel(name = "创建者")
private Long createdByUserId;
/**
* 更新者
*/
@Excel(name = "更新者")
private Long updatedByUserId;
/**
* 部门ID
*/
@Excel(name = "部门ID")
private Long deptId;
/**
* 是否删除
*/
@Excel(name = "是否删除")
private Boolean deleted;
/**
* 关联可售门票id列表
*/
private List<Long> ticketIds;
/**
* 关联售票员id列表
*/
private List<Long> userIds;
/**
* 关联自助机设备id列表
*/
private List<Long> ticketMachineIds;
/**
* 所属景区
*/
private Long scenicId;
/**
* 所属景区名称
*/
private String scenicName;
}

View File

@@ -0,0 +1,32 @@
package com.zhwl.sales.point.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* 售票点可售门票关联对象 zdy_sales_point_ticket
*
* @author song_xiaowei
* @date 2024-08-15
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ZdySalesPointTicket implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 检票点id
*/
private Long salesPointId;
/**
* 门票id
*/
private Long ticketId;
}

View File

@@ -0,0 +1,32 @@
package com.zhwl.sales.point.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* 售票点自助机关联对象 zdy_sales_point_user
*
* @author song_xiaowei
* @date 2024-08-15
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ZdySalesPointTicketMachine implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 检票点id
*/
private Long salesPointId;
/**
* 自助机id
*/
private Long ticketMachineId;
}

View File

@@ -0,0 +1,32 @@
package com.zhwl.sales.point.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* 售票点售票员关联对象 zdy_sales_point_user
*
* @author song_xiaowei
* @date 2024-08-15
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ZdySalesPointUser implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 检票点id
*/
private Long salesPointId;
/**
* 售票员id
*/
private Long userId;
}

View File

@@ -0,0 +1,28 @@
package com.zhwl.sales.point.enums;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
/**
* 销售点类型
* 数据字典sales_point_type
*
* @author song_xiaowei
*/
@Getter
@RequiredArgsConstructor
public enum SalesPointTypeEnum {
/**
* 人工窗口
*/
ARTIFICIAL_WINDOW("1"),
/**
* 自助机
*/
SELF_SERVICE_MACHINE("2");
/**
* 字典值
*/
private final String value;
}

View File

@@ -0,0 +1,63 @@
package com.zhwl.sales.point.mapper;
import com.zhwl.sales.point.domain.ZdySalesPoint;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 售票点信息Mapper接口
*
* @author song_xiaowei
* @date 2024-08-15
*/
@Mapper
public interface ZdySalesPointMapper {
/**
* 查询售票点信息
*
* @param id 售票点信息主键
* @return 售票点信息
*/
ZdySalesPoint selectZdySalesPointById(Long id);
/**
* 查询售票点信息列表
*
* @param zdySalesPoint 售票点信息
* @return 售票点信息集合
*/
List<ZdySalesPoint> selectZdySalesPointList(ZdySalesPoint zdySalesPoint);
/**
* 新增售票点信息
*
* @param zdySalesPoint 售票点信息
* @return 结果
*/
int insertZdySalesPoint(ZdySalesPoint zdySalesPoint);
/**
* 修改售票点信息
*
* @param zdySalesPoint 售票点信息
* @return 结果
*/
int updateZdySalesPoint(ZdySalesPoint zdySalesPoint);
/**
* 删除售票点信息
*
* @param id 售票点信息主键
* @return 结果
*/
int deleteZdySalesPointById(Long id);
/**
* 批量删除售票点信息
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
int deleteZdySalesPointByIds(Long[] ids);
}

View File

@@ -0,0 +1,56 @@
package com.zhwl.sales.point.mapper;
import com.zhwl.sales.point.domain.ZdySalesPointTicketMachine;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 售票点自助机关联Mapper接口
*
* @author song_xiaowei
*/
@Mapper
public interface ZdySalesPointTicketMachineMapper {
/**
* 根据售票点ID查询关联自助机ID列表
*
* @param salesPointId 售票点ID
* @return 自助机ID列表
*/
List<Long> listTicketMachineIdsBySalesPointId(Long salesPointId);
/**
* 新增售票点自助机关联
*
* @param zdySalesPointTicketMachine 售票点自助机关联
* @return 结果
*/
int insertZdySalesPointTicketMachine(ZdySalesPointTicketMachine zdySalesPointTicketMachine);
/**
* 批量删除售票点自助机关联
*
* @param salesPointId 售票点ID
* @param ticketMachineIds 自助机ID列表
*/
void deleteBySalesPointIdAndTicketMachineIds(@Param("salesPointId") Long salesPointId,
@Param("ticketMachineIds") List<Long> ticketMachineIds);
/**
* 根据售票点ID列表删除关联
*
* @param salesPointIds 售票点ID
*/
void deleteBySalesPointIds(Long[] salesPointIds);
/**
* 获取除特定售票点外所有已授权自助机设备的id
*
* @param salesPointId 售票点ID
* @return 自助机ID列表
*/
List<Long> listTicketMachineIdsExcludingSalesPoint(Long salesPointId);
}

View File

@@ -0,0 +1,71 @@
package com.zhwl.sales.point.mapper;
import com.zhwl.sales.point.domain.ZdySalesPointTicket;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 售票点可售门票关联Mapper接口
*
* @author song_xiaowei
*/
@Mapper
public interface ZdySalesPointTicketMapper {
/**
* 根据售票点ID查询可售门票ID
*
* @param salesPointId 售票点ID
* @return 可售门票ID
*/
List<Long> listTicketIdsBySalesPointId(Long salesPointId);
/**
* 新增售票点可售门票关联
*
* @param zdySalesPointTicket 售票点可售门票关联
* @return 结果
*/
int insertZdySalesPointTicket(ZdySalesPointTicket zdySalesPointTicket);
/**
* 删除售票点可售门票关联
*
* @param salesPointId 售票点ID
* @param ticketIds 可售门票ID
*/
void deleteBySalesPointIdAndTicketIds(@Param("salesPointId") Long salesPointId,
@Param("ticketIds") List<Long> ticketIds);
/**
* 根据售票员ID查询可售门票ID
*
* @param userId 售票员ID
* @return 可售门票ID
*/
List<Long> listTicketIdsByUserId(Long userId);
/**
* 根据自助机ID查询可售门票ID
*
* @param ticketMachineId 自助机ID
* @return 可售门票ID
*/
List<Long> listTicketIdsByTicketMachineId(Long ticketMachineId);
/**
* 根据门票ID删除关联
*
* @param ticketId 门票ID
*/
void deleteByTicketId(Long ticketId);
/**
* 根据售票点ID列表删除关联
*
* @param salesPointIds 售票点ID
*/
void deleteBySalesPointIds(Long[] salesPointIds);
}

View File

@@ -0,0 +1,47 @@
package com.zhwl.sales.point.mapper;
import com.zhwl.sales.point.domain.ZdySalesPointUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 售票点售票员关联Mapper接口
*
* @author song_xiaowei
*/
@Mapper
public interface ZdySalesPointUserMapper {
/**
* 根据售票点ID查询售票员ID
*
* @param salesPointId 售票点ID
* @return 售票员ID
*/
List<Long> listUserIdsBySalesPointId(Long salesPointId);
/**
* 新增售票点售票员关联
*
* @param zdySalesPointUser 售票点售票员关联
* @return 结果
*/
int insertZdySalesPointUser(ZdySalesPointUser zdySalesPointUser);
/**
* 根据售票点ID和售票员ID删除售票点售票员关联
*
* @param salesPointId 售票点ID
* @param userIds 售票员ID
*/
void deleteBySalesPointIdAndUserIds(@Param("salesPointId") Long salesPointId, @Param("userIds") List<Long> userIds);
/**
* 根据售票点ID列表删除关联
*
* @param salesPointIds 售票点ID
*/
void deleteBySalesPointIds(Long[] salesPointIds);
}

View File

@@ -0,0 +1,71 @@
package com.zhwl.sales.point.service;
import com.zhwl.sales.point.domain.ZdySalesPoint;
import com.zhwl.sales.point.vo.ZdyDeviceTicketMachineVO;
import com.zhwl.sales.point.vo.ZdyTicketSellerVO;
import java.util.List;
/**
* 售票点信息Service接口
*
* @author song_xiaowei
* @date 2024-08-15
*/
public interface IZdySalesPointService {
/**
* 查询售票点信息
*
* @param id 售票点信息主键
* @return 售票点信息
*/
ZdySalesPoint selectZdySalesPointById(Long id);
/**
* 查询售票点信息列表
*
* @param zdySalesPoint 售票点信息
* @return 售票点信息集合
*/
List<ZdySalesPoint> selectZdySalesPointList(ZdySalesPoint zdySalesPoint);
/**
* 新增售票点信息
*
* @param zdySalesPoint 售票点信息
* @return 结果
*/
int insertZdySalesPoint(ZdySalesPoint zdySalesPoint);
/**
* 修改售票点信息
*
* @param zdySalesPoint 售票点信息
* @return 结果
*/
int updateZdySalesPoint(ZdySalesPoint zdySalesPoint);
/**
* 批量删除售票点信息
*
* @param ids 需要删除的售票点信息主键集合
* @return 结果
*/
int deleteZdySalesPointByIds(Long[] ids);
/**
* 查询授权自助机设备列表
*
* @param zdySalesPoint 售票点信息
* @return 自助机设备列表
*/
List<ZdyDeviceTicketMachineVO> listAuthDeviceTicketMachines(ZdySalesPoint zdySalesPoint);
/**
* 查询关联售票员列表
*
* @param zdySalesPoint 售票点信息
* @return 售票员列表
*/
List<ZdyTicketSellerVO> listAuthUsers(ZdySalesPoint zdySalesPoint);
}

View File

@@ -0,0 +1,419 @@
package com.zhwl.sales.point.service.impl;
import com.zhwl.common.annotation.DataScope;
import com.zhwl.common.core.domain.entity.SysUser;
import com.zhwl.common.enums.DictTypeEnum;
import com.zhwl.common.utils.DateUtils;
import com.zhwl.common.utils.DictUtils;
import com.zhwl.common.utils.MybatisBatchUtils;
import com.zhwl.device.ticket_machine.domain.DeviceTicketMachine;
import com.zhwl.device.ticket_machine.mapper.DeviceTicketMachineMapper;
import com.zhwl.framework.aspectj.DataScopeAspect;
import com.zhwl.sales.point.domain.ZdySalesPoint;
import com.zhwl.sales.point.domain.ZdySalesPointTicket;
import com.zhwl.sales.point.domain.ZdySalesPointTicketMachine;
import com.zhwl.sales.point.domain.ZdySalesPointUser;
import com.zhwl.sales.point.enums.SalesPointTypeEnum;
import com.zhwl.sales.point.mapper.ZdySalesPointMapper;
import com.zhwl.sales.point.mapper.ZdySalesPointTicketMachineMapper;
import com.zhwl.sales.point.mapper.ZdySalesPointTicketMapper;
import com.zhwl.sales.point.mapper.ZdySalesPointUserMapper;
import com.zhwl.sales.point.service.IZdySalesPointService;
import com.zhwl.sales.point.vo.ZdyDeviceTicketMachineVO;
import com.zhwl.sales.point.vo.ZdyTicketSellerVO;
import com.zhwl.system.mapper.SysUserMapper;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
/**
* 售票点信息Service业务层处理
*
* @author song_xiaowei
* @date 2024-08-15
*/
@Service
@RequiredArgsConstructor
public class ZdySalesPointServiceImpl implements IZdySalesPointService {
private final ZdySalesPointMapper zdySalesPointMapper;
private final ZdySalesPointTicketMapper zdySalesPointTicketMapper;
private final ZdySalesPointTicketMachineMapper zdySalesPointTicketMachineMapper;
private final ZdySalesPointUserMapper zdySalesPointUserMapper;
private final MybatisBatchUtils mybatisBatchUtils;
private final DeviceTicketMachineMapper deviceTicketMachineMapper;
private final SysUserMapper sysUserMapper;
/**
* 查询售票点信息
*
* @param id 售票点信息主键
* @return 售票点信息
*/
@Override
public ZdySalesPoint selectZdySalesPointById(Long id) {
ZdySalesPoint zdySalesPoint = zdySalesPointMapper.selectZdySalesPointById(id);
if (Objects.nonNull(zdySalesPoint)) {
List<Long> ticketIds = Optional.ofNullable(zdySalesPointTicketMapper.listTicketIdsBySalesPointId(id))
.orElse(Collections.emptyList());
zdySalesPoint.setTicketIds(ticketIds);
String salesPointType = zdySalesPoint.getSalesPointType();
if (Objects.equals(salesPointType, SalesPointTypeEnum.ARTIFICIAL_WINDOW.getValue())) {
List<Long> userIds = zdySalesPointUserMapper.listUserIdsBySalesPointId(id);
zdySalesPoint.setUserIds(userIds);
} else if (Objects.equals(salesPointType, SalesPointTypeEnum.SELF_SERVICE_MACHINE.getValue())) {
List<Long> ticketMachineIds = this.listTicketMachineIdsBySalesPointId(id);
zdySalesPoint.setTicketMachineIds(ticketMachineIds);
}
}
convertValueToLabel(Collections.singletonList(zdySalesPoint));
return zdySalesPoint;
}
/**
* 查询售票点信息列表
*
* @param zdySalesPoint 售票点信息
* @return 售票点信息
*/
@Override
@DataScope(deptAlias = "zsp")
public List<ZdySalesPoint> selectZdySalesPointList(ZdySalesPoint zdySalesPoint) {
List<ZdySalesPoint> list = Optional.ofNullable(zdySalesPointMapper.selectZdySalesPointList(zdySalesPoint))
.orElse(Collections.emptyList());
convertValueToLabel(list);
return list;
}
/**
* 字典值转换为字典标签
*
* @param list 数据
*/
private void convertValueToLabel(List<ZdySalesPoint> list) {
Map<String, String> salesPointTypeMap = DictUtils.getDictLabelMap(DictTypeEnum.SALES_POINT_TYPE);
list.forEach(data -> data.setSalesPointTypeLabel(salesPointTypeMap.get(data.getSalesPointType())));
}
/**
* 新增售票点信息
*
* @param zdySalesPoint 售票点信息
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int insertZdySalesPoint(ZdySalesPoint zdySalesPoint) {
zdySalesPoint.setCreateTime(DateUtils.getNowDate());
int rows = zdySalesPointMapper.insertZdySalesPoint(zdySalesPoint);
Long id = zdySalesPoint.getId();
batchAddTicketRel(id, zdySalesPoint.getTicketIds());
if (rows > 0) {
String salesPointType = zdySalesPoint.getSalesPointType();
if (Objects.equals(salesPointType, SalesPointTypeEnum.ARTIFICIAL_WINDOW.getValue())) {
batchAddUserRel(id, zdySalesPoint.getUserIds());
} else if (Objects.equals(salesPointType, SalesPointTypeEnum.SELF_SERVICE_MACHINE.getValue())) {
batchAddTicketMachineRel(id, zdySalesPoint.getTicketMachineIds());
}
}
return rows;
}
/**
* 批量新增售票点可售门票关联
*
* @param salesPointId 售票点id
* @param ticketIds 可售门票id列表
*/
private void batchAddTicketRel(Long salesPointId, List<Long> ticketIds) {
if (CollectionUtils.isEmpty(ticketIds)) {
return;
}
List<ZdySalesPointTicket> list = ticketIds.stream()
.map(ticketId -> new ZdySalesPointTicket(salesPointId, ticketId))
.collect(Collectors.toList());
mybatisBatchUtils.batchUpdateOrInsert(list, ZdySalesPointTicketMapper.class,
(data, mapper) -> mapper.insertZdySalesPointTicket(data));
}
/**
* 批量新增售票点自助机关联
*
* @param salesPointId 售票点id
* @param ticketMachineIds 自助机id列表
*/
private void batchAddTicketMachineRel(Long salesPointId, List<Long> ticketMachineIds) {
if (CollectionUtils.isEmpty(ticketMachineIds)) {
return;
}
List<ZdySalesPointTicketMachine> list = ticketMachineIds.stream()
.map(ticketMachineId -> new ZdySalesPointTicketMachine(salesPointId, ticketMachineId))
.collect(Collectors.toList());
mybatisBatchUtils.batchUpdateOrInsert(list, ZdySalesPointTicketMachineMapper.class,
(data, mapper) -> mapper.insertZdySalesPointTicketMachine(data));
}
/**
* 批量新增售票点售票员关联
*
* @param salesPointId 售票点id
* @param userIds 售票员id列表
*/
private void batchAddUserRel(Long salesPointId, List<Long> userIds) {
if (CollectionUtils.isEmpty(userIds)) {
return;
}
List<ZdySalesPointUser> zdySalesPointUserList = userIds.stream()
.map(userId -> new ZdySalesPointUser(salesPointId, userId))
.collect(Collectors.toList());
mybatisBatchUtils.batchUpdateOrInsert(zdySalesPointUserList, ZdySalesPointUserMapper.class,
(data, mapper) -> mapper.insertZdySalesPointUser(data));
}
/**
* 修改售票点信息
*
* @param zdySalesPoint 售票点信息
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int updateZdySalesPoint(ZdySalesPoint zdySalesPoint) {
zdySalesPoint.setUpdateTime(DateUtils.getNowDate());
int row = zdySalesPointMapper.updateZdySalesPoint(zdySalesPoint);
if (row > 0) {
Long id = zdySalesPoint.getId();
batchUpdateTicketRel(id, zdySalesPoint.getTicketIds());
String salesPointType = zdySalesPoint.getSalesPointType();
if (Objects.equals(salesPointType, SalesPointTypeEnum.ARTIFICIAL_WINDOW.getValue())) {
batchUpdateUserRel(id, zdySalesPoint.getUserIds());
} else if (Objects.equals(salesPointType, SalesPointTypeEnum.SELF_SERVICE_MACHINE.getValue())) {
batchUpdateTicketMachineRel(id, zdySalesPoint.getTicketMachineIds());
}
}
return row;
}
/**
* 批量更新售票点可售门票关联
*
* @param salesPointId 售票点id
* @param ticketIds 可售门票id列表
*/
private void batchUpdateTicketRel(Long salesPointId, List<Long> ticketIds) {
List<Long> newList = Optional.ofNullable(ticketIds).orElse(Collections.emptyList());
List<Long> oldList = Optional.ofNullable(zdySalesPointTicketMapper
.listTicketIdsBySalesPointId(salesPointId))
.orElse(Collections.emptyList());
if (newList.isEmpty() && oldList.isEmpty()) {
return;
}
Set<Long> oldSet = new HashSet<>(oldList);
Set<Long> newSet = new HashSet<>(newList);
List<ZdySalesPointTicket> adds = newSet.stream()
.filter(ticketId -> !oldSet.contains(ticketId))
.map(ticketId -> new ZdySalesPointTicket(salesPointId, ticketId))
.collect(Collectors.toList());
if (!adds.isEmpty()) {
mybatisBatchUtils.batchUpdateOrInsert(adds, ZdySalesPointTicketMapper.class,
(data, mapper) -> mapper.insertZdySalesPointTicket(data));
}
List<Long> delete = oldSet.stream().filter(userId -> !newSet.contains(userId))
.collect(Collectors.toList());
if (!delete.isEmpty()) {
zdySalesPointTicketMapper.deleteBySalesPointIdAndTicketIds(salesPointId, delete);
}
}
/**
* 批量更新售票点自助机关联
*
* @param salesPointId 售票点id
* @param ticketMachineIds 自助机id列表
*/
private void batchUpdateTicketMachineRel(Long salesPointId, List<Long> ticketMachineIds) {
List<Long> newList = Optional.ofNullable(ticketMachineIds).orElse(Collections.emptyList());
List<Long> oldList = this.listTicketMachineIdsBySalesPointId(salesPointId);
if (newList.isEmpty() && oldList.isEmpty()) {
return;
}
Set<Long> oldSet = new HashSet<>(oldList);
Set<Long> newSet = new HashSet<>(newList);
List<ZdySalesPointTicketMachine> adds = newSet.stream()
.filter(ticketMachineId -> !oldSet.contains(ticketMachineId))
.map(ticketMachineId -> new ZdySalesPointTicketMachine(salesPointId, ticketMachineId))
.collect(Collectors.toList());
if (!adds.isEmpty()) {
mybatisBatchUtils.batchUpdateOrInsert(adds, ZdySalesPointTicketMachineMapper.class,
(data, mapper) -> mapper.insertZdySalesPointTicketMachine(data));
}
List<Long> delete = oldSet.stream().filter(userId -> !newSet.contains(userId))
.collect(Collectors.toList());
if (!delete.isEmpty()) {
zdySalesPointTicketMachineMapper.deleteBySalesPointIdAndTicketMachineIds(salesPointId, delete);
}
}
/**
* 批量更新售票点售票员关联
*
* @param salesPointId 售票点id
* @param userIds 售票员id列表
*/
private void batchUpdateUserRel(Long salesPointId, List<Long> userIds) {
List<Long> newList = Optional.ofNullable(userIds).orElse(Collections.emptyList());
List<Long> oldList = Optional.ofNullable(zdySalesPointUserMapper.listUserIdsBySalesPointId(salesPointId))
.orElse(Collections.emptyList());
if (newList.isEmpty() && oldList.isEmpty()) {
return;
}
Set<Long> oldSet = new HashSet<>(oldList);
Set<Long> newSet = new HashSet<>(newList);
List<ZdySalesPointUser> adds = newSet.stream()
.filter(userId -> !oldSet.contains(userId))
.map(userId -> new ZdySalesPointUser(salesPointId, userId))
.collect(Collectors.toList());
if (!adds.isEmpty()) {
mybatisBatchUtils.batchUpdateOrInsert(adds, ZdySalesPointUserMapper.class,
(data, mapper) -> mapper.insertZdySalesPointUser(data));
}
List<Long> delete = oldSet.stream().filter(userId -> !newSet.contains(userId))
.collect(Collectors.toList());
if (!delete.isEmpty()) {
zdySalesPointUserMapper.deleteBySalesPointIdAndUserIds(salesPointId, delete);
}
}
/**
* 批量删除售票点信息
*
* @param ids 需要删除的售票点信息主键
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int deleteZdySalesPointByIds(Long[] ids) {
// 删除可售门票关联
zdySalesPointTicketMapper.deleteBySalesPointIds(ids);
// 删除自助机关联
zdySalesPointTicketMachineMapper.deleteBySalesPointIds(ids);
// 删除售票员关联
zdySalesPointUserMapper.deleteBySalesPointIds(ids);
return zdySalesPointMapper.deleteZdySalesPointByIds(ids);
}
@Override
public List<ZdyDeviceTicketMachineVO> listAuthDeviceTicketMachines(ZdySalesPoint zdySalesPoint) {
List<DeviceTicketMachine> deviceTicketMachines = listTicketMachines();
if (deviceTicketMachines.isEmpty()) {
return Collections.emptyList();
}
//已授权设备id列表
List<Long> authDeviceIds = listTicketMachineIdsExcludingSalesPoint(zdySalesPoint.getId());
//转为VO列表
return convertToTicketMachineVOList(deviceTicketMachines, authDeviceIds);
}
@Override
@DataScope(deptAlias = "d")
public List<ZdyTicketSellerVO> listAuthUsers(ZdySalesPoint zdySalesPoint) {
List<SysUser> ticketSellers = listTicketSellers(zdySalesPoint);
if (ticketSellers.isEmpty()) {
return Collections.emptyList();
}
//转为VO列表
return convertToTicketSellerVOList(ticketSellers);
}
/**
* 查询售票点已关联售票员id列表并排除特定售票点
*
* @param salesPointId 售票点id
* @return 售票员id列表
*/
private List<Long> listTicketMachineIdsExcludingSalesPoint(Long salesPointId) {
return Optional
.ofNullable(zdySalesPointTicketMachineMapper.listTicketMachineIdsExcludingSalesPoint(salesPointId))
.orElse(Collections.emptyList());
}
/**
* 转换为售票员VO列表
*
* @param ticketSellers 售票员列表
* @return 售票员VO列表
*/
private List<ZdyTicketSellerVO> convertToTicketSellerVOList(List<SysUser> ticketSellers) {
return ticketSellers.stream()
.map(ticketSeller -> ZdyTicketSellerVO.builder()
.userId(ticketSeller.getUserId())
.nickName(ticketSeller.getNickName())
.build())
.collect(Collectors.toList());
}
/**
* 查询所有售票员
*
* @param zdySalesPoint 售票点信息
* @return 售票员列表
*/
private List<SysUser> listTicketSellers(ZdySalesPoint zdySalesPoint) {
SysUser sysUser = new SysUser();
sysUser.getParams().put(DataScopeAspect.DATA_SCOPE, zdySalesPoint.getParams().get(DataScopeAspect.DATA_SCOPE));
return Optional.ofNullable(sysUserMapper.selectUserList(sysUser))
.orElse(Collections.emptyList());
}
/**
* 查询所有自助机设备
*
* @return 自助机设备列表
*/
private List<DeviceTicketMachine> listTicketMachines() {
return Optional.ofNullable(deviceTicketMachineMapper.selectDeviceTicketMachineList(new DeviceTicketMachine()))
.orElse(Collections.emptyList());
}
/**
* 查询售票点已关联自助机设备id列表
*
* @param salesPointId 售票点id
* @return 自助机设备id列表
*/
private List<Long> listTicketMachineIdsBySalesPointId(Long salesPointId) {
return Optional.ofNullable(zdySalesPointTicketMachineMapper.listTicketMachineIdsBySalesPointId(salesPointId))
.orElse(Collections.emptyList());
}
/**
* 转换为自助机设备VO列表
*
* @param devices 自助机设备列表
* @param authDeviceIds 已授权自助机设备id列表
* @return 自助机设备VO列表
*/
private List<ZdyDeviceTicketMachineVO> convertToTicketMachineVOList(List<DeviceTicketMachine> devices,
List<Long> authDeviceIds) {
// 将 authDeviceIds 转为 Set 以提高查找效率
Set<Long> authDeviceIdSet = new HashSet<>(authDeviceIds);
return devices.stream()
.filter(device -> !authDeviceIdSet.contains(device.getId()))
.map(device -> new ZdyDeviceTicketMachineVO(device.getId(), device.getName()))
.collect(Collectors.toList());
}
}

View File

@@ -0,0 +1,24 @@
package com.zhwl.sales.point.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* 自助机设备信息VO
*
* @author song_xiaowei
*/
@Data
@AllArgsConstructor
public class ZdyDeviceTicketMachineVO {
/**
* id
*/
private Long id;
/**
* 名称
*/
private String name;
}

View File

@@ -0,0 +1,24 @@
package com.zhwl.sales.point.vo;
import lombok.Builder;
import lombok.Data;
/**
* 售票员信息VO
*
* @author song_xiaowei
*/
@Data
@Builder
public class ZdyTicketSellerVO {
/**
* 用户ID
*/
private Long userId;
/**
* 用户昵称
*/
private String nickName;
}

View File

@@ -0,0 +1,158 @@
<?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.zhwl.sales.point.mapper.ZdySalesPointMapper">
<resultMap type="ZdySalesPoint" id="ZdySalesPointResult">
<result property="id" column="id"/>
<result property="pointName" column="point_name"/>
<result property="salesPointType" column="sales_point_type"/>
<result property="createTime" column="create_time"/>
<result property="createdByUserId" column="created_by_user_id"/>
<result property="updateTime" column="update_time"/>
<result property="updatedByUserId" column="updated_by_user_id"/>
<result property="deptId" column="dept_id"/>
<result property="deleted" column="is_deleted"/>
<result property="scenicId" column="scenic_id"/>
<result property="scenicName" column="scenic_name"/>
</resultMap>
<sql id="selectZdySalesPointVo">
select zsp.id,
zsp.point_name,
zsp.sales_point_type,
zsp.create_time,
zsp.created_by_user_id,
zsp.update_time,
zsp.updated_by_user_id,
zsp.dept_id,
zsp.is_deleted,
zsp.scenic_id,
zs.scenic_name
from zdy_sales_point zsp
left join zdy_scenic zs on zs.id = zsp.scenic_id
</sql>
<select id="selectZdySalesPointList" parameterType="ZdySalesPoint" resultMap="ZdySalesPointResult">
<include refid="selectZdySalesPointVo"/>
<where>
zsp.is_deleted = 0
<if test="pointName != null and pointName != ''">
and zsp.point_name like concat('%', #{pointName}, '%')
</if>
<if test="salesPointType != null and salesPointType != ''">
and zsp.sales_point_type = #{salesPointType}
</if>
<if test="createdByUserId != null ">
and zsp.created_by_user_id = #{createdByUserId}
</if>
<if test="updatedByUserId != null ">
and zsp.updated_by_user_id = #{updatedByUserId}
</if>
<if test="deptId != null ">
and zsp.dept_id = #{deptId}
</if>
${params.dataScope}
</where>
</select>
<select id="selectZdySalesPointById" parameterType="Long"
resultMap="ZdySalesPointResult">
<include refid="selectZdySalesPointVo"/>
where zsp.id = #{id}
</select>
<insert id="insertZdySalesPoint" parameterType="ZdySalesPoint" useGeneratedKeys="true"
keyProperty="id">
insert into zdy_sales_point
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="pointName != null and pointName != ''">point_name,
</if>
<if test="salesPointType != null and salesPointType != ''">sales_point_type,
</if>
<if test="createTime != null">create_time,
</if>
<if test="createdByUserId != null">created_by_user_id,
</if>
<if test="updateTime != null">update_time,
</if>
<if test="updatedByUserId != null">updated_by_user_id,
</if>
<if test="deptId != null">dept_id,
</if>
<if test="deleted != null">is_deleted,
</if>
<if test="scenicId != null">scenic_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="pointName != null and pointName != ''">#{pointName},
</if>
<if test="salesPointType != null and salesPointType != ''">#{salesPointType},
</if>
<if test="createTime != null">#{createTime},
</if>
<if test="createdByUserId != null">#{createdByUserId},
</if>
<if test="updateTime != null">#{updateTime},
</if>
<if test="updatedByUserId != null">#{updatedByUserId},
</if>
<if test="deptId != null">#{deptId},
</if>
<if test="deleted != null">#{deleted},
</if>
<if test="scenicId != null">#{scenicId},
</if>
</trim>
</insert>
<update id="updateZdySalesPoint" parameterType="ZdySalesPoint">
update zdy_sales_point
<trim prefix="SET" suffixOverrides=",">
<if test="pointName != null and pointName != ''">point_name =
#{pointName},
</if>
<if test="salesPointType != null and salesPointType != ''">sales_point_type =
#{salesPointType},
</if>
<if test="createTime != null">create_time =
#{createTime},
</if>
<if test="createdByUserId != null">created_by_user_id =
#{createdByUserId},
</if>
<if test="updateTime != null">update_time =
#{updateTime},
</if>
<if test="updatedByUserId != null">updated_by_user_id =
#{updatedByUserId},
</if>
<if test="deptId != null">dept_id =
#{deptId},
</if>
<if test="deleted != null">is_deleted =
#{deleted},
</if>
<if test="scenicId != null">scenic_id =
#{scenicId},
</if>
</trim>
where id = #{id}
</update>
<update id="deleteZdySalesPointById" parameterType="Long">
update zdy_sales_point
set is_deleted = 1
where id = #{id}
</update>
<update id="deleteZdySalesPointByIds" parameterType="String">
update zdy_sales_point set is_deleted = 1 where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
</mapper>

View File

@@ -0,0 +1,63 @@
<?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.zhwl.sales.point.mapper.ZdySalesPointTicketMachineMapper">
<resultMap type="ZdySalesPointTicketMachine" id="ZdySalesPointTicketMachineResult">
<result property="salesPointId" column="sales_point_id"/>
<result property="ticketMachineId" column="ticket_machine_id"/>
</resultMap>
<sql id="selectZdySalesPointTicketMachineVo">
select sales_point_id, ticket_machine_id
from zdy_sales_point_ticket_machine
</sql>
<select id="listTicketMachineIdsBySalesPointId" parameterType="Long" resultType="Long">
select ticket_machine_id
from zdy_sales_point_ticket_machine
where sales_point_id = #{salesPointId}
</select>
<insert id="insertZdySalesPointTicketMachine" parameterType="ZdySalesPointTicketMachine">
insert into zdy_sales_point_ticket_machine
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="salesPointId != null">sales_point_id,
</if>
<if test="ticketMachineId != null">ticket_machine_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="salesPointId != null">#{salesPointId},
</if>
<if test="ticketMachineId != null">#{ticketMachineId},
</if>
</trim>
</insert>
<delete id="deleteBySalesPointIdAndTicketMachineIds">
delete from zdy_sales_point_ticket_machine where sales_point_id = #{salesPointId} and ticket_machine_id in
<foreach item="ticketMachineId" collection="ticketMachineIds" open="(" separator="," close=")">
#{ticketMachineId}
</foreach>
</delete>
<delete id="deleteBySalesPointIds">
delete from zdy_sales_point_ticket_machine
where
sales_point_id in
<foreach item="salesPointId" collection="array" open="(" separator="," close=")">
#{salesPointId}
</foreach>
</delete>
<select id="listTicketMachineIdsExcludingSalesPoint" parameterType="Long" resultType="Long">
select ticket_machine_id
from zdy_sales_point_ticket_machine
<where>
<if test="salesPointId != null">sales_point_id != #{salesPointId}</if>
</where>
</select>
</mapper>

View File

@@ -0,0 +1,77 @@
<?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.zhwl.sales.point.mapper.ZdySalesPointTicketMapper">
<resultMap type="ZdySalesPointTicket" id="ZdySalesPointTicketResult">
<result property="salesPointId" column="sales_point_id"/>
<result property="ticketId" column="ticket_id"/>
</resultMap>
<sql id="selectZdySalesPointTicketVo">
select sales_point_id, ticket_id
from zdy_sales_point_ticket
</sql>
<select id="listTicketIdsBySalesPointId" parameterType="Long" resultType="Long">
select ticket_id
from zdy_sales_point_ticket
where sales_point_id = #{salesPointId}
</select>
<insert id="insertZdySalesPointTicket" parameterType="ZdySalesPointTicket">
insert into zdy_sales_point_ticket
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="salesPointId != null">sales_point_id,
</if>
<if test="ticketId != null">ticket_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="salesPointId != null">#{salesPointId},
</if>
<if test="ticketId != null">#{ticketId},
</if>
</trim>
</insert>
<delete id="deleteByTicketId" parameterType="Long">
delete
from zdy_sales_point_ticket
where ticket_id = #{ticketId}
</delete>
<delete id="deleteBySalesPointIdAndTicketIds">
delete from zdy_sales_point_ticket where sales_point_id = #{salesPointId} and ticket_id in
<foreach item="ticketId" collection="ticketIds" open="(" separator="," close=")">
#{ticketId}
</foreach>
</delete>
<select id="listTicketIdsByUserId" resultType="java.lang.Long">
SELECT DISTINCT ticket_id
FROM zdy_sales_point_ticket
WHERE sales_point_id IN (SELECT sales_point_id
FROM zdy_sales_point_user
WHERE user_id = #{userId})
</select>
<select id="listTicketIdsByTicketMachineId" resultType="java.lang.Long">
SELECT DISTINCT ticket_id
FROM zdy_sales_point_ticket
WHERE sales_point_id IN (SELECT sales_point_id
FROM zdy_sales_point_ticket_machine
WHERE ticket_machine_id = #{ticketMachineId})
</select>
<delete id="deleteBySalesPointIds">
delete from zdy_sales_point_ticket
where
sales_point_id in
<foreach item="salesPointId" collection="array" open="(" separator="," close=")">
#{salesPointId}
</foreach>
</delete>
</mapper>

View File

@@ -0,0 +1,55 @@
<?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.zhwl.sales.point.mapper.ZdySalesPointUserMapper">
<resultMap type="ZdySalesPointUser" id="ZdySalesPointUserResult">
<result property="salesPointId" column="sales_point_id"/>
<result property="userId" column="user_id"/>
</resultMap>
<sql id="selectZdySalesPointUserVo">
select sales_point_id, user_id
from zdy_sales_point_user
</sql>
<select id="listUserIdsBySalesPointId" parameterType="Long" resultType="Long">
select user_id
from zdy_sales_point_user
where sales_point_id = #{salesPointId}
</select>
<insert id="insertZdySalesPointUser" parameterType="ZdySalesPointUser">
insert into zdy_sales_point_user
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="salesPointId != null">sales_point_id,
</if>
<if test="userId != null">user_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="salesPointId != null">#{salesPointId},
</if>
<if test="userId != null">#{userId},
</if>
</trim>
</insert>
<delete id="deleteBySalesPointIdAndUserIds">
delete from zdy_sales_point_user where sales_point_id = #{salesPointId} and user_id in
<foreach item="userId" collection="userIds" open="(" separator="," close=")">
#{userId}
</foreach>
</delete>
<delete id="deleteBySalesPointIds">
delete from zdy_sales_point_user
where
sales_point_id in
<foreach item="salesPointId" collection="array" open="(" separator="," close=")">
#{salesPointId}
</foreach>
</delete>
</mapper>

View File

@@ -0,0 +1,158 @@
<?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.zhwl.sales.point.mapper.ZdySalesPointMapper">
<resultMap type="ZdySalesPoint" id="ZdySalesPointResult">
<result property="id" column="id"/>
<result property="pointName" column="point_name"/>
<result property="salesPointType" column="sales_point_type"/>
<result property="createTime" column="create_time"/>
<result property="createdByUserId" column="created_by_user_id"/>
<result property="updateTime" column="update_time"/>
<result property="updatedByUserId" column="updated_by_user_id"/>
<result property="deptId" column="dept_id"/>
<result property="deleted" column="is_deleted"/>
<result property="scenicId" column="scenic_id"/>
<result property="scenicName" column="scenic_name"/>
</resultMap>
<sql id="selectZdySalesPointVo">
select zsp.id,
zsp.point_name,
zsp.sales_point_type,
zsp.create_time,
zsp.created_by_user_id,
zsp.update_time,
zsp.updated_by_user_id,
zsp.dept_id,
zsp.is_deleted,
zsp.scenic_id,
zs.scenic_name
from zdy_sales_point zsp
left join zdy_scenic zs on zs.id = zsp.scenic_id
</sql>
<select id="selectZdySalesPointList" parameterType="ZdySalesPoint" resultMap="ZdySalesPointResult">
<include refid="selectZdySalesPointVo"/>
<where>
zsp.is_deleted = 0
<if test="pointName != null and pointName != ''">
and zsp.point_name like concat('%', #{pointName}, '%')
</if>
<if test="salesPointType != null and salesPointType != ''">
and zsp.sales_point_type = #{salesPointType}
</if>
<if test="createdByUserId != null ">
and zsp.created_by_user_id = #{createdByUserId}
</if>
<if test="updatedByUserId != null ">
and zsp.updated_by_user_id = #{updatedByUserId}
</if>
<if test="deptId != null ">
and zsp.dept_id = #{deptId}
</if>
${params.dataScope}
</where>
</select>
<select id="selectZdySalesPointById" parameterType="Long"
resultMap="ZdySalesPointResult">
<include refid="selectZdySalesPointVo"/>
where zsp.id = #{id}
</select>
<insert id="insertZdySalesPoint" parameterType="ZdySalesPoint" useGeneratedKeys="true"
keyProperty="id">
insert into zdy_sales_point
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="pointName != null and pointName != ''">point_name,
</if>
<if test="salesPointType != null and salesPointType != ''">sales_point_type,
</if>
<if test="createTime != null">create_time,
</if>
<if test="createdByUserId != null">created_by_user_id,
</if>
<if test="updateTime != null">update_time,
</if>
<if test="updatedByUserId != null">updated_by_user_id,
</if>
<if test="deptId != null">dept_id,
</if>
<if test="deleted != null">is_deleted,
</if>
<if test="scenicId != null">scenic_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="pointName != null and pointName != ''">#{pointName},
</if>
<if test="salesPointType != null and salesPointType != ''">#{salesPointType},
</if>
<if test="createTime != null">#{createTime},
</if>
<if test="createdByUserId != null">#{createdByUserId},
</if>
<if test="updateTime != null">#{updateTime},
</if>
<if test="updatedByUserId != null">#{updatedByUserId},
</if>
<if test="deptId != null">#{deptId},
</if>
<if test="deleted != null">#{deleted},
</if>
<if test="scenicId != null">#{scenicId},
</if>
</trim>
</insert>
<update id="updateZdySalesPoint" parameterType="ZdySalesPoint">
update zdy_sales_point
<trim prefix="SET" suffixOverrides=",">
<if test="pointName != null and pointName != ''">point_name =
#{pointName},
</if>
<if test="salesPointType != null and salesPointType != ''">sales_point_type =
#{salesPointType},
</if>
<if test="createTime != null">create_time =
#{createTime},
</if>
<if test="createdByUserId != null">created_by_user_id =
#{createdByUserId},
</if>
<if test="updateTime != null">update_time =
#{updateTime},
</if>
<if test="updatedByUserId != null">updated_by_user_id =
#{updatedByUserId},
</if>
<if test="deptId != null">dept_id =
#{deptId},
</if>
<if test="deleted != null">is_deleted =
#{deleted},
</if>
<if test="scenicId != null">scenic_id =
#{scenicId},
</if>
</trim>
where id = #{id}
</update>
<update id="deleteZdySalesPointById" parameterType="Long">
update zdy_sales_point
set is_deleted = 1
where id = #{id}
</update>
<update id="deleteZdySalesPointByIds" parameterType="String">
update zdy_sales_point set is_deleted = 1 where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
</mapper>

View File

@@ -0,0 +1,63 @@
<?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.zhwl.sales.point.mapper.ZdySalesPointTicketMachineMapper">
<resultMap type="ZdySalesPointTicketMachine" id="ZdySalesPointTicketMachineResult">
<result property="salesPointId" column="sales_point_id"/>
<result property="ticketMachineId" column="ticket_machine_id"/>
</resultMap>
<sql id="selectZdySalesPointTicketMachineVo">
select sales_point_id, ticket_machine_id
from zdy_sales_point_ticket_machine
</sql>
<select id="listTicketMachineIdsBySalesPointId" parameterType="Long" resultType="Long">
select ticket_machine_id
from zdy_sales_point_ticket_machine
where sales_point_id = #{salesPointId}
</select>
<insert id="insertZdySalesPointTicketMachine" parameterType="ZdySalesPointTicketMachine">
insert into zdy_sales_point_ticket_machine
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="salesPointId != null">sales_point_id,
</if>
<if test="ticketMachineId != null">ticket_machine_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="salesPointId != null">#{salesPointId},
</if>
<if test="ticketMachineId != null">#{ticketMachineId},
</if>
</trim>
</insert>
<delete id="deleteBySalesPointIdAndTicketMachineIds">
delete from zdy_sales_point_ticket_machine where sales_point_id = #{salesPointId} and ticket_machine_id in
<foreach item="ticketMachineId" collection="ticketMachineIds" open="(" separator="," close=")">
#{ticketMachineId}
</foreach>
</delete>
<delete id="deleteBySalesPointIds">
delete from zdy_sales_point_ticket_machine
where
sales_point_id in
<foreach item="salesPointId" collection="array" open="(" separator="," close=")">
#{salesPointId}
</foreach>
</delete>
<select id="listTicketMachineIdsExcludingSalesPoint" parameterType="Long" resultType="Long">
select ticket_machine_id
from zdy_sales_point_ticket_machine
<where>
<if test="salesPointId != null">sales_point_id != #{salesPointId}</if>
</where>
</select>
</mapper>

View File

@@ -0,0 +1,77 @@
<?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.zhwl.sales.point.mapper.ZdySalesPointTicketMapper">
<resultMap type="ZdySalesPointTicket" id="ZdySalesPointTicketResult">
<result property="salesPointId" column="sales_point_id"/>
<result property="ticketId" column="ticket_id"/>
</resultMap>
<sql id="selectZdySalesPointTicketVo">
select sales_point_id, ticket_id
from zdy_sales_point_ticket
</sql>
<select id="listTicketIdsBySalesPointId" parameterType="Long" resultType="Long">
select ticket_id
from zdy_sales_point_ticket
where sales_point_id = #{salesPointId}
</select>
<insert id="insertZdySalesPointTicket" parameterType="ZdySalesPointTicket">
insert into zdy_sales_point_ticket
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="salesPointId != null">sales_point_id,
</if>
<if test="ticketId != null">ticket_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="salesPointId != null">#{salesPointId},
</if>
<if test="ticketId != null">#{ticketId},
</if>
</trim>
</insert>
<delete id="deleteByTicketId" parameterType="Long">
delete
from zdy_sales_point_ticket
where ticket_id = #{ticketId}
</delete>
<delete id="deleteBySalesPointIdAndTicketIds">
delete from zdy_sales_point_ticket where sales_point_id = #{salesPointId} and ticket_id in
<foreach item="ticketId" collection="ticketIds" open="(" separator="," close=")">
#{ticketId}
</foreach>
</delete>
<select id="listTicketIdsByUserId" resultType="java.lang.Long">
SELECT DISTINCT ticket_id
FROM zdy_sales_point_ticket
WHERE sales_point_id IN (SELECT sales_point_id
FROM zdy_sales_point_user
WHERE user_id = #{userId})
</select>
<select id="listTicketIdsByTicketMachineId" resultType="java.lang.Long">
SELECT DISTINCT ticket_id
FROM zdy_sales_point_ticket
WHERE sales_point_id IN (SELECT sales_point_id
FROM zdy_sales_point_ticket_machine
WHERE ticket_machine_id = #{ticketMachineId})
</select>
<delete id="deleteBySalesPointIds">
delete from zdy_sales_point_ticket
where
sales_point_id in
<foreach item="salesPointId" collection="array" open="(" separator="," close=")">
#{salesPointId}
</foreach>
</delete>
</mapper>

View File

@@ -0,0 +1,55 @@
<?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.zhwl.sales.point.mapper.ZdySalesPointUserMapper">
<resultMap type="ZdySalesPointUser" id="ZdySalesPointUserResult">
<result property="salesPointId" column="sales_point_id"/>
<result property="userId" column="user_id"/>
</resultMap>
<sql id="selectZdySalesPointUserVo">
select sales_point_id, user_id
from zdy_sales_point_user
</sql>
<select id="listUserIdsBySalesPointId" parameterType="Long" resultType="Long">
select user_id
from zdy_sales_point_user
where sales_point_id = #{salesPointId}
</select>
<insert id="insertZdySalesPointUser" parameterType="ZdySalesPointUser">
insert into zdy_sales_point_user
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="salesPointId != null">sales_point_id,
</if>
<if test="userId != null">user_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="salesPointId != null">#{salesPointId},
</if>
<if test="userId != null">#{userId},
</if>
</trim>
</insert>
<delete id="deleteBySalesPointIdAndUserIds">
delete from zdy_sales_point_user where sales_point_id = #{salesPointId} and user_id in
<foreach item="userId" collection="userIds" open="(" separator="," close=")">
#{userId}
</foreach>
</delete>
<delete id="deleteBySalesPointIds">
delete from zdy_sales_point_user
where
sales_point_id in
<foreach item="salesPointId" collection="array" open="(" separator="," close=")">
#{salesPointId}
</foreach>
</delete>
</mapper>