Commit 22858836 authored by zhaobiyan's avatar zhaobiyan

兑换记录更新接口

parent 6c3ca496
......@@ -6,9 +6,10 @@ import cn.iocoder.yudao.module.reward.api.reward.RedeemRewardApi;
import cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardReqVO;
import cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardRespDTO;
import cn.iocoder.yudao.module.reward.service.redeem.RewardRedeemService;
import cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemBaseVO;
import cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemPageReqVO;
import cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemPageRespVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemUpdateVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
......@@ -19,7 +20,6 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
......@@ -42,6 +42,18 @@ public class RedeemRewardController {
return success(rewardRedeemService.pageInfo(reqVO));
}
@PostMapping("record/detail")
@ApiOperation("兑换记录详情")
public CommonResult<RewardRedeemPageRespVO> detail(@Valid @RequestBody RewardRedeemBaseVO request) {
return success(rewardRedeemService.detail(request.getId()));
}
@PostMapping("record/update")
@ApiOperation("兑换记录更新")
public CommonResult<Boolean> update(@Valid @RequestBody RewardRedeemUpdateVO request) {
return success(rewardRedeemService.updateRecord(request));
}
@PostMapping("/single")
@ApiOperation("兑换礼品")
......
......@@ -19,4 +19,6 @@ public interface RewardRedeemMapper extends AbstractMapper<RewardRedeemDO> {
List<RewardRedeemPageRespVO> pageInfo(@Param("start") int start, @Param("size") int size, @Param("req") RewardRedeemPageReqVO reqVO);
int pageCount(@Param("req") RewardRedeemPageReqVO reqVO);
RewardRedeemPageRespVO detail(@Param("id") Long id);
}
......@@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.mybatis.core.service.IService;
import cn.iocoder.yudao.module.reward.dal.dataobject.redeem.RewardRedeemDO;
import cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemPageReqVO;
import cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemPageRespVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemUpdateVO;
/**
* 礼品兑换 Service 接口
......@@ -15,4 +15,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
public interface RewardRedeemService extends IService<RewardRedeemDO> {
PageResult<RewardRedeemPageRespVO> pageInfo(RewardRedeemPageReqVO reqVO);
RewardRedeemPageRespVO detail(Long id);
Boolean updateRecord(RewardRedeemUpdateVO request);
}
......@@ -2,16 +2,26 @@ package cn.iocoder.yudao.module.reward.service.redeem;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.reward.dal.dataobject.redeem.RewardRedeemDO;
import cn.iocoder.yudao.module.reward.dal.mysql.redeem.RewardRedeemMapper;
import cn.iocoder.yudao.module.reward.enums.ErrorCodeConstants;
import cn.iocoder.yudao.module.reward.enums.RewardRedeemStatusEnum;
import cn.iocoder.yudao.module.reward.service.reward.RewardService;
import cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemPageReqVO;
import cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemPageRespVO;
import cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemUpdateVO;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
/**
* 礼品兑换 Service
*
......@@ -22,6 +32,8 @@ import java.util.List;
public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper, RewardRedeemDO> implements RewardRedeemService {
@Resource
private RewardRedeemMapper rewardRedeemMapper;
@Resource
private RewardService rewardService;
@Override
public PageResult<RewardRedeemPageRespVO> pageInfo(RewardRedeemPageReqVO reqVO) {
......@@ -31,4 +43,49 @@ public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper,
int total = rewardRedeemMapper.pageCount(reqVO);
return new PageResult<>(result, total, reqVO.getPageSize(), reqVO.getPageNo(), (total + reqVO.getPageSize() - 1) / reqVO.getPageSize());
}
@Override
public RewardRedeemPageRespVO detail(Long id) {
if (id == null) {
return null;
}
return rewardRedeemMapper.detail(id);
}
@Override
public Boolean updateRecord(RewardRedeemUpdateVO request) {
validateParam(request);
LambdaUpdateWrapper<RewardRedeemDO> wrapper = Wrappers.lambdaUpdate();
wrapper.eq(RewardRedeemDO::getId, request.getId());
wrapper.set(RewardRedeemDO::getRedeemType, request.getRedeemType());
wrapper.set(RewardRedeemDO::getExpenses, request.getExpenses());
wrapper.set(RewardRedeemDO::getCurrency, request.getCurrency());
wrapper.set(RewardRedeemDO::getRecipientName, request.getRecipientName());
wrapper.set(RewardRedeemDO::getRecipientAddress, request.getRecipientAddress());
wrapper.set(RewardRedeemDO::getRecipientPhoneNum, request.getRecipientPhoneNum());
wrapper.set(RewardRedeemDO::getRedeemer, request.getRedeemer());
wrapper.set(RewardRedeemDO::getRedemptionTime, request.getRedemptionTime());
wrapper.set(RewardRedeemDO::getCourierCompany, request.getCourierCompany());
wrapper.set(RewardRedeemDO::getExpressNo, request.getExpressNo());
wrapper.set(RewardRedeemDO::getExpressDate, request.getExpressDate());
wrapper.set(RewardRedeemDO::getExpressSender, request.getExpressSender());
wrapper.set(RewardRedeemDO::getAnnex, request.getAnnex());
wrapper.set(RewardRedeemDO::getRemark, request.getRemark());
wrapper.set(RewardRedeemDO::getUpdater, SecurityFrameworkUtils.getLoginUserId());
wrapper.set(RewardRedeemDO::getUpdateTime, new Date());
rewardRedeemMapper.update(null, wrapper);
return true;
}
private void validateParam(RewardRedeemUpdateVO request) {
RewardRedeemDO rewardRedeemDO = getById(request.getId());
if (rewardRedeemDO == null) {
//todo 提示修改
throw exception(ErrorCodeConstants.REWARD_ENDTIME_ERROR);
}
if (rewardRedeemDO.getStatus() != RewardRedeemStatusEnum.REDEEMING.getValue()) {
//todo 提示修改
throw exception(ErrorCodeConstants.REWARD_ENDTIME_ERROR);
}
}
}
package cn.iocoder.yudao.module.reward.vo.reward;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class RewardRedeemUpdateVO {
@NotNull(message = "id is not null")
@ApiModelProperty(value = "id")
private Long id;
@NotNull(message = "redeemType is not null")
@ApiModelProperty(value = "兑换方式")
private Integer redeemType;
@ApiModelProperty(value = "费用")
private BigDecimal expenses;
@ApiModelProperty(value = "币种")
private Integer currency;
@NotNull(message = "recipientName is not null")
/**
* 收件人姓名
*/
@ApiModelProperty(value = "收件人姓名")
private String recipientName;
/**
* 收件人电话
*/
@NotNull(message = "recipientPhoneNum is not null")
@ApiModelProperty(value = "收件人电话")
private String recipientPhoneNum;
/**
* 收件人地址
*/
@NotNull(message = "recipientAddress is not null")
@ApiModelProperty(value = "收件人地址")
private String recipientAddress;
/**
* 兑换人
*/
@ApiModelProperty(value = "兑换人")
private String redeemer;
/**
* 兑换时间
*/
@ApiModelProperty(value = "兑换时间")
private Date redemptionTime;
/**
* 快递公司
*/
@ApiModelProperty(value = "快递公司")
private String courierCompany;
/**
* 快递单号
*/
@ApiModelProperty(value = "快递单号")
private String expressNo;
/**
* 快递日期
*/
@ApiModelProperty(value = "快递日期")
private String expressDate;
/**
* 快递寄出人
*/
@ApiModelProperty(value = "快递寄出人")
private String expressSender;
/**
* 上传附件
*/
@ApiModelProperty(value = "上传附件")
private String annex;
/**
* 备注
*/
@ApiModelProperty(value = "备注")
private String remark;
}
......@@ -11,6 +11,44 @@
<select id="pageInfo" resultType="cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemPageRespVO">
select
<include refid="columns"/>
from ecw_reward_redeem err
left join ecw_reward er on err.reward_id = er.id
left join member_user mu on mu.id = err.member_id
left join ecw_node en on er.node_id = en.id
left join system_user suc on suc.id = er.creator
left join system_user suu on suu.id = er.updater
left join ecw_currency cc on err.currency = cc.id
where 1=1
<include refid="pageCondition"/>
order by er.create_time desc
limit #{start}, #{size}
</select>
<select id="pageCount" resultType="java.lang.Integer">
select count(*)
from ecw_reward_redeem err
left join ecw_reward er on err.reward_id = er.id
left join member_user mu on mu.id = err.member_id
left join ecw_node en on er.node_id = en.id
left join system_user suc on suc.id = er.creator
left join system_user suu on suu.id = er.updater
where 1=1
<include refid="pageCondition"/>
</select>
<select id="detail" resultType="cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemPageRespVO">
select
<include refid="columns"/>
from ecw_reward_redeem err
left join ecw_reward er on err.reward_id = er.id
left join member_user mu on mu.id = err.member_id
left join ecw_node en on er.node_id = en.id
left join system_user suc on suc.id = er.creator
left join system_user suu on suu.id = er.updater
left join ecw_currency cc on err.currency = cc.id
where err.id = #{id}
</select>
<sql id="columns">
err.id ,
err.member_id as memberId,
err.reward_id as rewardId,
......@@ -49,29 +87,7 @@
cc.title_zh as currencyTitleZh,
cc.title_en as currencyTitleEn,
(select username from system_user where id = er.updater) as updaterName
from ecw_reward_redeem err
left join ecw_reward er on err.reward_id = er.id
left join member_user mu on mu.id = err.member_id
left join ecw_node en on er.node_id = en.id
left join system_user suc on suc.id = er.creator
left join system_user suu on suu.id = er.updater
left join ecw_currency cc on err.currency = cc.id
where 1=1
<include refid="pageCondition"/>
order by er.create_time desc
limit #{start}, #{size}
</select>
<select id="pageCount" resultType="java.lang.Integer">
select count(*)
from ecw_reward_redeem err
left join ecw_reward er on err.reward_id = er.id
left join member_user mu on mu.id = err.member_id
left join ecw_node en on er.node_id = en.id
left join system_user suc on suc.id = er.creator
left join system_user suu on suu.id = er.updater
where 1=1
<include refid="pageCondition"/>
</select>
</sql>
<sql id="pageCondition">
<if test="req.rewardTitle != null and req.rewardTitle !=''">
......
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