From ff2b2f8ee0a090f5b5cc1bda982c9e87019095eb Mon Sep 17 00:00:00 2001 From: wanggongfeng <1305282856@qq.com> Date: Mon, 27 Sep 2021 17:13:43 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=AF=E5=88=86=E5=85=91=E6=8D=A2=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epdc/dto/form/ExchangedCheckFormDTO.java | 46 +++++++ .../epdc/dto/form/ExchangedListFormDTO.java | 67 ++++++++++ .../dto/result/ExchangedCheckResultDTO.java | 48 +++++++ .../dto/result/ExchangedListResultDTO.java | 69 +++++++++++ .../epdc/controller/AppAcitveController.java | 85 +++++++++++++ .../com/elink/esua/epdc/dao/AppAcitveDao.java | 52 ++++++++ .../esua/epdc/service/AppAcitveService.java | 44 +++++++ .../service/impl/AppAcitveServiceImpl.java | 117 ++++++++++++++++++ .../main/resources/mapper/AppAcitveDao.xml | 78 ++++++++++++ 9 files changed, 606 insertions(+) create mode 100644 esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/form/ExchangedCheckFormDTO.java create mode 100644 esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/form/ExchangedListFormDTO.java create mode 100644 esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/result/ExchangedCheckResultDTO.java create mode 100644 esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/result/ExchangedListResultDTO.java create mode 100644 esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/controller/AppAcitveController.java create mode 100644 esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/dao/AppAcitveDao.java create mode 100644 esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/AppAcitveService.java create mode 100644 esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/impl/AppAcitveServiceImpl.java create mode 100644 esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/mapper/AppAcitveDao.xml diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/form/ExchangedCheckFormDTO.java b/esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/form/ExchangedCheckFormDTO.java new file mode 100644 index 000000000..e8d632e33 --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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; + + + +} diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/form/ExchangedListFormDTO.java b/esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/form/ExchangedListFormDTO.java new file mode 100644 index 000000000..fa091980c --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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; + +} diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/result/ExchangedCheckResultDTO.java b/esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/result/ExchangedCheckResultDTO.java new file mode 100644 index 000000000..72011bf41 --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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; + + + +} diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/result/ExchangedListResultDTO.java b/esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/result/ExchangedListResultDTO.java new file mode 100644 index 000000000..b1af60e63 --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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; + + + +} diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/controller/AppAcitveController.java b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/controller/AppAcitveController.java new file mode 100644 index 000000000..02aa1e4d8 --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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> getExchangedList(@RequestBody ExchangedListFormDTO formDto){ + //效验数据 + ValidatorUtils.validateEntity(formDto); + Result> result = appAcitveService.getExchangedList(formDto); + return result; + } + + /** + * 工作端-核销记录 + * @param formDto + * @return + */ + @GetMapping("exchangedCheck") + public Result exchangedCheck(@RequestBody ExchangedCheckFormDTO formDto){ + //效验数据 + ValidatorUtils.validateEntity(formDto); + Result result = appAcitveService.exchangedCheck(formDto); + return result; + } + + +} diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/dao/AppAcitveDao.java b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/dao/AppAcitveDao.java new file mode 100644 index 000000000..1f8d217a2 --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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 getExchangedList(ExchangedListFormDTO formDto); + + List checkState(ExchangedCheckFormDTO formDto); + + Integer checkPower(@Param("deptId") String deptId, @Param("productId") String productId); + +} diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/AppAcitveService.java b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/AppAcitveService.java new file mode 100644 index 000000000..8549bb684 --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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> getExchangedList(ExchangedListFormDTO formDto); + + Result exchangedCheck(ExchangedCheckFormDTO formDto); +} diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/impl/AppAcitveServiceImpl.java b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/impl/AppAcitveServiceImpl.java new file mode 100644 index 000000000..18183b88f --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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> getExchangedList(ExchangedListFormDTO formDto) { + + int pageIndex = (formDto.getPageIndex() - NumConstant.ONE) * formDto.getPageSize(); + formDto.setPageIndex(pageIndex); + + // 设置当前登陆人 + formDto.setCheckSysUserId(SecurityUser.getUserId().toString()); + + List list = appAcitveDao.getExchangedList(formDto); + return new Result>().ok(list); + } + + @Override + public Result 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 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().ok(resultDTO); + } + +} diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/mapper/AppAcitveDao.xml b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/mapper/AppAcitveDao.xml new file mode 100644 index 000000000..dff92a63b --- /dev/null +++ b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/mapper/AppAcitveDao.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +