Commit 8406a1d0 by 吕明尚

Merge branch 'dev' into test

parents e79fa81a 558ce6db
package share.web.controller.system;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import share.common.annotation.Log;
import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.core.page.TableDataInfo;
import share.common.enums.BusinessType;
import share.common.utils.poi.ExcelUtil;
import share.system.domain.PointActivityLog;
import share.system.domain.vo.PointActivityLogVo;
import share.system.service.PointActivityLogService;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 集点活动日志Controller
*
* @author wuwenlong
* @date 2024-11-21
*/
@RestController
@RequestMapping("/system/pointActivityLog")
public class PointActivityLogController extends BaseController {
@Autowired
private PointActivityLogService pointActivityLogService;
/**
* 查询集点活动日志列表
*/
@PreAuthorize("@ss.hasPermi('system:pointActivityLog:list')")
@GetMapping("/list")
public TableDataInfo list(PointActivityLogVo pointActivityLog) {
startPage();
List<PointActivityLogVo> list = pointActivityLogService.selectPointActivityLogList(pointActivityLog);
return getDataTable(list);
}
/**
* 导出集点活动日志列表
*/
@PreAuthorize("@ss.hasPermi('system:pointActivityLog:export')")
@Log(title = "集点活动日志", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, PointActivityLogVo pointActivityLog) {
List<PointActivityLogVo> list = pointActivityLogService.selectPointActivityLogList(pointActivityLog);
ExcelUtil<PointActivityLogVo> util = new ExcelUtil<PointActivityLogVo>(PointActivityLogVo.class);
util.exportExcel(response, list, "集点活动日志数据");
}
/**
* 获取集点活动日志详细信息
*/
@PreAuthorize("@ss.hasPermi('system:pointActivityLog:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(pointActivityLogService.selectPointActivityLogById(id));
}
/**
* 新增集点活动日志
*/
@PreAuthorize("@ss.hasPermi('system:pointActivityLog:add')")
@Log(title = "集点活动日志", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody PointActivityLog pointActivityLog) {
return toAjax(pointActivityLogService.insertPointActivityLog(pointActivityLog));
}
/**
* 修改集点活动日志
*/
@PreAuthorize("@ss.hasPermi('system:pointActivityLog:edit')")
@Log(title = "集点活动日志", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody PointActivityLog pointActivityLog) {
return toAjax(pointActivityLogService.updatePointActivityLog(pointActivityLog));
}
/**
* 删除集点活动日志
*/
@PreAuthorize("@ss.hasPermi('system:pointActivityLog:remove')")
@Log(title = "集点活动日志", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(pointActivityLogService.deletePointActivityLogByIds(ids));
}
}
package share.system.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
......@@ -26,6 +24,7 @@ public class PointActivities extends BaseEntity {
/**
* 主键
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
......
package share.system.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
......@@ -23,6 +21,7 @@ public class PointActivitiesConf extends BaseEntity {
/**
* 主键
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
......
package share.system.domain;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import share.common.annotation.Excel;
import share.common.core.domain.BaseEntity;
import java.util.Date;
/**
* 集点活动日志对象 s_point_activity_log
*
* @author wuwenlong
* @date 2024-11-21
*/
@Data
@TableName("s_point_activity_log")
public class PointActivityLog extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 用户ID
*/
@Excel(name = "用户ID")
private Long consumerId;
/**
* 集点活动id
*/
@Excel(name = "集点活动id")
private Long pointActivityId;
/**
* 订单编号
*/
@Excel(name = "订单编号")
private String orderNo;
/**
* 点数
*/
@Excel(name = "点数")
private Integer points;
/**
* 消费时间
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "消费时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date consumptionTime;
/**
* 是否删除(0:否,1:是)
*/
//逻辑删除注解(0 未删除 1 已删除)
@TableLogic
@TableField(select = false)
private Long isDelete;
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("consumerId", getConsumerId())
.append("pointActivityId", getPointActivityId())
.append("orderNo", getOrderNo())
.append("points", getPoints())
.append("consumptionTime", getConsumptionTime())
.append("isDelete", getIsDelete())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
}
package share.system.domain.vo;
import lombok.Data;
import share.system.domain.PointActivityLog;
@Data
public class PointActivityLogVo extends PointActivityLog {
private String nickName;
private String avatar;
private String phone;
}
package share.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import share.system.domain.PointActivityLog;
import share.system.domain.vo.PointActivityLogVo;
import java.util.List;
/**
* 集点活动日志Mapper接口
*
* @author wuwenlong
* @date 2024-11-21
*/
public interface PointActivityLogMapper extends BaseMapper<PointActivityLog> {
/**
* 查询集点活动日志
*
* @param id 集点活动日志主键
* @return 集点活动日志
*/
public PointActivityLog selectPointActivityLogById(Long id);
/**
* 查询集点活动日志列表
*
* @param pointActivityLog 集点活动日志
* @return 集点活动日志集合
*/
public List<PointActivityLogVo> selectPointActivityLogList(PointActivityLogVo pointActivityLog);
/**
* 新增集点活动日志
*
* @param pointActivityLog 集点活动日志
* @return 结果
*/
public int insertPointActivityLog(PointActivityLog pointActivityLog);
/**
* 修改集点活动日志
*
* @param pointActivityLog 集点活动日志
* @return 结果
*/
public int updatePointActivityLog(PointActivityLog pointActivityLog);
/**
* 删除集点活动日志
*
* @param id 集点活动日志主键
* @return 结果
*/
public int deletePointActivityLogById(Long id);
/**
* 批量删除集点活动日志
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deletePointActivityLogByIds(Long[] ids);
}
package share.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.PointActivityLog;
import share.system.domain.vo.PointActivityLogVo;
import java.util.List;
/**
* 集点活动日志Service接口
*
* @author wuwenlong
* @date 2024-11-21
*/
public interface PointActivityLogService extends IService<PointActivityLog> {
/**
* 查询集点活动日志
*
* @param id 集点活动日志主键
* @return 集点活动日志
*/
public PointActivityLog selectPointActivityLogById(Long id);
/**
* 查询集点活动日志列表
*
* @param pointActivityLog 集点活动日志
* @return 集点活动日志集合
*/
public List<PointActivityLogVo> selectPointActivityLogList(PointActivityLogVo pointActivityLog);
/**
* 新增集点活动日志
*
* @param pointActivityLog 集点活动日志
* @return 结果
*/
public int insertPointActivityLog(PointActivityLog pointActivityLog);
/**
* 修改集点活动日志
*
* @param pointActivityLog 集点活动日志
* @return 结果
*/
public int updatePointActivityLog(PointActivityLog pointActivityLog);
/**
* 批量删除集点活动日志
*
* @param ids 需要删除的集点活动日志主键集合
* @return 结果
*/
public int deletePointActivityLogByIds(Long[] ids);
/**
* 删除集点活动日志信息
*
* @param id 集点活动日志主键
* @return 结果
*/
public int deletePointActivityLogById(Long id);
}
......@@ -77,6 +77,11 @@ public class PackServiceImpl extends ServiceImpl<PackMapper, SPack> implements I
@Override
public int insertPack(SPack sPack) {
sPack.setCreateTime(DateUtils.getNowDate());
if (sPack.getType().equals(YesNoEnum.yes.getIndex())) {
if ((Integer.parseInt(sPack.getPackaEndPeriod()) - Integer.parseInt(sPack.getPackaStartPeriod())) != Integer.parseInt(sPack.getDuration())) {
throw new BaseException("套餐时长和使用时长不匹配!");
}
}
return baseMapper.insertPack(sPack);
}
......@@ -89,6 +94,11 @@ public class PackServiceImpl extends ServiceImpl<PackMapper, SPack> implements I
@Override
public int updatePack(SPack SPack) {
SPack.setUpdateTime(DateUtils.getNowDate());
if (SPack.getType().equals(YesNoEnum.yes.getIndex())) {
if ((Integer.parseInt(SPack.getPackaEndPeriod()) - Integer.parseInt(SPack.getPackaStartPeriod())) != Integer.parseInt(SPack.getDuration())) {
throw new BaseException("套餐时长和使用时长不匹配!");
}
}
return baseMapper.updatePack(SPack);
}
......
......@@ -8,16 +8,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.common.enums.YesNoEnum;
import share.common.utils.DateUtils;
import share.system.domain.PointActivities;
import share.system.domain.PointActivitiesConf;
import share.system.domain.SConsumer;
import share.system.domain.SOrder;
import share.system.domain.*;
import share.system.domain.vo.PointActivitiesVo;
import share.system.mapper.PointActivitiesMapper;
import share.system.service.ISConsumerCouponService;
import share.system.service.PointActivitiesConfService;
import share.system.service.PointActivitiesService;
import share.system.service.SConsumerService;
import share.system.service.*;
import java.time.LocalDate;
import java.util.Comparator;
......@@ -40,6 +34,8 @@ public class PointActivitiesServiceImpl extends ServiceImpl<PointActivitiesMappe
private PointActivitiesConfService pointActivitiesConfService;
@Autowired
private ISConsumerCouponService sConsumerCouponService;
@Autowired
private PointActivityLogService pointActivityLogService;
/**
* 查询用户集点活动
......@@ -107,6 +103,14 @@ public class PointActivitiesServiceImpl extends ServiceImpl<PointActivitiesMappe
oldPointActivities.setIsReceive(YesNoEnum.yes.getIndex());
}
updateById(oldPointActivities);
PointActivityLog pointActivityLog = new PointActivityLog();
pointActivityLog.setConsumerId(user.getId());
pointActivityLog.setPointActivityId(oldPointActivities.getId());
pointActivityLog.setOrderNo(sOrder.getOrderNo());
pointActivityLog.setPoints(oldPointActivities.getPoints() + YesNoEnum.yes.getIndex());
pointActivityLog.setConsumptionTime(sOrder.getPayTime());
pointActivityLog.setCreateTime(new Date());
pointActivityLogService.save(pointActivityLog);
}
} else {
oldPointActivities.setPoints(oldPointActivities.getPoints() + YesNoEnum.yes.getIndex());
......@@ -130,6 +134,14 @@ public class PointActivitiesServiceImpl extends ServiceImpl<PointActivitiesMappe
pointActivities.setCurrentYear(LocalDate.now().getYear());
pointActivities.setCurrentMonth(LocalDate.now().getMonthValue());
save(pointActivities);
PointActivityLog pointActivityLog = new PointActivityLog();
pointActivityLog.setConsumerId(user.getId());
pointActivityLog.setPointActivityId(pointActivities.getId());
pointActivityLog.setOrderNo(sOrder.getOrderNo());
pointActivityLog.setPoints(YesNoEnum.yes.getIndex());
pointActivityLog.setConsumptionTime(sOrder.getPayTime());
pointActivityLog.setCreateTime(new Date());
pointActivityLogService.save(pointActivityLog);
}
}
......
package share.system.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.common.utils.DateUtils;
import share.system.domain.PointActivityLog;
import share.system.domain.vo.PointActivityLogVo;
import share.system.mapper.PointActivityLogMapper;
import share.system.service.PointActivityLogService;
import java.util.List;
/**
* 集点活动日志Service业务层处理
*
* @author wuwenlong
* @date 2024-11-21
*/
@Service
public class PointActivityLogServiceImpl extends ServiceImpl<PointActivityLogMapper, PointActivityLog> implements PointActivityLogService {
@Autowired
private PointActivityLogMapper pointActivityLogMapper;
/**
* 查询集点活动日志
*
* @param id 集点活动日志主键
* @return 集点活动日志
*/
@Override
public PointActivityLog selectPointActivityLogById(Long id) {
return pointActivityLogMapper.selectPointActivityLogById(id);
}
/**
* 查询集点活动日志列表
*
* @param pointActivityLog 集点活动日志
* @return 集点活动日志
*/
@Override
public List<PointActivityLogVo> selectPointActivityLogList(PointActivityLogVo pointActivityLog) {
return pointActivityLogMapper.selectPointActivityLogList(pointActivityLog);
}
/**
* 新增集点活动日志
*
* @param pointActivityLog 集点活动日志
* @return 结果
*/
@Override
public int insertPointActivityLog(PointActivityLog pointActivityLog) {
pointActivityLog.setCreateTime(DateUtils.getNowDate());
return pointActivityLogMapper.insertPointActivityLog(pointActivityLog);
}
/**
* 修改集点活动日志
*
* @param pointActivityLog 集点活动日志
* @return 结果
*/
@Override
public int updatePointActivityLog(PointActivityLog pointActivityLog) {
pointActivityLog.setUpdateTime(DateUtils.getNowDate());
return pointActivityLogMapper.updatePointActivityLog(pointActivityLog);
}
/**
* 批量删除集点活动日志
*
* @param ids 需要删除的集点活动日志主键
* @return 结果
*/
@Override
public int deletePointActivityLogByIds(Long[] ids) {
return pointActivityLogMapper.deletePointActivityLogByIds(ids);
}
/**
* 删除集点活动日志信息
*
* @param id 集点活动日志主键
* @return 结果
*/
@Override
public int deletePointActivityLogById(Long id) {
return pointActivityLogMapper.deletePointActivityLogById(id);
}
}
<?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="share.system.mapper.PointActivityLogMapper">
<resultMap type="PointActivityLog" id="PointActivityLogResult">
<result property="id" column="id"/>
<result property="consumerId" column="consumer_id"/>
<result property="pointActivityId" column="point_activity_id"/>
<result property="orderNo" column="order_no"/>
<result property="points" column="points"/>
<result property="consumptionTime" column="consumption_time"/>
<result property="isDelete" column="is_delete"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
</resultMap>
<sql id="selectPointActivityLogVo">
select id,
consumer_id,
point_activity_id,
order_no,
points,
consumption_time,
is_delete,
create_by,
create_time,
update_by,
update_time,
remark
from s_point_activity_log
</sql>
<select id="selectPointActivityLogList" parameterType="PointActivityLogVo" resultMap="PointActivityLogResult">
<include refid="selectPointActivityLogVo"/>
<where>
<if test="consumerId != null ">and consumer_id = #{consumerId}</if>
<if test="pointActivityId != null ">and point_activity_id = #{pointActivityId}</if>
<if test="orderNo != null and orderNo != ''">and order_no = #{orderNo}</if>
<if test="points != null ">and points = #{points}</if>
<if test="consumptionTime != null ">and consumption_time = #{consumptionTime}</if>
<if test="isDelete != null ">and is_delete = #{isDelete}</if>
</where>
</select>
<select id="selectPointActivityLogById" parameterType="Long" resultMap="PointActivityLogResult">
<include refid="selectPointActivityLogVo"/>
where id = #{id}
</select>
<insert id="insertPointActivityLog" parameterType="PointActivityLog" useGeneratedKeys="true" keyProperty="id">
insert into s_point_activity_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="consumerId != null">consumer_id,</if>
<if test="pointActivityId != null">point_activity_id,</if>
<if test="orderNo != null">order_no,</if>
<if test="points != null">points,</if>
<if test="consumptionTime != null">consumption_time,</if>
<if test="isDelete != null">is_delete,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="consumerId != null">#{consumerId},</if>
<if test="pointActivityId != null">#{pointActivityId},</if>
<if test="orderNo != null">#{orderNo},</if>
<if test="points != null">#{points},</if>
<if test="consumptionTime != null">#{consumptionTime},</if>
<if test="isDelete != null">#{isDelete},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updatePointActivityLog" parameterType="PointActivityLog">
update s_point_activity_log
<trim prefix="SET" suffixOverrides=",">
<if test="consumerId != null">consumer_id = #{consumerId},</if>
<if test="pointActivityId != null">point_activity_id = #{pointActivityId},</if>
<if test="orderNo != null">order_no = #{orderNo},</if>
<if test="points != null">points = #{points},</if>
<if test="consumptionTime != null">consumption_time = #{consumptionTime},</if>
<if test="isDelete != null">is_delete = #{isDelete},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deletePointActivityLogById" parameterType="Long">
delete
from s_point_activity_log
where id = #{id}
</delete>
<delete id="deletePointActivityLogByIds" parameterType="String">
delete from s_point_activity_log where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment