Browse Source

积分兑换接口

feature/dangjian
wanggongfeng 4 years ago
parent
commit
ff2b2f8ee0
  1. 46
      esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/form/ExchangedCheckFormDTO.java
  2. 67
      esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/form/ExchangedListFormDTO.java
  3. 48
      esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/result/ExchangedCheckResultDTO.java
  4. 69
      esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/result/ExchangedListResultDTO.java
  5. 85
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/controller/AppAcitveController.java
  6. 52
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/dao/AppAcitveDao.java
  7. 44
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/AppAcitveService.java
  8. 117
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/impl/AppAcitveServiceImpl.java
  9. 78
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/mapper/AppAcitveDao.xml

46
esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/form/ExchangedCheckFormDTO.java

@ -0,0 +1,46 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.dto.form;
import lombok.Data;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 工作端-兑换核销入参
*
* @author wgf
* @since v1.0.0 2021-09-23
*/
@Data
public class ExchangedCheckFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 兑换ID
*/
@NotBlank(message = "兑换ID不能为空")
private String exchangeId;
}

67
esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/form/ExchangedListFormDTO.java

@ -0,0 +1,67 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.dto.form;
import lombok.Data;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;
/**
* 工作端-核销记录入参
*
* @author wgf
* @since v1.0.0 2021-09-23
*/
@Data
public class ExchangedListFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 页码从1开始
*/
@Min(value = 1, message = "页码必须大于0")
private int pageIndex;
/**
* 页容量默认20页
*/
@Min(value = 1, message = "每页条数必须大于必须大于0")
private int pageSize = 10;
/**
* 第一页查询发起时的时间
*/
@NotBlank(message = "时间戳不能为空")
private String timestamp;
/**
* 检索内容
*/
private String searchKey;
/**
* 核销人ID
*/
private String checkSysUserId;
}

48
esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/result/ExchangedCheckResultDTO.java

@ -0,0 +1,48 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* 工作端-兑换核销
*
* @author wgf
* @since v1.0.0 2021-09-23
*/
@Data
public class ExchangedCheckResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 是否成功
*/
private Boolean isSuccess;
/**
* 信息
*/
private String message;
}

69
esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/result/ExchangedListResultDTO.java

@ -0,0 +1,69 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.dto.result;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 工作端-核销记录
*
* @author wgf
* @since v1.0.0 2021-09-23
*/
@Data
public class ExchangedListResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
private String id;
/**
* 商品
*/
private String name;
/**
* 兑换人姓名
*/
private String userName;
/**
* 商品图片
*/
private String headPic;
/**
* 核销时间
*/
private String checkTime;
/**
* 核销人姓名
*/
private String checkSysUserName;
}

85
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/controller/AppAcitveController.java

@ -0,0 +1,85 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.controller;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.ExcelUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.commons.tools.validator.AssertUtils;
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils;
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup;
import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup;
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup;
import com.elink.esua.epdc.dto.AcitveProductExchangeDTO;
import com.elink.esua.epdc.dto.form.ExchangedCheckFormDTO;
import com.elink.esua.epdc.dto.form.ExchangedListFormDTO;
import com.elink.esua.epdc.dto.result.ExchangedCheckResultDTO;
import com.elink.esua.epdc.dto.result.ExchangedListResultDTO;
import com.elink.esua.epdc.excel.AcitveProductExchangeExcel;
import com.elink.esua.epdc.service.AcitveProductExchangeService;
import com.elink.esua.epdc.service.AppAcitveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* 接口
*
* @author wgf
* @since v1.0.0 2021-09-23
*/
@RestController
@RequestMapping("appAcitve")
public class AppAcitveController {
@Autowired
private AppAcitveService appAcitveService;
/**
* 工作端-核销记录
* @param formDto
* @return
*/
@GetMapping("getExchangedList")
public Result<List<ExchangedListResultDTO>> getExchangedList(@RequestBody ExchangedListFormDTO formDto){
//效验数据
ValidatorUtils.validateEntity(formDto);
Result<List<ExchangedListResultDTO>> result = appAcitveService.getExchangedList(formDto);
return result;
}
/**
* 工作端-核销记录
* @param formDto
* @return
*/
@GetMapping("exchangedCheck")
public Result<ExchangedCheckResultDTO> exchangedCheck(@RequestBody ExchangedCheckFormDTO formDto){
//效验数据
ValidatorUtils.validateEntity(formDto);
Result<ExchangedCheckResultDTO> result = appAcitveService.exchangedCheck(formDto);
return result;
}
}

52
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/dao/AppAcitveDao.java

@ -0,0 +1,52 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.dao;
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
import com.elink.esua.epdc.dto.AcitveProductExchangeDTO;
import com.elink.esua.epdc.dto.form.ExchangedCheckFormDTO;
import com.elink.esua.epdc.dto.form.ExchangedListFormDTO;
import com.elink.esua.epdc.dto.result.ExchangedListResultDTO;
import com.elink.esua.epdc.entity.AcitveProductExchangeEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 接口
*
* @author wgf
* @since v1.0.0 2021-09-23
*/
@Mapper
public interface AppAcitveDao {
/**
* 条件查询
* @param formDto
* @return
*/
List<ExchangedListResultDTO> getExchangedList(ExchangedListFormDTO formDto);
List<AcitveProductExchangeDTO> checkState(ExchangedCheckFormDTO formDto);
Integer checkPower(@Param("deptId") String deptId, @Param("productId") String productId);
}

44
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/AppAcitveService.java

@ -0,0 +1,44 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.service;
import com.elink.esua.epdc.commons.mybatis.service.BaseService;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.AcitveProductExchangeDTO;
import com.elink.esua.epdc.dto.form.ExchangedCheckFormDTO;
import com.elink.esua.epdc.dto.form.ExchangedListFormDTO;
import com.elink.esua.epdc.dto.result.ExchangedCheckResultDTO;
import com.elink.esua.epdc.dto.result.ExchangedListResultDTO;
import com.elink.esua.epdc.entity.AcitveProductExchangeEntity;
import java.util.List;
import java.util.Map;
/**
* 接口
*
* @author wgf
* @since v1.0.0 2021-09-23
*/
public interface AppAcitveService {
Result<List<ExchangedListResultDTO>> getExchangedList(ExchangedListFormDTO formDto);
Result<ExchangedCheckResultDTO> exchangedCheck(ExchangedCheckFormDTO formDto);
}

117
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/impl/AppAcitveServiceImpl.java

@ -0,0 +1,117 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.commons.tools.constant.NumConstant;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.security.user.SecurityUser;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dao.AcitveProductExchangeDao;
import com.elink.esua.epdc.dao.AppAcitveDao;
import com.elink.esua.epdc.dto.AcitveProductExchangeDTO;
import com.elink.esua.epdc.dto.form.ExchangedCheckFormDTO;
import com.elink.esua.epdc.dto.form.ExchangedListFormDTO;
import com.elink.esua.epdc.dto.result.ExchangedCheckResultDTO;
import com.elink.esua.epdc.dto.result.ExchangedListResultDTO;
import com.elink.esua.epdc.entity.AcitveProductExchangeEntity;
import com.elink.esua.epdc.redis.AcitveProductExchangeRedis;
import com.elink.esua.epdc.service.AcitveProductExchangeService;
import com.elink.esua.epdc.service.AppAcitveService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 接口
*
* @author wgf
* @since v1.0.0 2021-09-23
*/
@Service
public class AppAcitveServiceImpl implements AppAcitveService {
@Autowired
private AppAcitveDao appAcitveDao;
@Autowired
private AcitveProductExchangeService acitveProductExchangeService;
@Override
public Result<List<ExchangedListResultDTO>> getExchangedList(ExchangedListFormDTO formDto) {
int pageIndex = (formDto.getPageIndex() - NumConstant.ONE) * formDto.getPageSize();
formDto.setPageIndex(pageIndex);
// 设置当前登陆人
formDto.setCheckSysUserId(SecurityUser.getUserId().toString());
List<ExchangedListResultDTO> list = appAcitveDao.getExchangedList(formDto);
return new Result<List<ExchangedListResultDTO>>().ok(list);
}
@Override
public Result<ExchangedCheckResultDTO> exchangedCheck(ExchangedCheckFormDTO formDto) {
// 当前登陆人信息
String userId = SecurityUser.getUser().getId().toString();
String deptId = SecurityUser.getUser().getDeptId().toString();
String userName = SecurityUser.getUser().getUsername();
// 返回实体
ExchangedCheckResultDTO resultDTO = new ExchangedCheckResultDTO();
// 校验是否已核销(查询未核销)
List<AcitveProductExchangeDTO> list = appAcitveDao.checkState(formDto);
if(list.size() > 0){
AcitveProductExchangeDTO acitveProductExchangeDTO = list.get(0);
// 判断当前登陆人是否有该商品的核销权限
Integer isPower = appAcitveDao.checkPower(deptId,acitveProductExchangeDTO.getProductId());
if(isPower > 0){
acitveProductExchangeDTO.setExchangeState("1");
acitveProductExchangeDTO.setCheckSysUserId(userId);
acitveProductExchangeDTO.setCheckSysUserName(userName);
acitveProductExchangeDTO.setCheckTime(new Date());
acitveProductExchangeDTO.setUpdatedBy(userId);
acitveProductExchangeDTO.setUpdatedTime(new Date());
acitveProductExchangeService.update(acitveProductExchangeDTO);
resultDTO.setIsSuccess(true);
resultDTO.setMessage("核销成功!");
}else{
resultDTO.setIsSuccess(false);
resultDTO.setMessage("您没有该商品核销权限!");
}
}else{
resultDTO.setIsSuccess(false);
resultDTO.setMessage("该商品已核销!");
}
return new Result<ExchangedCheckResultDTO>().ok(resultDTO);
}
}

78
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/mapper/AppAcitveDao.xml

@ -0,0 +1,78 @@
<?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.elink.esua.epdc.dao.AppAcitveDao">
<resultMap type="com.elink.esua.epdc.entity.AcitveProductExchangeEntity" id="acitveProductExchangeMap">
<result property="id" column="ID"/>
<result property="userId" column="USER_ID"/>
<result property="userName" column="USER_NAME"/>
<result property="productId" column="PRODUCT_ID"/>
<result property="productName" column="PRODUCT_NAME"/>
<result property="exchangeTime" column="EXCHANGE_TIME"/>
<result property="exchangeState" column="EXCHANGE_STATE"/>
<result property="checkSysUserId" column="CHECK_SYS_USER_ID"/>
<result property="qrCodeUrl" column="QR_CODE_URL"/>
<result property="checkSysUserName" column="CHECK_SYS_USER_NAME"/>
<result property="checkTime" column="CHECK_TIME"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<select id="getExchangedList" resultType="com.elink.esua.epdc.dto.result.ExchangedListResultDTO"
parameterType="com.elink.esua.epdc.dto.form.ExchangedListFormDTO">
select
a.ID id,
a.PRODUCT_NAME name,
a.USER_NAME userName,
b.HEAD_PIC headPic,
a.CHECK_TIME checkTime,
a.CHECK_SYS_USER_NAME checkSysUserName
from epdc_acitve_product_exchange a
left join epdc_acitve_product_info b on a.PRODUCT_ID = b.ID and b.DEL_FLAG = 0
where a.DEL_FLAG = 0
and a.EXCHANGE_STATE = '1'
<if test="timestamp != null">
<![CDATA[ AND DATE_FORMAT(a.CHECK_TIME,'%Y-%m-%d %H:%i:%s') <= ]]> #{timestamp}
</if>
<if test="searchKey != null and searchKey != ''">
and (a.CHECK_SYS_USER_NAME like '%' #{searchKey} '%' or a.PRODUCT_NAME like '%' #{searchKey} '%')
</if>
<if test="checkSysUserId != null and checkSysUserId != ''">
and a.CHECK_SYS_USER_ID = #{checkSysUserId}
</if>
LIMIT #{pageIndex},#{pageSize}
</select>
<select id="checkState" resultType="com.elink.esua.epdc.dto.AcitveProductExchangeDTO"
parameterType="com.elink.esua.epdc.dto.form.ExchangedCheckFormDTO">
select
a.ID id,
a.PRODUCT_ID
from epdc_acitve_product_exchange a
where a.DEL_FLAG = 0
and a.EXCHANGE_STATE = '0'
<if test="exchangeId != null and exchangeId != ''">
and a.ID = #{exchangeId}
</if>
</select>
<select id="checkPower" resultType="java.lang.Integer" parameterType="java.lang.String">
select
count(a.ID)
from epdc_acitve_product_dept a
where a.DEL_FLAG = 0
<if test="deptId != null and deptId != ''">
and a.DEPT_ID = #{deptId}
</if>
<if test="productId != null and productId != ''">
and a.PRODUCT_ID = #{productId}
</if>
</select>
</mapper>
Loading…
Cancel
Save