mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-14 05:42:06 +08:00
资金管理接口,ES索引统一枚举
This commit is contained in:
+47
@@ -0,0 +1,47 @@
|
||||
package com.cf.imes.module.system.api.funds;
|
||||
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.module.system.api.funds.dto.InvoiceTitleInfoDTO;
|
||||
import com.cf.imes.module.system.api.funds.dto.OrganAmountDTO;
|
||||
import com.cf.imes.module.system.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author 资金管理feign接口
|
||||
*/
|
||||
@FeignClient(name = ApiConstants.NAME) // TODO 晨丰:fallbackFactory =
|
||||
@Tag(name = "RPC 服务 - 资金管理")
|
||||
public interface SystemFundsApi {
|
||||
|
||||
|
||||
String PREFIX = ApiConstants.PREFIX + "/funds";
|
||||
|
||||
|
||||
@GetMapping(PREFIX + "/amount/reduce")
|
||||
@Operation(summary = "减少组织可开票的金额")
|
||||
CommonResult<Boolean> reduceOrganAmount(@RequestParam("organId") Long organId,@RequestParam("invoiceAmount") BigDecimal invoiceAmount);
|
||||
|
||||
|
||||
@GetMapping(PREFIX + "/amount/add")
|
||||
@Operation(summary = "增加组织可开票的金额")
|
||||
CommonResult<Boolean> addOrganAmount(@RequestParam("organId") Long organId,@RequestParam("invoiceAmount") BigDecimal invoiceAmount);
|
||||
|
||||
|
||||
@GetMapping(PREFIX + "/amount/organ")
|
||||
@Operation(summary = "获取组织的资金信息")
|
||||
CommonResult<OrganAmountDTO> getOrganAmount(@RequestParam("organId") Long organId);
|
||||
|
||||
|
||||
@GetMapping(PREFIX + "/invoice/title")
|
||||
@Operation(summary = "获取发票的抬头信息")
|
||||
CommonResult<InvoiceTitleInfoDTO> getInvoiceTitle(@RequestParam("invoiceTitleId") Long invoiceTitleId);
|
||||
|
||||
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package com.cf.imes.module.system.api.funds.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Schema(description = "RPC 服务 - 发票的抬头信息")
|
||||
@Data
|
||||
public class InvoiceTitleInfoDTO {
|
||||
|
||||
|
||||
@Schema(description = "抬头ID")
|
||||
private Long id;
|
||||
|
||||
|
||||
@Schema(description = "组织ID")
|
||||
private Long organId;
|
||||
|
||||
|
||||
@Schema(description = "发票抬头")
|
||||
private String invoiceTitle;
|
||||
|
||||
|
||||
@Schema(description = "开具类型")
|
||||
private Integer issueType;
|
||||
|
||||
|
||||
@Schema(description = "发票类型")
|
||||
private Integer invoiceType;
|
||||
|
||||
|
||||
@Schema(description = "纳税人识别号")
|
||||
private String taxpayerId;
|
||||
|
||||
|
||||
@Schema(description = "开户银行名称")
|
||||
private String bankName;
|
||||
|
||||
|
||||
@Schema(description = "开户银行账号")
|
||||
private String bankAccount;
|
||||
|
||||
|
||||
@Schema(description = "注册场所地址")
|
||||
private String registeredAddress;
|
||||
|
||||
|
||||
@Schema(description = "注册固定电话")
|
||||
private String fixedPhone;
|
||||
|
||||
|
||||
@Schema(description = "邮箱")
|
||||
private String email;
|
||||
|
||||
|
||||
}
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package com.cf.imes.module.system.api.funds.dto;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Schema(description = "RPC 服务 - 组织的资金信息")
|
||||
@Data
|
||||
public class OrganAmountDTO {
|
||||
|
||||
|
||||
@Schema(description = "主键")
|
||||
private Long id;
|
||||
|
||||
|
||||
@Schema(description = "组织ID")
|
||||
private Long organId;
|
||||
|
||||
|
||||
@Schema(description = "现金金额")
|
||||
private BigDecimal amount;
|
||||
|
||||
|
||||
@Schema(description = "赠送金额")
|
||||
private BigDecimal giftAmount;
|
||||
|
||||
|
||||
@Schema(description = "货币类型")
|
||||
private Integer currency;
|
||||
|
||||
|
||||
@Schema(description = "货币单位")
|
||||
private String currencyUnit;
|
||||
|
||||
|
||||
@Schema(description = "可开票金额")
|
||||
private BigDecimal invoiceableAmount;
|
||||
|
||||
|
||||
|
||||
}
|
||||
+15
-3
@@ -2,17 +2,17 @@ package com.cf.imes.module.system.api.organ;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.module.system.api.organ.dto.OrgStatisticsReqDTO;
|
||||
import com.cf.imes.module.system.api.organ.dto.OrganizationDTO;
|
||||
import com.cf.imes.module.system.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -42,4 +42,16 @@ public interface OrganApi {
|
||||
@GetMapping(PREFIX + "/warn/org")
|
||||
@Operation(summary = "组织过期日期统计")
|
||||
CommonResult<Map<String, List<Object>>> getWarnToOrg();
|
||||
|
||||
|
||||
@GetMapping(PREFIX + "/organ-details")
|
||||
@Operation(summary = "根据组织ID获取组织的详细信息")
|
||||
CommonResult<OrganizationDTO> getOrganDetails(@RequestParam("organId") Long organId);
|
||||
|
||||
|
||||
@GetMapping(PREFIX + "/name-details")
|
||||
@Operation(summary = "根据组织名称获取组织的信息")
|
||||
CommonResult<List<OrganizationDTO>> getOrganDetailsByName(@RequestParam("organName") String organName);
|
||||
|
||||
|
||||
}
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.cf.imes.module.system.api.organ.dto;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author 组织的信息
|
||||
*/
|
||||
@Schema(description = "RPC 服务 - 组织的信息 Resp DTO")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class OrganizationDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1788458794035807655L;
|
||||
|
||||
|
||||
@Schema(description = "组织ID")
|
||||
private Long id;
|
||||
|
||||
|
||||
@Schema(description = "组织名称")
|
||||
private String name;
|
||||
|
||||
|
||||
|
||||
}
|
||||
+25
-1
@@ -420,6 +420,21 @@ public class ErrorCodeConstants {
|
||||
public static final ErrorCode INVOICE_FILE_UPLOAD_FAILED = new ErrorCode(1_002_043_005, "发票附件上传失败,请重新上传");
|
||||
public static final ErrorCode INVOICE_FILE_IS_NULL_NOT_DOWNLOAD = new ErrorCode(1_002_043_006, "发票附件不存在,无法下载");
|
||||
public static final ErrorCode INVOICE_FILE_DATA_ERROR = new ErrorCode(1_002_043_007, "发票附件下载失败,请重新下载或稍等重试");
|
||||
public static final ErrorCode PURCHASE_RECORD_NO_EXIST = new ErrorCode(1_002_043_008, "当前发票对应的购买记录有误,请删除重新创建发票");
|
||||
public static final ErrorCode INVOICE_TITLE_NO_EXIST = new ErrorCode(1_002_043_009, "发票抬头信息有误,请进行查看");
|
||||
public static final ErrorCode THIS_INVOICE_IS_FAIL = new ErrorCode(1_002_043_010, "当前发票以开票,无法再次进行开票");
|
||||
public static final ErrorCode THIS_INVOICE_IS_SUCCESS = new ErrorCode(1_002_043_011, "当前发票已经开票,无法再次进行开票");
|
||||
public static final ErrorCode PRODUCTS_IS_EXIST = new ErrorCode(1_002_043_012, "当前名称的产品已存在,无法新增产品");
|
||||
public static final ErrorCode PRODUCTS_NO_DELETE = new ErrorCode(1_002_043_013, "当前产品以上架,无法删除,请下架后再删除");
|
||||
public static final ErrorCode PRODUCTS_NO_UPDATE = new ErrorCode(1_002_043_014, "当前产品以上架,无法进行修改");
|
||||
public static final ErrorCode PRODUCTS_DETAIL_NO_UPDATE = new ErrorCode(1_002_043_016, "定价规则对应的产品已上架,无法进行修改");
|
||||
public static final ErrorCode ADVERTISEMENT_START_TIME_ERROR = new ErrorCode(1_003_043_017, "广告开始时间选择有误,应等于或大于当日");
|
||||
public static final ErrorCode ADVERTISEMENT_TIME_ERROR = new ErrorCode(1_003_043_018, "时间选择有误,结束时间应大于或等于开始时间");
|
||||
public static final ErrorCode ADVERTISEMENT_NAME_IS_EXIST = new ErrorCode(1_003_043_019, "当前名称的广告已存在,请重新命名");
|
||||
public static final ErrorCode ADVERTISEMENT_NO_DELETE = new ErrorCode(1_003_043_020, "当前广告已经发布,无法删除,请结束发布后再删除");
|
||||
public static final ErrorCode ADVERTISEMENT_REPUBLISH_NO_TIME = new ErrorCode(1_003_043_021, "广告重新发布,应重新选择投放时间");
|
||||
public static final ErrorCode RECHARGE_ACTIVE_NAME_IS_EXIST = new ErrorCode(1_004_043_022, "当前赠送金活动名称已存在,请修改");
|
||||
public static final ErrorCode IMAGE_UPLOAD_ERROR = new ErrorCode(1_004_043_023, "图片上传失败,请重试或重新选择图片");
|
||||
|
||||
//=========== 支付相关 1-002-044-000 ============
|
||||
public static final ErrorCode PAY_CHANNEL_NOT_SUPPORT = new ErrorCode(1_002_044_000, "暂不支持的支付渠道,请使用其他支付渠道");
|
||||
@@ -437,7 +452,7 @@ public class ErrorCodeConstants {
|
||||
public static final ErrorCode PRODUCTS_DETAIL_DURATION_EXIST = new ErrorCode(1_002_045_005, "存在当前时长的产品定价规则");
|
||||
public static final ErrorCode PRODUCTS_DETAIL_OUTPUT_EXIST = new ErrorCode(1_002_045_006, "存在当前产量的产品定价规则");
|
||||
public static final ErrorCode PRODUCTS_DURATION_NUM_ERR = new ErrorCode(1_002_045_007, "产品定价规则,时长数据设置有误");
|
||||
public static final ErrorCode PRODUCTS_DURATION_INT_ERR = new ErrorCode(1_002_045_008, "产品定价规则,时长数据为正整数");
|
||||
public static final ErrorCode PRODUCTS_DURATION_INT_ERR = new ErrorCode(1_002_045_008, "产品定价规则:时长必须为整数且大于 0");
|
||||
public static final ErrorCode PRODUCTS_DURATION_UNIT_ERR = new ErrorCode(1_002_045_009, "产品定价规则,时长单位设置有误");
|
||||
|
||||
//=========== 广告相关 1-002-046-000 ============
|
||||
@@ -451,4 +466,13 @@ public class ErrorCodeConstants {
|
||||
|
||||
public static final ErrorCode RECHARGE_ACTIVE_NO_EXIST = new ErrorCode(1_004_001_001, "当前赠送金活动不存在");
|
||||
|
||||
|
||||
|
||||
|
||||
//=========== 解析器管理 1-002-044-000 ============
|
||||
public static final ErrorCode PARSER_NO_EXIST = new ErrorCode(1_002_044_001, "当前解析器不存在,请重新选择");
|
||||
|
||||
public static final ErrorCode PARSER_TEMPLATE_NO_EXIST = new ErrorCode(1_002_044_002, "当前解析器模板不存在,请重新选择");
|
||||
|
||||
|
||||
}
|
||||
|
||||
+3
-28
@@ -5,7 +5,6 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 广告状态单位态枚举
|
||||
@@ -16,10 +15,9 @@ import java.util.Objects;
|
||||
@AllArgsConstructor
|
||||
public enum AdvertisementStatusEnum implements IntArrayValuable {
|
||||
|
||||
ALL(0, "全部"),
|
||||
UNPUBLISHED(1, "未发布"),
|
||||
PUBLISHED(2, "已发布"),
|
||||
ENDED(3, "已结束");
|
||||
UNPUBLISHED(0, "未发布"),
|
||||
PUBLISHED(1, "已发布"),
|
||||
ENDED(2, "已结束");
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(AdvertisementStatusEnum::getStatus).toArray();
|
||||
|
||||
@@ -37,28 +35,5 @@ public enum AdvertisementStatusEnum implements IntArrayValuable {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
public static boolean isAll(String name) {
|
||||
return Objects.equals(ALL.name, name);
|
||||
}
|
||||
|
||||
public static boolean isUnpublished(String name) {
|
||||
return Objects.equals(UNPUBLISHED.name, name);
|
||||
}
|
||||
|
||||
public static boolean isPublished(String name) {
|
||||
return Objects.equals(PUBLISHED.name, name);
|
||||
}
|
||||
|
||||
public static boolean isEnded(String name) {
|
||||
return Objects.equals(ENDED.name, name);
|
||||
}
|
||||
|
||||
public static Integer getNameByStatus(String name) {
|
||||
for (AdvertisementStatusEnum e : values()) {
|
||||
if (e.getName().equals(name)) {
|
||||
return e.getStatus();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -16,9 +16,9 @@ import java.util.Objects;
|
||||
@AllArgsConstructor
|
||||
public enum DurationUnitEnum implements IntArrayValuable {
|
||||
|
||||
YEAR(0, "year"),
|
||||
MONTH(1, "month"),
|
||||
DAY(2, "day");
|
||||
YEAR(0, "年"),
|
||||
MONTH(1, "月"),
|
||||
DAY(2, "日");
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DurationUnitEnum::getStatus).toArray();
|
||||
|
||||
|
||||
+4
-4
@@ -16,10 +16,10 @@ import java.util.Objects;
|
||||
@AllArgsConstructor
|
||||
public enum ProductStatusEnum implements IntArrayValuable {
|
||||
|
||||
PRODUCT_ALL(0, "全部"),
|
||||
PRODUCT_WAITING_UPDATES(1, "待上架"),
|
||||
PRODUCT_UPDATES(2, "已上架"),
|
||||
PRODUCT_DELIS(3, "已下架");
|
||||
|
||||
PRODUCT_WAITING_UPDATES(0, "待上架"),
|
||||
PRODUCT_UPDATES(1, "已上架"),
|
||||
PRODUCT_DELIS(2, "已下架");
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductStatusEnum::getStatus).toArray();
|
||||
|
||||
|
||||
+2
@@ -2,11 +2,13 @@ package com.cf.imes.module.system;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
/**
|
||||
* 项目的启动类
|
||||
* @author 晨丰科技
|
||||
*/
|
||||
@EnableScheduling
|
||||
@SpringBootApplication
|
||||
public class SystemServerApplication {
|
||||
|
||||
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
package com.cf.imes.module.system.api.funds;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.framework.common.util.Assert.AssertUtils;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.module.system.api.funds.dto.InvoiceTitleInfoDTO;
|
||||
import com.cf.imes.module.system.api.funds.dto.OrganAmountDTO;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.invoice.InvoiceTitleInfoDO;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.organamount.OrganAmountDO;
|
||||
import com.cf.imes.module.system.dal.mysql.funds.invoice.InvoiceTitleInfoMapper;
|
||||
import com.cf.imes.module.system.dal.mysql.funds.organamount.OrganAmountMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.INVOICE_TITLE_NO_EXIST;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.ORGAN_AMOUNT_NO_EXIST;
|
||||
|
||||
|
||||
/**
|
||||
* @author 资金管理feign实现类
|
||||
*/
|
||||
@RestController
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class SystemFundsApiImpl implements SystemFundsApi {
|
||||
|
||||
@Resource
|
||||
private OrganAmountMapper organAmountMapper;
|
||||
|
||||
|
||||
@Resource
|
||||
private InvoiceTitleInfoMapper invoiceTitleInfoMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> reduceOrganAmount(Long organId, BigDecimal invoiceAmount) {
|
||||
|
||||
OrganAmountDO organAmountDO = validateOrganAmountExists(organId);
|
||||
|
||||
BigDecimal invoiceableAmount = organAmountDO.getInvoiceableAmount().subtract(invoiceAmount);
|
||||
|
||||
if(invoiceableAmount.signum() < 0){
|
||||
invoiceableAmount = BigDecimal.valueOf(0);
|
||||
}
|
||||
|
||||
|
||||
organAmountDO.setInvoiceableAmount(invoiceableAmount);
|
||||
organAmountMapper.updateById(organAmountDO);
|
||||
|
||||
return CommonResult.success(Boolean.TRUE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> addOrganAmount(Long organId, BigDecimal invoiceAmount) {
|
||||
|
||||
OrganAmountDO organAmountDO = validateOrganAmountExists(organId);
|
||||
|
||||
BigDecimal invoiceableAmount = organAmountDO.getInvoiceableAmount().add(invoiceAmount);
|
||||
|
||||
|
||||
organAmountDO.setInvoiceableAmount(invoiceableAmount);
|
||||
organAmountMapper.updateById(organAmountDO);
|
||||
|
||||
return CommonResult.success(Boolean.TRUE);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<OrganAmountDTO> getOrganAmount(Long organId) {
|
||||
|
||||
return CommonResult.success(BeanUtils.toBean(validateOrganAmountExists(organId),OrganAmountDTO.class));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommonResult<InvoiceTitleInfoDTO> getInvoiceTitle(Long invoiceTitleId) {
|
||||
|
||||
InvoiceTitleInfoDO invoiceTitleInfoDO = invoiceTitleInfoMapper.selectById(invoiceTitleId);
|
||||
|
||||
AssertUtils.notEmpty(invoiceTitleInfoDO,INVOICE_TITLE_NO_EXIST);
|
||||
|
||||
return CommonResult.success(BeanUtils.toBean(invoiceTitleInfoDO,InvoiceTitleInfoDTO.class));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private OrganAmountDO validateOrganAmountExists(Long organId) {
|
||||
|
||||
OrganAmountDO organAmountDO = organAmountMapper.selectOne(new LambdaUpdateWrapper<OrganAmountDO>()
|
||||
.eq(OrganAmountDO::getOrganId, organId)
|
||||
.eq(OrganAmountDO::getDeleted, false));
|
||||
|
||||
AssertUtils.notEmpty(organAmountDO,ORGAN_AMOUNT_NO_EXIST);
|
||||
|
||||
return organAmountDO;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+22
@@ -3,9 +3,12 @@ package com.cf.imes.module.system.api.organ;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.cf.imes.framework.common.enums.OrderStatisticsUnit;
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.module.system.api.organ.dto.OrgStatisticsIsLapseRespDTO;
|
||||
import com.cf.imes.module.system.api.organ.dto.OrgStatisticsReqDTO;
|
||||
import com.cf.imes.module.system.api.organ.dto.OrganizationDTO;
|
||||
import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganRespVO;
|
||||
import com.cf.imes.module.system.dal.mysql.organ.OrganMapper;
|
||||
import com.cf.imes.module.system.service.organ.OrganService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -27,6 +30,11 @@ public class OrganApiImpl implements OrganApi {
|
||||
@Resource
|
||||
private OrganService organService;
|
||||
|
||||
|
||||
@Resource
|
||||
private OrganMapper organMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public CommonResult<List<Long>> getOrganIdList() {
|
||||
return success(organService.getOrganIdList());
|
||||
@@ -107,6 +115,20 @@ public class OrganApiImpl implements OrganApi {
|
||||
return success(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<OrganizationDTO> getOrganDetails(Long organId) {
|
||||
|
||||
return success(BeanUtils.toBean(organService.validOrgan(organId),OrganizationDTO.class));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommonResult<List<OrganizationDTO>> getOrganDetailsByName(String organName) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private void setOrgStatisticsReqVO(OrgStatisticsReqDTO reqVO){
|
||||
if (ObjectUtil.isNull(reqVO.getUnit())){
|
||||
reqVO.setUnit(OrderStatisticsUnit.DAY.getValue());
|
||||
|
||||
-106
@@ -1,106 +0,0 @@
|
||||
package com.cf.imes.module.system.controller.admin.advertisement;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.module.system.controller.admin.advertisement.vo.AdvertisementPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.advertisement.vo.AdvertisementRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.advertisement.vo.AdvertisementSaveReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.advertisement.AdvertisementDO;
|
||||
import com.cf.imes.module.system.enums.advertisement.AdvertisementStatusEnum;
|
||||
import com.cf.imes.module.system.service.advertisement.AdvertisementService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 广告管理")
|
||||
@RestController
|
||||
@RequestMapping("/system/ad")
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class AdvertisementController {
|
||||
|
||||
@Resource
|
||||
private AdvertisementService advertisementService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "新建广告")
|
||||
@PreAuthorize("@ss.hasPermission('base:advertisement:create')")
|
||||
public CommonResult<Long> createAdvertisement(@Valid @RequestBody AdvertisementSaveReqVO createReqVO) {
|
||||
return success(advertisementService.create(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新广告")
|
||||
@PreAuthorize("@ss.hasPermission('base:advertisement:update')")
|
||||
public CommonResult<Boolean> updateAdvertisement(@Valid @RequestBody AdvertisementSaveReqVO updateReqVO) {
|
||||
AdvertisementDO productsDO = BeanUtils.toBean(updateReqVO, AdvertisementDO.class);
|
||||
advertisementService.update(productsDO, 0);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除广告")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('base:advertisement:delete')")
|
||||
public CommonResult<Boolean> deleteAdvertisement(@RequestParam("id") Long id) {
|
||||
advertisementService.delete(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得广告")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('base:advertisement:query')")
|
||||
public CommonResult<AdvertisementRespVO> getAdvertisement(@RequestParam("id") Long id) {
|
||||
AdvertisementDO productRespVO = advertisementService.get(id);
|
||||
return success(BeanUtils.toBean(productRespVO, AdvertisementRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得广告分页")
|
||||
@PreAuthorize("@ss.hasPermission('base:advertisement:query')")
|
||||
public CommonResult<PageResult<AdvertisementSaveReqVO>> getAdvertisementPage(@Valid AdvertisementPageReqVO pageReqVO) {
|
||||
PageResult<AdvertisementDO> pageResult = advertisementService.getPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, AdvertisementSaveReqVO.class));
|
||||
}
|
||||
|
||||
@PutMapping("/published")
|
||||
@Operation(summary = "结束发布广告")
|
||||
@Parameter(name = "id", description = "广告id", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('base:advertisement:update')")
|
||||
public CommonResult<Boolean> published(@RequestParam("id") Long id) {
|
||||
advertisementService.update(id, AdvertisementStatusEnum.ENDED.getStatus());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/publishing")
|
||||
@Operation(summary = "立即发布广告")
|
||||
@PreAuthorize("@ss.hasPermission('base:advertisement:update')")
|
||||
@Parameter(name = "id", description = "广告id", required = true)
|
||||
public CommonResult<Boolean> publishing(@RequestParam("id") Long id) {
|
||||
advertisementService.update(id,AdvertisementStatusEnum.PUBLISHED.getStatus());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/republish")
|
||||
@Operation(summary = "重新发布广告")
|
||||
@Parameter(name = "id", description = "广告id", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('base:advertisement:update')")
|
||||
public CommonResult<Boolean> republish(@Valid @RequestBody AdvertisementSaveReqVO updateReqVO) {
|
||||
AdvertisementDO productsDO = BeanUtils.toBean(updateReqVO, AdvertisementDO.class);
|
||||
advertisementService.update(productsDO, 1);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
-65
@@ -1,65 +0,0 @@
|
||||
package com.cf.imes.module.system.controller.admin.advertisement.vo;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageParam;
|
||||
import com.cf.imes.module.system.validation.advertisement.AdvertisementStatus;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 广告分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class AdvertisementPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "广告id", example = "163681486581530624")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "广告名称", example = "西亚哈")
|
||||
private String adName;
|
||||
|
||||
@Schema(description = "软件标识", example = "163681481946824704")
|
||||
private String softwareId;
|
||||
|
||||
@Schema(description = "广告位置")
|
||||
private String adPosition;
|
||||
|
||||
@Schema(description = "广告图片")
|
||||
private String adImagePath;
|
||||
|
||||
@Schema(description = "投放开始时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] startTime;
|
||||
|
||||
@Schema(description = "投放结束时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] endTime;
|
||||
|
||||
@Schema(description = "跳转路径")
|
||||
private String adRedirectUrl;
|
||||
|
||||
@Schema(description = "广告顺序")
|
||||
private Short sort;
|
||||
|
||||
@Schema(description = "广告状态", example = "0全部 1未发布 2已发布 3已结束")
|
||||
@AdvertisementStatus
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "操作人")
|
||||
private String updater;
|
||||
|
||||
@Schema(description = "操作时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@Schema(description = "排序", example = "ascend")
|
||||
private String order;
|
||||
|
||||
@Schema(description = "排序字段", example = "id")
|
||||
private String field;
|
||||
}
|
||||
+164
@@ -0,0 +1,164 @@
|
||||
package com.cf.imes.module.system.controller.admin.funds.advertisement;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.module.system.controller.admin.funds.advertisement.vo.AdvertisementPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.advertisement.vo.AdvertisementPublishReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.advertisement.vo.AdvertisementRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.advertisement.vo.AdvertisementSaveReqVO;
|
||||
import com.cf.imes.module.system.service.funds.advertisement.AdvertisementService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.ADVERTISEMENT_STATUS_ERROR;
|
||||
|
||||
@Tag(name = "管理后台 - 广告管理")
|
||||
@RestController
|
||||
@RequestMapping("/system/ad")
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class AdvertisementController {
|
||||
|
||||
@Resource
|
||||
private AdvertisementService advertisementService;
|
||||
|
||||
|
||||
@PostMapping("")
|
||||
@Operation(summary = "新建广告")
|
||||
@PreAuthorize("@ss.hasPermission('base:advertisement:create')")
|
||||
public CommonResult<Long> createAdvertisement(@Valid @RequestBody AdvertisementSaveReqVO createReqVO) {
|
||||
return success(advertisementService.create(createReqVO));
|
||||
}
|
||||
|
||||
|
||||
@PutMapping("")
|
||||
@Operation(summary = "更新广告")
|
||||
@PreAuthorize("@ss.hasPermission('base:advertisement:update')")
|
||||
public CommonResult<Boolean> updateAdvertisement(@Valid @RequestBody AdvertisementSaveReqVO reqVO) {
|
||||
advertisementService.update(reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
@DeleteMapping("")
|
||||
@Operation(summary = "删除广告")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('base:advertisement:delete')")
|
||||
public CommonResult<Boolean> deleteAdvertisement(@RequestParam("id") Long id) {
|
||||
advertisementService.delete(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/{id}")
|
||||
@Operation(summary = "获得广告")
|
||||
@Parameter(name = "id", description = "广告ID", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('base:advertisement:query')")
|
||||
public CommonResult<AdvertisementRespVO> getAdvertisement(@PathVariable("id") Long id) {
|
||||
|
||||
return success(advertisementService.get(id));
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得广告分页")
|
||||
@PreAuthorize("@ss.hasPermission('base:advertisement:query')")
|
||||
public CommonResult<PageResult<AdvertisementRespVO>> getAdvertisementPage(@Valid AdvertisementPageReqVO pageReqVO) {
|
||||
|
||||
return success(advertisementService.getPage(pageReqVO));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PutMapping("/publish")
|
||||
@Operation(summary = "发布/结束/重新发布广告")
|
||||
@Parameter(name = "id", description = "广告id", required = true)
|
||||
@Parameter(name = "status", description = "广告状态", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('base:advertisement:update')")
|
||||
public CommonResult<Boolean> updatePublishStatus(@RequestBody AdvertisementPublishReqVO reqVO) {
|
||||
advertisementService.updatePublishStatus(reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@GetMapping("/getAd")
|
||||
@Operation(summary = "根据广告位置获得广告信息")
|
||||
@PreAuthorize("@ss.hasPermission('base:advertisement:query')")
|
||||
public CommonResult<List<AdvertisementRespVO>> getAdvertisementByPosition(@RequestParam("id") Integer adPosition) {
|
||||
|
||||
return success(advertisementService.getAdvertisementByPosition(adPosition));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 上传图片,支持附带 orderId 参数
|
||||
@PostMapping("/upload")
|
||||
public CommonResult<String> uploadImage(@RequestParam("file") MultipartFile file,
|
||||
@RequestParam("orderId") Long orderId) {
|
||||
|
||||
try {
|
||||
|
||||
|
||||
// 获取原始文件名并提取扩展名
|
||||
String originalFilename = file.getOriginalFilename();
|
||||
String extension = "";
|
||||
|
||||
int dotIndex = originalFilename.lastIndexOf('.');
|
||||
if (dotIndex != -1) {
|
||||
extension = originalFilename.substring(dotIndex); // 包含“.”
|
||||
} else {
|
||||
throw exception(1,"缺少扩展名");
|
||||
}
|
||||
|
||||
// 构建新文件名: orderId + .扩展名
|
||||
String filename = orderId + extension;
|
||||
|
||||
// 确保目录存在
|
||||
File dir = new File("E:\\ceshi123\\");
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
|
||||
|
||||
File dest = new File(dir, filename);
|
||||
file.transferTo(dest);
|
||||
|
||||
|
||||
// 你可以把图片信息和 orderId 一起存入数据库,这里省略
|
||||
return success("上传成功: " + filename);
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage());
|
||||
throw exception(ADVERTISEMENT_STATUS_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.cf.imes.module.system.controller.admin.funds.advertisement.vo;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Getter
|
||||
@Data
|
||||
public class AdImageFilePath {
|
||||
|
||||
@Value("${adImageFile.filepath}")
|
||||
private String filePath;
|
||||
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.cf.imes.module.system.controller.admin.funds.advertisement.vo;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageParam;
|
||||
import com.cf.imes.module.system.validation.advertisement.AdvertisementStatus;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - 广告分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class AdvertisementPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "广告id", example = "163681486581530624")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "广告名称", example = "西亚哈")
|
||||
private String adName;
|
||||
|
||||
@Schema(description = "广告位置")
|
||||
private String adPosition;
|
||||
|
||||
@Schema(description = "广告状态", example = "0全部 1未发布 2已发布 3已结束")
|
||||
@AdvertisementStatus
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.cf.imes.module.system.controller.admin.funds.advertisement.vo;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Schema(description = "广告发布状态")
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class AdvertisementPublishReqVO {
|
||||
|
||||
|
||||
@Schema(description = "广告id")
|
||||
private Long id;
|
||||
|
||||
|
||||
@Schema(description = "发布状态")
|
||||
private Integer status;
|
||||
|
||||
|
||||
@Schema(description = "是否重新发布",example = "false")
|
||||
private Boolean isRepublish;
|
||||
|
||||
|
||||
@Schema(description = "投放开始时间,重新发布时传")
|
||||
private LocalDate startTime;
|
||||
|
||||
|
||||
@Schema(description = "投放结束时间,重新发布时传")
|
||||
private LocalDate endTime;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+19
-3
@@ -1,4 +1,4 @@
|
||||
package com.cf.imes.module.system.controller.admin.advertisement.vo;
|
||||
package com.cf.imes.module.system.controller.admin.funds.advertisement.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@@ -12,7 +12,7 @@ import java.time.LocalDateTime;
|
||||
public class AdvertisementRespVO {
|
||||
|
||||
@Schema(description = "广告id", requiredMode = Schema.RequiredMode.REQUIRED, example = "163681486581530624")
|
||||
private int id;
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "广告名称", example = "西亚哈")
|
||||
private String adName;
|
||||
@@ -23,19 +23,35 @@ public class AdvertisementRespVO {
|
||||
@Schema(description = "图片路径")
|
||||
private String adImagePath;
|
||||
|
||||
@Schema(description = "图片的Base64形式")
|
||||
private String adImageBase64;
|
||||
|
||||
@Schema(description = "图片的类型")
|
||||
private String adImageFileType;
|
||||
|
||||
@Schema(description = "投放开始时间")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@Schema(description = "投放结束时间")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@Schema(description = "投放时间")
|
||||
private String launchTime;
|
||||
|
||||
@Schema(description = "跳转路径")
|
||||
private String adRedirectUrl;
|
||||
|
||||
@Schema(description = "广告顺序")
|
||||
private Short sort;
|
||||
|
||||
@Schema(description = "广告状态", example = "0全部 1未发布 2已发布 3已结束")
|
||||
@Schema(description = "广告状态", example = " 0未发布 1已发布 2已结束")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "操作人")
|
||||
private String creator;
|
||||
|
||||
@Schema(description = "操作时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
|
||||
}
|
||||
+26
-11
@@ -1,57 +1,72 @@
|
||||
package com.cf.imes.module.system.controller.admin.advertisement.vo;
|
||||
package com.cf.imes.module.system.controller.admin.funds.advertisement.vo;
|
||||
|
||||
import com.cf.imes.framework.common.validation.NumberValid;
|
||||
import com.cf.imes.module.system.validation.advertisement.AdvertisementStatus;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDate;
|
||||
|
||||
import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
|
||||
|
||||
@Schema(description = "管理后台 - 广告新增/修改 Request VO")
|
||||
@Data
|
||||
public class AdvertisementSaveReqVO {
|
||||
|
||||
@Schema(description = "广告id", example = "1")
|
||||
@Schema(description = "广告id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "广告名称", example = "西亚哈")
|
||||
|
||||
@Schema(description = "广告名称")
|
||||
@NotBlank(message = "广告名称不能为空")
|
||||
@Size(max = 32, message = "广告名称长度不能超过 32 个字符")
|
||||
private String adName;
|
||||
|
||||
@Schema(description = "软件标识", example = "163681481946824704")
|
||||
|
||||
@Schema(description = "软件标识")
|
||||
private String softwareId;
|
||||
|
||||
|
||||
@Schema(description = "广告位置,字典键值", example = "[1,2]")
|
||||
@NotNull(message = "广告位置不能为空")
|
||||
private Integer[] adPosition;
|
||||
|
||||
@Schema(description = "广告图片")
|
||||
@NotBlank(message = "广告图片不能为空")
|
||||
@Size(max = 255, message = "广告图片长度不能超过 255 个字符")
|
||||
private String adImagePath;
|
||||
|
||||
@Schema(description = "广告图片文件")
|
||||
@NotBlank(message = "广告图片文件不能为空")
|
||||
private MultipartFile adImageFile;
|
||||
|
||||
|
||||
@Schema(description = "投放开始时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
@NotNull(message = "投放开始时间不能为空")
|
||||
private LocalDateTime startTime;
|
||||
private LocalDate startTime;
|
||||
|
||||
|
||||
@Schema(description = "投放结束时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
@NotNull(message = "投放结束时间不能为空")
|
||||
private LocalDateTime endTime;
|
||||
private LocalDate endTime;
|
||||
|
||||
|
||||
@Schema(description = "跳转路径")
|
||||
@Size(max = 255, message = "链接长度不能超过 255 个字符")
|
||||
private String adRedirectUrl;
|
||||
|
||||
|
||||
@Schema(description = "广告顺序")
|
||||
@NumberValid(name = "广告顺序")
|
||||
private Integer sort;
|
||||
|
||||
|
||||
@Schema(description = "广告状态", example = "0全部 1未发布 2已发布 3已结束")
|
||||
@AdvertisementStatus
|
||||
private Integer status;
|
||||
|
||||
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.cf.imes.module.system.controller.admin.funds.invoice;
|
||||
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.module.system.controller.admin.funds.invoice.vo.InvoiceTitleReqVO;
|
||||
import com.cf.imes.module.system.service.funds.invoice.InvoiceService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||
|
||||
|
||||
/**
|
||||
* @author 发票管理
|
||||
*/
|
||||
@Tag(name = "管理后台 - 发票管理")
|
||||
@RestController
|
||||
@RequestMapping("/system/invoice")
|
||||
@Validated
|
||||
public class InvoiceController {
|
||||
|
||||
|
||||
@Resource
|
||||
private InvoiceService invoiceService;
|
||||
|
||||
|
||||
@PostMapping("")
|
||||
@Operation(summary = "新增/修改发票抬头信息")
|
||||
public CommonResult<Boolean> insetInvoiceTitle(@Valid @RequestBody InvoiceTitleReqVO reqVO) {
|
||||
|
||||
invoiceService.insetInvoiceTitle(reqVO);
|
||||
|
||||
return success(Boolean.TRUE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
package com.cf.imes.module.system.controller.admin.funds.invoice.vo;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class InvoiceTitleReqVO {
|
||||
|
||||
|
||||
@Schema(description = "发票抬头ID")
|
||||
private Long id;
|
||||
|
||||
|
||||
@Schema(description = "组织ID")
|
||||
private Long organId;
|
||||
|
||||
|
||||
@Schema(description = "发票抬头")
|
||||
@NotBlank(message = "发票抬头不能为空")
|
||||
private String invoiceTitle;
|
||||
|
||||
|
||||
@Schema(description = "开具类型,0企业 1个人")
|
||||
@NotNull(message = "开具类型不能为空")
|
||||
private Integer issueType;
|
||||
|
||||
|
||||
@Schema(description = "发票类型,0增值税普通发票 1增值税专用发票")
|
||||
@NotNull(message = "发票类型不能为空")
|
||||
private Integer invoiceType;
|
||||
|
||||
|
||||
@Schema(description = "纳税人识别号")
|
||||
@NotNull(message = "纳税人识别号不能为空")
|
||||
private String taxpayerId;
|
||||
|
||||
|
||||
@Schema(description = "开户银行名称")
|
||||
private String bankName;
|
||||
|
||||
|
||||
@Schema(description = "开户银行账号")
|
||||
private String bankAccount;
|
||||
|
||||
|
||||
@Schema(description = "注册场所地址")
|
||||
private String registeredAddress;
|
||||
|
||||
|
||||
@Schema(description = "注册固定电话")
|
||||
private String fixedPhone;
|
||||
|
||||
|
||||
@Schema(description = "邮箱")
|
||||
@NotNull(message = "邮箱不能为空")
|
||||
private String email;
|
||||
|
||||
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
package com.cf.imes.module.system.controller.admin.funds.organamount;
|
||||
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.module.system.controller.admin.funds.organamount.vo.AllOrganAmountRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.organamount.vo.OrganAmountRespVO;
|
||||
import com.cf.imes.module.system.service.funds.organamount.OrganAmountService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* @author 组织资金
|
||||
*/
|
||||
@Tag(name = "管理后台 - 组织资金")
|
||||
@RestController
|
||||
@RequestMapping("/system/amount")
|
||||
@Validated
|
||||
public class OrganAmountController {
|
||||
|
||||
|
||||
@Resource
|
||||
private OrganAmountService organAmountService;
|
||||
|
||||
|
||||
|
||||
@GetMapping("")
|
||||
@Operation(summary = "获取组织余额数据")
|
||||
@Parameter(name = "organId", description = "组织ID", required = true)
|
||||
public CommonResult<OrganAmountRespVO> getOrganAmount(@Valid @RequestParam("organId") Long organId) {
|
||||
|
||||
return success(organAmountService.getOrganAmount(organId));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@GetMapping("/all")
|
||||
@Operation(summary = "获取全部组织的余额数据")
|
||||
public CommonResult<AllOrganAmountRespVO> getOrganAmountAll() {
|
||||
|
||||
return success(organAmountService.getOrganAmountAll());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.cf.imes.module.system.controller.admin.funds.organamount.vo;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Schema(description = "管理后台 - 所有组织的余额信息 Response VO")
|
||||
@Data
|
||||
public class AllOrganAmountRespVO {
|
||||
|
||||
|
||||
@Schema(description = "所有组织的余额")
|
||||
private BigDecimal allOrganAmount;
|
||||
|
||||
|
||||
@Schema(description = "待审核的发票金额")
|
||||
private BigDecimal toExamineAmount;
|
||||
|
||||
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.cf.imes.module.system.controller.admin.funds.organamount.vo;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Schema(description = "管理后台 - 组织余额信息 Response VO")
|
||||
@Data
|
||||
public class OrganAmountRespVO {
|
||||
|
||||
|
||||
@Schema(description = "可用总金额")
|
||||
private BigDecimal availableAmount;
|
||||
|
||||
|
||||
@Schema(description = "现金余额")
|
||||
private BigDecimal amount;
|
||||
|
||||
|
||||
@Schema(description = "赠送金余额")
|
||||
private BigDecimal giftAmount;
|
||||
|
||||
|
||||
@Schema(description = "可开票金额")
|
||||
private BigDecimal invoiceableAmount;
|
||||
|
||||
}
|
||||
|
||||
+11
-11
@@ -1,13 +1,13 @@
|
||||
package com.cf.imes.module.system.controller.admin.products;
|
||||
package com.cf.imes.module.system.controller.admin.funds.products;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.module.system.controller.admin.products.vo.product.ProductPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.products.vo.product.ProductRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.products.vo.product.ProductSaveReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.products.ProductsDO;
|
||||
import com.cf.imes.module.system.service.products.ProductsService;
|
||||
import com.cf.imes.module.system.controller.admin.funds.products.vo.product.ProductPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.products.vo.product.ProductRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.products.vo.product.ProductSaveReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.products.ProductsDO;
|
||||
import com.cf.imes.module.system.service.funds.products.ProductsService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -30,14 +30,14 @@ public class ProductsController {
|
||||
@Resource
|
||||
private ProductsService productsService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@PostMapping("")
|
||||
@Operation(summary = "新建产品")
|
||||
// @PreAuthorize("@ss.hasPermission('base:products:create')")
|
||||
public CommonResult<Long> createProducts(@RequestParam("productName") String productName) {
|
||||
return success(productsService.create(productName));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@PutMapping("")
|
||||
@Operation(summary = "更新产品")
|
||||
// @PreAuthorize("@ss.hasPermission('base:products:update')")
|
||||
public CommonResult<Boolean> updateProducts(@Valid @RequestBody ProductSaveReqVO updateReqVO) {
|
||||
@@ -65,7 +65,7 @@ public class ProductsController {
|
||||
}
|
||||
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@DeleteMapping("")
|
||||
@Operation(summary = "删除产品")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('base:products:delete')")
|
||||
@@ -74,11 +74,11 @@ public class ProductsController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@GetMapping("/{id}")
|
||||
@Operation(summary = "获得产品")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('base:products:query')")
|
||||
public CommonResult<ProductRespVO> getProducts(@RequestParam("id") Long id) {
|
||||
public CommonResult<ProductRespVO> getProducts(@PathVariable("id") Long id) {
|
||||
ProductsDO productRespVO = productsService.get(id);
|
||||
return success(BeanUtils.toBean(productRespVO, ProductRespVO.class));
|
||||
}
|
||||
+11
-11
@@ -1,13 +1,13 @@
|
||||
package com.cf.imes.module.system.controller.admin.products;
|
||||
package com.cf.imes.module.system.controller.admin.funds.products;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.module.system.controller.admin.products.vo.productDetails.ProductDetailsPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.products.vo.productDetails.ProductDetailsRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.products.vo.productDetails.ProductDetailsSaveReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.products.ProductsDetailDO;
|
||||
import com.cf.imes.module.system.service.products.ProductsDetailService;
|
||||
import com.cf.imes.module.system.controller.admin.funds.products.vo.productDetails.ProductDetailsPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.products.vo.productDetails.ProductDetailsRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.products.vo.productDetails.ProductDetailsSaveReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.products.ProductsDetailDO;
|
||||
import com.cf.imes.module.system.service.funds.products.ProductsDetailService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -30,14 +30,14 @@ public class ProductsDetailController {
|
||||
@Resource
|
||||
private ProductsDetailService productDetailsService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@PostMapping("")
|
||||
@Operation(summary = "新建产品明细")
|
||||
@PreAuthorize("@ss.hasPermission('base:productDetails:create')")
|
||||
public CommonResult<Long> createProducts(@Valid @RequestBody ProductDetailsSaveReqVO createReqVO) {
|
||||
return success(productDetailsService.create(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@PutMapping("")
|
||||
@Operation(summary = "更新产品明细")
|
||||
@PreAuthorize("@ss.hasPermission('base:productDetails:update')")
|
||||
public CommonResult<Boolean> updateProducts(@Valid @RequestBody ProductDetailsSaveReqVO updateReqVO) {
|
||||
@@ -45,7 +45,7 @@ public class ProductsDetailController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@DeleteMapping("")
|
||||
@Operation(summary = "删除产品明细")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('base:productDetails:delete')")
|
||||
@@ -54,11 +54,11 @@ public class ProductsDetailController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@GetMapping("/{id}")
|
||||
@Operation(summary = "获得产品明细")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('base:productDetails:query')")
|
||||
public CommonResult<List<ProductsDetailDO>> getProducts(@RequestParam("id") Long id) {
|
||||
public CommonResult<List<ProductsDetailDO>> getProducts(@PathVariable("id") Long id) {
|
||||
List<ProductsDetailDO> productDetailsDO = productDetailsService.get(id);
|
||||
return success(productDetailsDO);
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cf.imes.module.system.controller.admin.products.vo.product;
|
||||
package com.cf.imes.module.system.controller.admin.funds.products.vo.product;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageParam;
|
||||
import com.cf.imes.module.system.validation.products.ProductStatus;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cf.imes.module.system.controller.admin.products.vo.product;
|
||||
package com.cf.imes.module.system.controller.admin.funds.products.vo.product;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cf.imes.module.system.controller.admin.products.vo.product;
|
||||
package com.cf.imes.module.system.controller.admin.funds.products.vo.product;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cf.imes.module.system.controller.admin.products.vo.productDetails;
|
||||
package com.cf.imes.module.system.controller.admin.funds.products.vo.productDetails;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageParam;
|
||||
import com.cf.imes.module.system.validation.products.ProductType;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cf.imes.module.system.controller.admin.products.vo.productDetails;
|
||||
package com.cf.imes.module.system.controller.admin.funds.products.vo.productDetails;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
package com.cf.imes.module.system.controller.admin.products.vo.productDetails;
|
||||
package com.cf.imes.module.system.controller.admin.funds.products.vo.productDetails;
|
||||
|
||||
import com.cf.imes.module.system.validation.products.ProductType;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@@ -23,13 +23,13 @@ public class ProductDetailsSaveReqVO {
|
||||
@ProductType
|
||||
private Integer purchaseType;
|
||||
|
||||
@Schema(description = "产品时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "1month")
|
||||
@Schema(description = "产品时间,格式:时长值 - 时间单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "1month")
|
||||
private String duration;
|
||||
|
||||
@Schema(description = "产品产量", requiredMode = Schema.RequiredMode.REQUIRED, example = "")
|
||||
private BigDecimal output;
|
||||
|
||||
@Schema(description = "赠送时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "半个月")
|
||||
//
|
||||
@Schema(description = "赠送时间,格式:时长值 - 时间单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "半个月")
|
||||
private String giftDuration;
|
||||
|
||||
@Schema(description = "赠送产量", requiredMode = Schema.RequiredMode.REQUIRED, example = "")
|
||||
+11
-11
@@ -1,13 +1,13 @@
|
||||
package com.cf.imes.module.system.controller.admin.recharge;
|
||||
package com.cf.imes.module.system.controller.admin.funds.recharge;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.module.system.controller.admin.recharge.vo.RechargePageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.recharge.vo.RechargeRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.recharge.vo.RechargeSaveReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.recharge.GiftMoneyDetailsDO;
|
||||
import com.cf.imes.module.system.service.recharge.RechargeActiveService;
|
||||
import com.cf.imes.module.system.controller.admin.funds.recharge.vo.RechargePageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.recharge.vo.RechargeRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.recharge.vo.RechargeSaveReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.recharge.GiftMoneyDetailsDO;
|
||||
import com.cf.imes.module.system.service.funds.recharge.RechargeActiveService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -29,14 +29,14 @@ public class RechargeActiveController {
|
||||
@Resource
|
||||
private RechargeActiveService productsService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@PostMapping("")
|
||||
@Operation(summary = "新建充值活动")
|
||||
@PreAuthorize("@ss.hasPermission('base:recharge-active:create')")
|
||||
public CommonResult<Long> createRechargeActive(@Valid @RequestBody RechargeSaveReqVO createReqVO) {
|
||||
return success(productsService.create(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@PutMapping("")
|
||||
@Operation(summary = "更新充值活动")
|
||||
@PreAuthorize("@ss.hasPermission('base:recharge-active:update')")
|
||||
public CommonResult<Boolean> updateRechargeActive(@Valid @RequestBody RechargeSaveReqVO updateReqVO) {
|
||||
@@ -44,7 +44,7 @@ public class RechargeActiveController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@DeleteMapping("")
|
||||
@Operation(summary = "删除充值活动")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('base:recharge-active:delete')")
|
||||
@@ -53,11 +53,11 @@ public class RechargeActiveController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@GetMapping("/{id}")
|
||||
@Operation(summary = "获得充值活动")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('base:recharge-active:query')")
|
||||
public CommonResult<RechargeRespVO> getRechargeActive(@RequestParam("id") Long id) {
|
||||
public CommonResult<RechargeRespVO> getRechargeActive(@PathVariable("id") Long id) {
|
||||
GiftMoneyDetailsDO giftMoneyDetailsDO = productsService.get(id);
|
||||
return success(BeanUtils.toBean(giftMoneyDetailsDO, RechargeRespVO.class));
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cf.imes.module.system.controller.admin.recharge.vo;
|
||||
package com.cf.imes.module.system.controller.admin.funds.recharge.vo;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageParam;
|
||||
import com.cf.imes.module.system.validation.recharge.PurchaseType;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cf.imes.module.system.controller.admin.recharge.vo;
|
||||
package com.cf.imes.module.system.controller.admin.funds.recharge.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cf.imes.module.system.controller.admin.recharge.vo;
|
||||
package com.cf.imes.module.system.controller.admin.funds.recharge.vo;
|
||||
|
||||
import com.cf.imes.module.system.validation.recharge.MoneyValid;
|
||||
import com.cf.imes.module.system.validation.recharge.PurchaseType;
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
package com.cf.imes.module.system.controller.admin.parser;
|
||||
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.module.system.controller.admin.parser.vo.ParserReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.parser.vo.ParserRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.parser.vo.ParserSimpleRespVO;
|
||||
import com.cf.imes.module.system.service.parser.ParserService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 解析器管理")
|
||||
@RestController
|
||||
@RequestMapping("/system/parser")
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class ParserController {
|
||||
|
||||
|
||||
|
||||
@Resource
|
||||
private ParserService parserService;
|
||||
|
||||
|
||||
|
||||
|
||||
@PutMapping("")
|
||||
@Operation(summary = "解析器配置修改")
|
||||
@PreAuthorize("@ss.hasPermission('base:advertisement:update')")
|
||||
public CommonResult<Boolean> updateParser(@Valid @RequestBody ParserReqVO reqVO) {
|
||||
parserService.update(reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@GetMapping("")
|
||||
@Operation(summary = "获得解析器树")
|
||||
@PreAuthorize("@ss.hasAnyPermissions('system:machine:query','system:base-setting')")
|
||||
public CommonResult<Map<Integer, List<ParserRespVO>>> getParserTree(@RequestParam(required = false) Long type) {
|
||||
return success(parserService.getParserTree(type));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/simple")
|
||||
@Operation(summary = "获得解析器对应的精简信息")
|
||||
public CommonResult<Map<Integer, List<ParserSimpleRespVO>>> getParserSimple(@RequestParam(required = false) Long type) {
|
||||
return success(parserService.getParserSimple(type));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@GetMapping("/{id}")
|
||||
@Operation(summary = "根据ID获取解析器信息")
|
||||
@Parameter(name = "id", description = "解析器ID", required = true)
|
||||
public CommonResult<ParserRespVO> getParser(@PathVariable("id") Long id) {
|
||||
return success(parserService.getParser(id));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
package com.cf.imes.module.system.controller.admin.parser;
|
||||
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.module.system.controller.admin.parser.vo.ParserTemplateReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.parser.vo.ParserTemplateRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.parser.vo.TemplateLimitReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.parser.vo.TemplateSimpleRespVO;
|
||||
import com.cf.imes.module.system.service.parser.ParserTemplateService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/system/parser-template")
|
||||
@Tag(name = "管理后台 - 解析器模板管理")
|
||||
@Validated
|
||||
public class ParserTemplateController {
|
||||
|
||||
|
||||
@Resource
|
||||
private ParserTemplateService parserTemplateService;
|
||||
|
||||
|
||||
@PutMapping("")
|
||||
@Operation(summary = "解析器模板配置修改")
|
||||
public CommonResult<Boolean> updateParserTemplate(@Valid @RequestBody ParserTemplateReqVO reqVO) {
|
||||
parserTemplateService.update(reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@GetMapping("")
|
||||
@Operation(summary = "获得解析器模板树")
|
||||
public CommonResult<Map<Integer, List<ParserTemplateRespVO>>> getParserTemplateTree(@RequestParam(required = false) Long type) {
|
||||
return success(parserTemplateService.getParserTemplateTree(type));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@GetMapping("/simple")
|
||||
@Operation(summary = "获得解析对应的精简信息")
|
||||
public CommonResult<Map<Integer, List<TemplateSimpleRespVO>>> getParserTemplateSimple(@RequestParam(required = false) Long type) {
|
||||
return success(parserTemplateService.getParserTemplateSimple(type));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@GetMapping("/{id}")
|
||||
@Operation(summary = "根据ID获取解析器模板信息")
|
||||
@Parameter(name = "id", description = "解析器ID", required = true)
|
||||
public CommonResult<ParserTemplateRespVO> getParserTemplate(@PathVariable("id") Long id) {
|
||||
return success(parserTemplateService.getParserTemplate(id));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PutMapping("/limit")
|
||||
@Operation(summary = "修改解析器模板的授权信息")
|
||||
public CommonResult<Boolean> updateParserTemplateLimit(@Valid @RequestBody TemplateLimitReqVO reqVO) {
|
||||
parserTemplateService.updateParserTemplateLimit(reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@GetMapping("/limit/{organId}")
|
||||
@Operation(summary = "获取组织对应的解析器模板的授权信息")
|
||||
@Parameter(name = "organId", description = "解析器ID", required = true)
|
||||
public CommonResult<List<Long>> getOrganParserTemplateLimit(@PathVariable("organId") Long organId) {
|
||||
return success(parserTemplateService.getOrganParserTemplateLimit(organId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.cf.imes.module.system.controller.admin.parser.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "管理后台 - 解析器修改 Request VO")
|
||||
@Data
|
||||
public class ParserReqVO {
|
||||
|
||||
|
||||
@Schema(description = "解析器id")
|
||||
private Long id;
|
||||
|
||||
|
||||
@Schema(description = "解析器名称")
|
||||
private String name;
|
||||
|
||||
|
||||
@Schema(description = "解析器类型")
|
||||
private Integer parserType;
|
||||
|
||||
|
||||
@Schema(description = "解析器配置")
|
||||
private String setting;
|
||||
|
||||
|
||||
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.cf.imes.module.system.controller.admin.parser.vo;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ParserRespVO {
|
||||
|
||||
|
||||
@Schema(description = "解析器id")
|
||||
private Long id;
|
||||
|
||||
|
||||
@Schema(description = "解析器名称")
|
||||
private String name;
|
||||
|
||||
|
||||
@Schema(description = "解析器类型")
|
||||
private Integer parserType;
|
||||
|
||||
|
||||
@Schema(description = "解析器配置")
|
||||
private String setting;
|
||||
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.cf.imes.module.system.controller.admin.parser.vo;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ParserSimpleRespVO {
|
||||
|
||||
|
||||
@Schema(description = "解析器id")
|
||||
private Long id;
|
||||
|
||||
|
||||
@Schema(description = "解析器名称")
|
||||
private String name;
|
||||
|
||||
|
||||
@Schema(description = "解析器类型")
|
||||
private Integer parserType;
|
||||
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.cf.imes.module.system.controller.admin.parser.vo;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 解析器模板修改 Request VO")
|
||||
@Data
|
||||
public class ParserTemplateReqVO {
|
||||
|
||||
|
||||
@Schema(description = "解析器id")
|
||||
private Long id;
|
||||
|
||||
|
||||
@Schema(description = "解析器名称")
|
||||
private String name;
|
||||
|
||||
|
||||
@Schema(description = "解析器类型")
|
||||
private Integer parserType;
|
||||
|
||||
|
||||
@Schema(description = "解析器配置")
|
||||
private String setting;
|
||||
|
||||
|
||||
@Schema(description = "是否可用")
|
||||
private Boolean isEnabled;
|
||||
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.cf.imes.module.system.controller.admin.parser.vo;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class ParserTemplateRespVO {
|
||||
|
||||
|
||||
@Schema(description = "解析器模板id")
|
||||
private Long id;
|
||||
|
||||
|
||||
@Schema(description = "解析器模板名称")
|
||||
private String name;
|
||||
|
||||
|
||||
@Schema(description = "解析器类型")
|
||||
private Integer parserType;
|
||||
|
||||
|
||||
@Schema(description = "解析器模板配置")
|
||||
private String setting;
|
||||
|
||||
|
||||
@Schema(description = "是否可用")
|
||||
private Boolean isEnabled;
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.cf.imes.module.system.controller.admin.parser.vo;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
public class TemplateLimitReqVO {
|
||||
|
||||
|
||||
@Schema(description = "组织id")
|
||||
private Long organId;
|
||||
|
||||
|
||||
@Schema(description = "解析器ID")
|
||||
private List<Long> parserTemplateIds;
|
||||
|
||||
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.cf.imes.module.system.controller.admin.parser.vo;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TemplateSimpleRespVO {
|
||||
|
||||
|
||||
@Schema(description = "解析器模板id")
|
||||
private Long id;
|
||||
|
||||
|
||||
@Schema(description = "解析器模板名称")
|
||||
private String name;
|
||||
|
||||
|
||||
@Schema(description = "解析器类型")
|
||||
private Integer parserType;
|
||||
|
||||
|
||||
}
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
package com.cf.imes.module.system.dal.dataobject.advertisement;
|
||||
package com.cf.imes.module.system.dal.dataobject.funds.advertisement;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
@@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* 广告表 product_details DO
|
||||
@@ -48,12 +48,12 @@ public class AdvertisementDO extends BaseDO {
|
||||
/**
|
||||
* 投放开始时间
|
||||
*/
|
||||
private LocalDateTime startTime;
|
||||
private LocalDate startTime;
|
||||
|
||||
/**
|
||||
* 投放结束时间
|
||||
*/
|
||||
private LocalDateTime endTime;
|
||||
private LocalDate endTime;
|
||||
/**
|
||||
* 跳转路径
|
||||
*/
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cf.imes.module.system.dal.dataobject.advertisement;
|
||||
package com.cf.imes.module.system.dal.dataobject.funds.advertisement;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
package com.cf.imes.module.system.dal.dataobject.funds.invoice;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* @author 发票抬头信息表
|
||||
*/
|
||||
@TableName("invoice_title_info")
|
||||
@KeySequence("invoice_title_info_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class InvoiceTitleInfoDO extends BaseDO {
|
||||
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
|
||||
/**
|
||||
* 组织ID
|
||||
*/
|
||||
private Long organId;
|
||||
|
||||
|
||||
/**
|
||||
* 发票抬头
|
||||
*/
|
||||
private String invoiceTitle;
|
||||
|
||||
|
||||
/**
|
||||
* 开具类型
|
||||
*/
|
||||
private Integer issueType;
|
||||
|
||||
|
||||
/**
|
||||
* 发票类型
|
||||
*/
|
||||
private Integer invoiceType;
|
||||
|
||||
|
||||
/**
|
||||
* 纳税人识别号
|
||||
*/
|
||||
private String taxpayerId;
|
||||
|
||||
|
||||
/**
|
||||
* 开户银行名称
|
||||
*/
|
||||
private String bankName;
|
||||
|
||||
|
||||
/**
|
||||
* 开户银行账号
|
||||
*/
|
||||
private String bankAccount;
|
||||
|
||||
|
||||
/**
|
||||
* 注册场所地址
|
||||
*/
|
||||
private String registeredAddress;
|
||||
|
||||
|
||||
/**
|
||||
* 注册固定电话
|
||||
*/
|
||||
private String fixedPhone;
|
||||
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package com.cf.imes.module.system.dal.dataobject.funds.organamount;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@TableName("organ_amount")
|
||||
@KeySequence("organ_amount_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class OrganAmountDO extends BaseDO {
|
||||
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
|
||||
/**
|
||||
* 组织ID
|
||||
*/
|
||||
private Long organId;
|
||||
|
||||
|
||||
/**
|
||||
* 现金金额
|
||||
*/
|
||||
private BigDecimal amount;
|
||||
|
||||
|
||||
/**
|
||||
* 赠送金额
|
||||
*/
|
||||
private BigDecimal giftAmount;
|
||||
|
||||
|
||||
/**
|
||||
* 货币类型
|
||||
*/
|
||||
private Integer currency;
|
||||
|
||||
|
||||
/**
|
||||
* 货币单位
|
||||
*/
|
||||
private String currencyUnit;
|
||||
|
||||
|
||||
/**
|
||||
* 可开票金额
|
||||
*/
|
||||
private BigDecimal invoiceableAmount;
|
||||
|
||||
|
||||
}
|
||||
+9
-2
@@ -1,4 +1,4 @@
|
||||
package com.cf.imes.module.system.dal.dataobject.products;
|
||||
package com.cf.imes.module.system.dal.dataobject.funds.products;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
@@ -22,24 +22,31 @@ import lombok.*;
|
||||
@AllArgsConstructor
|
||||
public class ProductsDO extends BaseDO {
|
||||
|
||||
|
||||
/**
|
||||
* 产品 ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
|
||||
/**
|
||||
* 产品名称
|
||||
*/
|
||||
private String productName;
|
||||
|
||||
|
||||
/**
|
||||
* 产品状态
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
|
||||
/**
|
||||
* 软件id,不同软件的标识(用于分辩不同系统中的产品)---目前就只有一个产品
|
||||
*/
|
||||
private Integer softwareId;
|
||||
|
||||
private Boolean deleted;
|
||||
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cf.imes.module.system.dal.dataobject.products;
|
||||
package com.cf.imes.module.system.dal.dataobject.funds.products;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cf.imes.module.system.dal.dataobject.recharge;
|
||||
package com.cf.imes.module.system.dal.dataobject.funds.recharge;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package com.cf.imes.module.system.dal.dataobject.parser;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
||||
import lombok.*;
|
||||
|
||||
|
||||
/**
|
||||
* 解析器配置 DO
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
@TableName(value = "system_parser", autoResultMap = true)
|
||||
@KeySequence("system_parser_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ParserDO extends BaseDO {
|
||||
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 解析器模板ID
|
||||
*/
|
||||
private Long parserTemplateId;
|
||||
|
||||
/**
|
||||
* 解析器名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 解析器类型
|
||||
*/
|
||||
private Integer parserType;
|
||||
|
||||
/**
|
||||
* 解析器配置
|
||||
*/
|
||||
private String setting;
|
||||
|
||||
/**
|
||||
* 组织ID
|
||||
*/
|
||||
private Long organId;
|
||||
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.cf.imes.module.system.dal.dataobject.parser;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
||||
import lombok.*;
|
||||
|
||||
@TableName(value = "system_parser_limit", autoResultMap = true)
|
||||
@KeySequence("system_parser_limit_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ParserLimitDO extends BaseDO {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 组织ID
|
||||
*/
|
||||
@TableId
|
||||
private Long organId;
|
||||
|
||||
|
||||
/**
|
||||
* 解析器授权列表
|
||||
*/
|
||||
private String parserIds;
|
||||
|
||||
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package com.cf.imes.module.system.dal.dataobject.parser;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
||||
import lombok.*;
|
||||
|
||||
@TableName("system_parser_template")
|
||||
@KeySequence("system_parser_template_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ParserTemplateDO extends BaseDO {
|
||||
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 解析器名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 解析器类型
|
||||
*/
|
||||
private Integer parserType;
|
||||
|
||||
/**
|
||||
* 解析器配置
|
||||
*/
|
||||
private String setting;
|
||||
|
||||
/**
|
||||
* 是否可用
|
||||
*/
|
||||
private Boolean isEnabled;
|
||||
|
||||
|
||||
|
||||
}
|
||||
-73
@@ -1,73 +0,0 @@
|
||||
package com.cf.imes.module.system.dal.mysql.advertisement;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.system.controller.admin.advertisement.vo.AdvertisementPageReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.advertisement.AdvertisementDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 广告信息表 Mapper
|
||||
*
|
||||
* @author 晨丰科技
|
||||
*/
|
||||
@Mapper
|
||||
public interface AdvertisementMapper extends BaseMapperX<AdvertisementDO> {
|
||||
|
||||
default PageResult<AdvertisementDO> selectPage(AdvertisementPageReqVO reqVO, boolean deleted) {
|
||||
|
||||
LambdaQueryWrapperX<AdvertisementDO> queryWrapper = new LambdaQueryWrapperX<AdvertisementDO>()
|
||||
.likeIfPresent(AdvertisementDO::getAdName, reqVO.getAdName())
|
||||
.likeIfPresent(AdvertisementDO::getAdPosition, reqVO.getAdPosition())
|
||||
.eqIfPresent(AdvertisementDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(AdvertisementDO::getDeleted, deleted);
|
||||
|
||||
if (reqVO.getOrder() == null) {
|
||||
queryWrapper.orderByDesc(AdvertisementDO::getSort);
|
||||
}else {
|
||||
if (reqVO.getOrder().equals("ascend")) {
|
||||
switch (reqVO.getField()) {
|
||||
case "id" -> queryWrapper.orderByAsc(AdvertisementDO::getId);
|
||||
case "adName" -> queryWrapper.orderByAsc(AdvertisementDO::getAdName);
|
||||
case "updater" -> queryWrapper.orderByAsc(AdvertisementDO::getUpdater);
|
||||
case "updateTime" -> queryWrapper.orderByAsc(AdvertisementDO::getUpdateTime);
|
||||
default -> {
|
||||
// default不排序
|
||||
}
|
||||
}
|
||||
}else if (reqVO.getOrder().equals("descend")) {
|
||||
switch (reqVO.getField()) {
|
||||
case "id" -> queryWrapper.orderByDesc(AdvertisementDO::getId);
|
||||
case "adName" -> queryWrapper.orderByDesc(AdvertisementDO::getAdName);
|
||||
case "updater" -> queryWrapper.orderByDesc(AdvertisementDO::getUpdater);
|
||||
case "updateTime" -> queryWrapper.orderByDesc(AdvertisementDO::getUpdateTime);
|
||||
default -> {
|
||||
// default不排序
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return selectPage(reqVO, queryWrapper);
|
||||
|
||||
}
|
||||
|
||||
default int updateAdStatus(Long id, Integer newStatus) {
|
||||
return update(new LambdaUpdateWrapper<AdvertisementDO>()
|
||||
.set(AdvertisementDO::getStatus, newStatus)
|
||||
.eq(AdvertisementDO::getId, id)
|
||||
.eq(AdvertisementDO::getDeleted, false));
|
||||
}
|
||||
|
||||
default List<AdvertisementDO> selectList(LocalDateTime now, Integer status) {
|
||||
return selectList(new LambdaQueryWrapperX<AdvertisementDO>()
|
||||
.le(AdvertisementDO::getStartTime, now)
|
||||
.eq(AdvertisementDO::getStatus, status));
|
||||
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
package com.cf.imes.module.system.dal.mysql.funds.advertisement;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.system.controller.admin.funds.advertisement.vo.AdvertisementPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.advertisement.vo.AdvertisementRespVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.advertisement.AdvertisementDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 广告信息表 Mapper
|
||||
*
|
||||
* @author 晨丰科技
|
||||
*/
|
||||
@Mapper
|
||||
public interface AdvertisementMapper extends BaseMapperX<AdvertisementDO> {
|
||||
|
||||
default PageResult<AdvertisementDO> selectPage(AdvertisementPageReqVO reqVO) {
|
||||
|
||||
LambdaQueryWrapperX<AdvertisementDO> queryWrapper = new LambdaQueryWrapperX<AdvertisementDO>()
|
||||
.likeIfPresent(AdvertisementDO::getAdName, reqVO.getAdName())
|
||||
.likeIfPresent(AdvertisementDO::getAdPosition, reqVO.getAdPosition())
|
||||
.eqIfPresent(AdvertisementDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(AdvertisementDO::getDeleted, false);
|
||||
|
||||
return selectPage(reqVO, queryWrapper);
|
||||
|
||||
}
|
||||
|
||||
default int updateAdStatus(Long id, Integer newStatus) {
|
||||
return update(new LambdaUpdateWrapper<AdvertisementDO>()
|
||||
.set(AdvertisementDO::getStatus, newStatus)
|
||||
.eq(AdvertisementDO::getId, id)
|
||||
.eq(AdvertisementDO::getDeleted, false));
|
||||
}
|
||||
|
||||
default List<AdvertisementDO> selectList(LocalDateTime now, Integer status) {
|
||||
return selectList(new LambdaQueryWrapperX<AdvertisementDO>()
|
||||
.le(AdvertisementDO::getStartTime, now)
|
||||
.eq(AdvertisementDO::getStatus, status));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
default AdvertisementDO selectAdByAdName(String adName,Long id) {
|
||||
|
||||
LambdaQueryWrapperX<AdvertisementDO> queryWrapper = new LambdaQueryWrapperX<>();
|
||||
queryWrapper.eq(AdvertisementDO::getAdName, adName);
|
||||
|
||||
if(id != null){
|
||||
queryWrapper.ne(AdvertisementDO::getId, id);
|
||||
}
|
||||
|
||||
return selectOne(queryWrapper);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void updateAdStatusIsPublish(@Param("now") LocalDate now,@Param("status") Integer status);
|
||||
|
||||
|
||||
|
||||
void updateAdStatusIsEndPublished(@Param("now") LocalDate now,@Param("status") Integer status);
|
||||
|
||||
|
||||
|
||||
List<AdvertisementRespVO> selectAdList(@Param("adPosition") Integer adPosition,@Param("status") Integer status,@Param("now") LocalDate now);
|
||||
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package com.cf.imes.module.system.dal.mysql.advertisement;
|
||||
package com.cf.imes.module.system.dal.mysql.funds.advertisement;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.module.system.dal.dataobject.advertisement.AdvertisementTaskDO;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.advertisement.AdvertisementTaskDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.cf.imes.module.system.dal.mysql.funds.invoice;
|
||||
|
||||
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.invoice.InvoiceTitleInfoDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface InvoiceTitleInfoMapper extends BaseMapperX<InvoiceTitleInfoDO> {
|
||||
|
||||
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.cf.imes.module.system.dal.mysql.funds.organamount;
|
||||
|
||||
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.organamount.OrganAmountDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Mapper
|
||||
public interface OrganAmountMapper extends BaseMapperX<OrganAmountDO> {
|
||||
|
||||
|
||||
@Select("select sum(amount) from organ_amount where deleted = false")
|
||||
BigDecimal selectAllOrganAmount();
|
||||
|
||||
}
|
||||
+17
-17
@@ -1,10 +1,10 @@
|
||||
package com.cf.imes.module.system.dal.mysql.products;
|
||||
package com.cf.imes.module.system.dal.mysql.funds.products;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.system.controller.admin.products.vo.productDetails.ProductDetailsPageReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.products.ProductsDetailDO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.products.vo.productDetails.ProductDetailsPageReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.products.ProductsDetailDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -33,25 +33,25 @@ public interface ProductsDetailMapper extends BaseMapperX<ProductsDetailDO> {
|
||||
}
|
||||
|
||||
|
||||
// 时长查重,添加productId为查询条件
|
||||
default int selectCountByDuration(String duration, Long productId, Boolean flag) {
|
||||
// 时长查重,添加productId为查询条件
|
||||
default int selectCountByDuration(String duration, Long productId) {
|
||||
LambdaQueryWrapperX<ProductsDetailDO> queryWrapper = new LambdaQueryWrapperX<>();
|
||||
queryWrapper.eq(ProductsDetailDO::getDuration, duration)
|
||||
.eq(ProductsDetailDO::getDeleted, false);
|
||||
if (flag) { // flag为true时,查询条件中添加productId
|
||||
queryWrapper.eq(ProductsDetailDO::getProductId, productId);
|
||||
}
|
||||
queryWrapper.eq(ProductsDetailDO::getProductId, productId)
|
||||
.eq(ProductsDetailDO::getDeleted, false)
|
||||
.eq(ProductsDetailDO::getDuration, duration);
|
||||
return Math.toIntExact(selectCount(queryWrapper));
|
||||
|
||||
}
|
||||
|
||||
// 产量查重
|
||||
default int selectCountByOutput(BigDecimal output, Long productId, Boolean flag) {
|
||||
|
||||
|
||||
// 产量查重
|
||||
default int selectCountByOutput(BigDecimal output, Long productId) {
|
||||
LambdaQueryWrapperX<ProductsDetailDO> queryWrapper = new LambdaQueryWrapperX<>();
|
||||
queryWrapper.eq(ProductsDetailDO::getDuration, output)
|
||||
.eq(ProductsDetailDO::getDeleted, false);
|
||||
if (flag) { // flag为true时,查询条件中添加productId
|
||||
queryWrapper.eq(ProductsDetailDO::getProductId, productId);
|
||||
}
|
||||
queryWrapper.eq(ProductsDetailDO::getProductId, productId)
|
||||
.eq(ProductsDetailDO::getDeleted, false)
|
||||
.eq(ProductsDetailDO::getDuration, output);
|
||||
return Math.toIntExact(selectCount(queryWrapper));
|
||||
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
package com.cf.imes.module.system.dal.mysql.products;
|
||||
package com.cf.imes.module.system.dal.mysql.funds.products;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.system.controller.admin.products.vo.product.ProductPageReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.products.ProductsDO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.products.vo.product.ProductPageReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.products.ProductsDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
package com.cf.imes.module.system.dal.mysql.recharge;
|
||||
package com.cf.imes.module.system.dal.mysql.funds.recharge;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.system.controller.admin.recharge.vo.RechargePageReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.recharge.GiftMoneyDetailsDO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.recharge.vo.RechargePageReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.recharge.GiftMoneyDetailsDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.cf.imes.module.system.dal.mysql.parser;
|
||||
|
||||
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.module.system.dal.dataobject.parser.ParserLimitDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author 解析器授权 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface ParserLimitMapper extends BaseMapperX<ParserLimitDO> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.cf.imes.module.system.dal.mysql.parser;
|
||||
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.module.system.dal.dataobject.parser.ParserDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author 解析器 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface ParserMapper extends BaseMapperX<ParserDO> {
|
||||
|
||||
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.cf.imes.module.system.dal.mysql.parser;
|
||||
|
||||
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.module.system.dal.dataobject.parser.ParserTemplateDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
/**
|
||||
* @author 解析器模板 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface ParserTemplateMapper extends BaseMapperX<ParserTemplateDO> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
package com.cf.imes.module.system.framework.rpc.config;
|
||||
|
||||
import com.cf.imes.module.executor.api.customplateno.OrderCustomPlateNoApi;
|
||||
import com.cf.imes.module.executor.api.funds.ExecutorFundsApi;
|
||||
import com.cf.imes.module.executor.api.orderProcess.OrderProcessApi;
|
||||
import com.cf.imes.module.executor.api.plan.OrderPlanApi;
|
||||
import com.cf.imes.module.infra.api.file.FileApi;
|
||||
@@ -9,6 +10,6 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableFeignClients(clients = {FileApi.class, WebSocketSenderApi.class, OrderProcessApi.class, OrderPlanApi.class, OrderCustomPlateNoApi.class})
|
||||
@EnableFeignClients(clients = {FileApi.class, WebSocketSenderApi.class, OrderProcessApi.class, OrderPlanApi.class, OrderCustomPlateNoApi.class, ExecutorFundsApi.class})
|
||||
public class RpcConfiguration {
|
||||
}
|
||||
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package com.cf.imes.module.system.job.advertisement;
|
||||
|
||||
|
||||
import com.cf.imes.module.system.dal.mysql.funds.advertisement.AdvertisementMapper;
|
||||
import com.cf.imes.module.system.enums.advertisement.AdvertisementStatusEnum;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* @author 定时任务修改广告的发布状态
|
||||
*/
|
||||
@Component
|
||||
public class UpdateAdStatus {
|
||||
|
||||
@Resource
|
||||
private AdvertisementMapper advertisementMapper;
|
||||
|
||||
|
||||
// 修改广告的发布状态,将 未发布 修改为 发布,凌晨一点执行
|
||||
// @Scheduled(cron = "0 0 1 * * ?")
|
||||
public void updateAdStatusIsPublish() {
|
||||
|
||||
LocalDate now = LocalDate.now();
|
||||
|
||||
|
||||
/**
|
||||
* 修改广告的发布状态,修改 未发布 为 发布
|
||||
* @param now 现在的时间
|
||||
* @param status 未发布的状态
|
||||
*/
|
||||
advertisementMapper.updateAdStatusIsPublish(now,AdvertisementStatusEnum.UNPUBLISHED.getStatus());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 修改广告的发布状态,将 发布 修改为 已结束,晚上 11点半执行
|
||||
// @Scheduled(cron = "0 30 23 * * ?")
|
||||
public void updateAdStatusIsEndPublished(){
|
||||
|
||||
LocalDate now = LocalDate.now();
|
||||
|
||||
/**
|
||||
* 修改广告的发布状态,修改 发布 为 未发布
|
||||
* @param now 现在的时间
|
||||
* @param status 发布的状态
|
||||
*/
|
||||
advertisementMapper.updateAdStatusIsEndPublished(now,AdvertisementStatusEnum.PUBLISHED.getStatus());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+2
-1
@@ -10,6 +10,7 @@ import org.springframework.web.context.request.RequestContextHolder;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -36,7 +37,7 @@ public class AdvertisementProducer {
|
||||
* @param triggerTime 到期时间
|
||||
*/
|
||||
|
||||
public String sendAdvertisementSendMessage(Long adId, String action, LocalDateTime triggerTime) {
|
||||
public String sendAdvertisementSendMessage(Long adId, String action, LocalDate triggerTime) {
|
||||
|
||||
String messageId = UUID.randomUUID().toString();
|
||||
|
||||
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
package com.cf.imes.module.system.service.advertisement;
|
||||
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.module.system.controller.admin.advertisement.vo.AdvertisementPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.advertisement.vo.AdvertisementSaveReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.advertisement.AdvertisementDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
public interface AdvertisementService {
|
||||
|
||||
/**
|
||||
* 创建广告
|
||||
*
|
||||
* @param createReqVO 产品名称
|
||||
* @return 编号
|
||||
*/
|
||||
Long create(@Valid AdvertisementSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新广告
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void update(@Valid AdvertisementDO updateReqVO, Integer index);
|
||||
|
||||
/**
|
||||
* 更新广告状态
|
||||
*
|
||||
* @param id 更新信息
|
||||
*/
|
||||
void update(Long id, Integer status);
|
||||
|
||||
/**
|
||||
* 删除广告
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void delete(Long id);
|
||||
|
||||
/**
|
||||
* 获得广告
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
AdvertisementDO get(Long id);
|
||||
|
||||
/**
|
||||
* 获得广告 分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
*/
|
||||
PageResult<AdvertisementDO> getPage(AdvertisementPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
-251
@@ -1,251 +0,0 @@
|
||||
package com.cf.imes.module.system.service.advertisement;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.nacos.common.utils.StringUtils;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaUpdateWrapperX;
|
||||
import com.cf.imes.module.system.controller.admin.advertisement.vo.AdvertisementPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.advertisement.vo.AdvertisementSaveReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.advertisement.AdvertisementDO;
|
||||
import com.cf.imes.module.system.dal.dataobject.advertisement.AdvertisementTaskDO;
|
||||
import com.cf.imes.module.system.dal.mysql.advertisement.AdvertisementMapper;
|
||||
import com.cf.imes.module.system.dal.mysql.advertisement.AdvertisementTaskMapper;
|
||||
import com.cf.imes.module.system.enums.advertisement.AdvertisementStatusEnum;
|
||||
import com.cf.imes.module.system.enums.advertisement.MessageStatusEnum;
|
||||
import com.cf.imes.module.system.mq.producer.advertisement.AdvertisementProducer;
|
||||
import com.cf.imes.module.system.service.dict.DictDataService;
|
||||
import com.cf.imes.module.system.util.SnowflakeIdWorker3rd;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 广告表 advertisement Service 实现类
|
||||
*
|
||||
* @author 晨丰科技
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class AdvertisementServiceImpl implements AdvertisementService{
|
||||
|
||||
private static final String ADVERTISEMENT_POSITION = "advertisement_position";
|
||||
|
||||
private static final String EMPTY_STRING = new String();
|
||||
|
||||
@Value("${chenfeng.info.name}")
|
||||
private String SOFT_WARE_ID; // 获取软件标识-可修改
|
||||
|
||||
@Resource
|
||||
private DictDataService dictDataService;
|
||||
|
||||
@Resource
|
||||
private AdvertisementMapper advertisementMapper;
|
||||
|
||||
@Resource
|
||||
private AdvertisementTaskMapper advertisementTaskMapper;
|
||||
|
||||
@Resource
|
||||
private SnowflakeIdWorker3rd idWorker;
|
||||
|
||||
@Resource
|
||||
private AdvertisementProducer advertisementProducer;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long create(AdvertisementSaveReqVO createReqVO) {
|
||||
// 遍历adPosition验证广告位置是否存在
|
||||
for (Integer adPosition : createReqVO.getAdPosition()) {
|
||||
if (dictDataService.getDictData(ADVERTISEMENT_POSITION, adPosition.toString()) == null) {
|
||||
throw exception(ADVERTISEMENT_POSITION_NO_EXIST);
|
||||
}
|
||||
}
|
||||
// 插入广告
|
||||
Long id = idWorker.nextId();
|
||||
createReqVO.setId(id);
|
||||
AdvertisementDO advertisementDO = BeanUtils.toBean(createReqVO, AdvertisementDO.class)
|
||||
.setAdPosition(Arrays.toString(createReqVO.getAdPosition()))
|
||||
// .setStartTime(createReqVO.getStartTime().toLocalDate().atStartOfDay()) // 开始结束时间设置为每天00:00:00
|
||||
// .setEndTime(createReqVO.getEndTime().toLocalDate().atStartOfDay())
|
||||
.setStatus(validateAdvertisementStatus(createReqVO.getStartTime(), createReqVO.getEndTime()))
|
||||
.setSoftwareId(SOFT_WARE_ID);
|
||||
advertisementMapper.insert(advertisementDO);
|
||||
|
||||
// 使用子线程,添加生产者队列,待到达发布时间进行广告状态修改为已发布
|
||||
sendDelayMessages(advertisementDO);
|
||||
return advertisementDO.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送初始延迟消息
|
||||
*
|
||||
* 根据状态发送延迟信息
|
||||
*/
|
||||
private void sendDelayMessages(AdvertisementDO ad) {
|
||||
|
||||
// 删除可能存在的旧消息
|
||||
cancelExistingMessages(ad.getId());
|
||||
|
||||
// 发送发布消息
|
||||
if (ad.getStartTime().isAfter(LocalDateTime.now())) {
|
||||
String publishMsgId = advertisementProducer.sendAdvertisementSendMessage(ad.getId(), AdvertisementStatusEnum.PUBLISHED.getName(), ad.getStartTime()); // 发布
|
||||
trackMessage(ad.getId(), publishMsgId, AdvertisementStatusEnum.PUBLISHED.getStatus(), MessageStatusEnum.PENDING.getStatus());
|
||||
}
|
||||
|
||||
// 发送结束消息
|
||||
if (ad.getEndTime().isAfter(LocalDateTime.now())) {
|
||||
String expireMsgId = advertisementProducer.sendAdvertisementSendMessage(ad.getId(), AdvertisementStatusEnum.ENDED.getName(), ad.getEndTime()); // 结束
|
||||
trackMessage(ad.getId(), expireMsgId, AdvertisementStatusEnum.ENDED.getStatus(), MessageStatusEnum.PENDING.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录消息追踪
|
||||
*/
|
||||
private void trackMessage(Long adId, String messageId, Integer advertisementStatus, Integer messageStatus) {
|
||||
if (StringUtils.isNotBlank(messageId)) {
|
||||
advertisementTaskMapper.insert(new AdvertisementTaskDO()
|
||||
.setAdvertisementId(adId)
|
||||
.setMessageId(messageId)
|
||||
.setMessageStatus(messageStatus)
|
||||
.setAdvertisementStatus(advertisementStatus)
|
||||
);
|
||||
log.info("[trackMessage][adId({}) messageId({}) 记录消息追踪成功]", adId, messageId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消关联的消息
|
||||
*/
|
||||
private void cancelExistingMessages(Long adId) {
|
||||
// 标记消息为已取消(实际消费时检查)
|
||||
advertisementTaskMapper.updateToDeletedById(adId,true, MessageStatusEnum.CANCELLED.getStatus());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(AdvertisementDO updateReqVO, Integer index) {
|
||||
// 确认广告是否存在
|
||||
validateAdvertisementExists(updateReqVO.getId(), false);
|
||||
// 更新内容
|
||||
AdvertisementDO advertisementDO = BeanUtils.toBean(updateReqVO, AdvertisementDO.class);
|
||||
// 删除现有广告的延迟队列
|
||||
if (index == 0) { // 全部更新
|
||||
advertisementDO.setAdRedirectUrl(getEmpty(advertisementDO.getAdRedirectUrl()))
|
||||
.setSort(getZeroInt(advertisementDO.getSort()))
|
||||
.setStatus(validateAdvertisementStatus(advertisementDO.getStartTime(), advertisementDO.getEndTime()));
|
||||
|
||||
} else {
|
||||
advertisementDO = getAdvertisementDO(updateReqVO.getId(), false)
|
||||
.setStartTime(updateReqVO.getStartTime())
|
||||
.setEndTime(updateReqVO.getEndTime())
|
||||
.setStatus(validateAdvertisementStatus(advertisementDO.getStartTime(), advertisementDO.getEndTime()));
|
||||
|
||||
}
|
||||
// 根据修改时间,新增广告状态修改延迟队列
|
||||
advertisementMapper.updateById(advertisementDO);
|
||||
|
||||
// 使用子线程,添加生产者队列,待到达发布时间进行广告状态修改为已发布
|
||||
sendDelayMessages(advertisementDO);
|
||||
}
|
||||
// 判断广告状态
|
||||
public int validateAdvertisementStatus(LocalDateTime startTime, LocalDateTime endTime) {
|
||||
// 当前时间
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
if (now.isBefore(startTime)) { // 未开始
|
||||
return AdvertisementStatusEnum.UNPUBLISHED.getStatus();
|
||||
} else if (now.isAfter(endTime)) { // 已结束
|
||||
return AdvertisementStatusEnum.ENDED.getStatus();
|
||||
} else { // 进行中
|
||||
return AdvertisementStatusEnum.PUBLISHED.getStatus();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* value为空返回EMPTY_STRING
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
private String getEmpty(String value) {
|
||||
return StringUtils.defaultIfEmpty(value, EMPTY_STRING);
|
||||
}
|
||||
|
||||
/**
|
||||
* value为空返回0.0
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
private int getZeroInt(Integer value) {
|
||||
return ObjectUtil.defaultIfNull(value, 0);
|
||||
}
|
||||
|
||||
private void validateAdvertisementExists(Long id, Boolean deleted) {
|
||||
AdvertisementDO advertisementDO = advertisementMapper.selectOne(new LambdaQueryWrapperX<AdvertisementDO>()
|
||||
.eq(AdvertisementDO::getId, id)
|
||||
.eq(AdvertisementDO::getDeleted, deleted));
|
||||
if (advertisementDO == null) {
|
||||
throw exception(ADVERTISEMENT_NO_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
private AdvertisementDO getAdvertisementDO(Long id, Boolean deleted) {
|
||||
return advertisementMapper.selectOne(new LambdaQueryWrapperX<AdvertisementDO>()
|
||||
.eq(AdvertisementDO::getId, id)
|
||||
.eq(AdvertisementDO::getDeleted, deleted));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Long id, Integer status) { // 发布,结束
|
||||
if (status.equals(AdvertisementStatusEnum.PUBLISHED.getStatus())) { // 立即发布
|
||||
if (LocalDateTime.now().isAfter(getAdvertisementDO(id, false).getStartTime())) {
|
||||
throw exception(ADVERTISEMENT_STATUS_ERROR);
|
||||
}
|
||||
if (LocalDateTime.now().isAfter(getAdvertisementDO(id, false).getEndTime())) {
|
||||
throw exception(ADVERTISEMENT_STATUS_ERROR2);
|
||||
}
|
||||
|
||||
} else if (status.equals(AdvertisementStatusEnum.ENDED.getStatus())) { // 结束发布
|
||||
if (LocalDateTime.now().isBefore(getAdvertisementDO(id, false).getStartTime())) {
|
||||
throw exception(ADVERTISEMENT_END_ERROR);
|
||||
}
|
||||
if (LocalDateTime.now().isAfter(getAdvertisementDO(id, false).getEndTime())) {
|
||||
throw exception(ADVERTISEMENT_END_ERROR2);
|
||||
}
|
||||
}
|
||||
advertisementMapper.update(new AdvertisementDO().setStatus(status),
|
||||
new LambdaUpdateWrapperX<AdvertisementDO>()
|
||||
.eq(AdvertisementDO::getId, id)
|
||||
.eq(AdvertisementDO::getDeleted, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long id) {
|
||||
// 确认广告是否存在
|
||||
validateAdvertisementExists(id, false);
|
||||
advertisementMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdvertisementDO get(Long id) {
|
||||
validateAdvertisementExists(id, false);
|
||||
return getAdvertisementDO(id, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<AdvertisementDO> getPage(AdvertisementPageReqVO pageReqVO) {
|
||||
return advertisementMapper.selectPage(pageReqVO, false);
|
||||
}
|
||||
}
|
||||
+9
-8
@@ -1,11 +1,11 @@
|
||||
package com.cf.imes.module.system.service.advertisement;
|
||||
package com.cf.imes.module.system.service.funds.advertisement;
|
||||
|
||||
import com.alibaba.nacos.common.utils.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.cf.imes.module.system.dal.dataobject.advertisement.AdvertisementDO;
|
||||
import com.cf.imes.module.system.dal.dataobject.advertisement.AdvertisementTaskDO;
|
||||
import com.cf.imes.module.system.dal.mysql.advertisement.AdvertisementMapper;
|
||||
import com.cf.imes.module.system.dal.mysql.advertisement.AdvertisementTaskMapper;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.advertisement.AdvertisementDO;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.advertisement.AdvertisementTaskDO;
|
||||
import com.cf.imes.module.system.dal.mysql.funds.advertisement.AdvertisementMapper;
|
||||
import com.cf.imes.module.system.dal.mysql.funds.advertisement.AdvertisementTaskMapper;
|
||||
import com.cf.imes.module.system.enums.advertisement.AdvertisementStatusEnum;
|
||||
import com.cf.imes.module.system.enums.advertisement.MessageStatusEnum;
|
||||
import com.cf.imes.module.system.mq.message.advertisement.AdvertisementSendMessage;
|
||||
@@ -17,6 +17,7 @@ import org.springframework.web.context.request.RequestContextHolder;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@@ -47,7 +48,7 @@ public class AdvertisementCompensateTask {
|
||||
// @Scheduled(cron = "0 0/30 * * * ?")
|
||||
public void checkAdStatusConsistency() {
|
||||
// 1. 检查应发布但未发布的广告
|
||||
List<AdvertisementDO> unpublishedAds = advertisementMapper.selectList(LocalDateTime.now(), AdvertisementStatusEnum.UNPUBLISHED.getStatus());
|
||||
List<AdvertisementDO> unpublishedAds = advertisementMapper.selectList(LocalDate.now().atStartOfDay(), AdvertisementStatusEnum.UNPUBLISHED.getStatus());
|
||||
unpublishedAds.forEach(ad -> {
|
||||
updateAdStatus(ad, AdvertisementStatusEnum.PUBLISHED.getStatus());
|
||||
rescheduleExpireMessage(ad);
|
||||
@@ -63,8 +64,8 @@ public class AdvertisementCompensateTask {
|
||||
}
|
||||
|
||||
private void rescheduleExpireMessage(AdvertisementDO ad) {
|
||||
if (ad.getEndTime().isAfter(LocalDateTime.now())) {
|
||||
String newMsgId = sendSingleMessage(ad.getId(), "expire", ad.getEndTime());
|
||||
if (ad.getEndTime().isAfter(LocalDate.now())) {
|
||||
String newMsgId = sendSingleMessage(ad.getId(), "expire", ad.getEndTime().atStartOfDay());
|
||||
trackMessage(ad.getId(), newMsgId, AdvertisementStatusEnum.PUBLISHED.getStatus(), MessageStatusEnum.CANCELLED.getStatus());
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package com.cf.imes.module.system.service.funds.advertisement;
|
||||
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.module.system.controller.admin.funds.advertisement.vo.AdvertisementPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.advertisement.vo.AdvertisementPublishReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.advertisement.vo.AdvertisementRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.advertisement.vo.AdvertisementSaveReqVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AdvertisementService {
|
||||
|
||||
/**
|
||||
* 创建广告
|
||||
*
|
||||
* @param createReqVO 产品名称
|
||||
* @return 编号
|
||||
*/
|
||||
Long create(AdvertisementSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新广告
|
||||
*
|
||||
* @param reqVO 更新信息
|
||||
*/
|
||||
void update(AdvertisementSaveReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 删除广告
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void delete(Long id);
|
||||
|
||||
/**
|
||||
* 获得广告
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
AdvertisementRespVO get(Long id);
|
||||
|
||||
/**
|
||||
* 获得广告 分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
*/
|
||||
PageResult<AdvertisementRespVO> getPage(AdvertisementPageReqVO pageReqVO);
|
||||
|
||||
|
||||
void updatePublishStatus(AdvertisementPublishReqVO reqVO);
|
||||
|
||||
List<AdvertisementRespVO> getAdvertisementByPosition(Integer adPosition);
|
||||
|
||||
}
|
||||
+494
@@ -0,0 +1,494 @@
|
||||
package com.cf.imes.module.system.service.funds.advertisement;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.cf.imes.framework.common.exception.ServiceException;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.Assert.AssertUtils;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.system.controller.admin.funds.advertisement.vo.*;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.advertisement.AdvertisementDO;
|
||||
import com.cf.imes.module.system.dal.mysql.funds.advertisement.AdvertisementMapper;
|
||||
import com.cf.imes.module.system.dal.mysql.funds.advertisement.AdvertisementTaskMapper;
|
||||
import com.cf.imes.module.system.enums.advertisement.AdvertisementStatusEnum;
|
||||
import com.cf.imes.module.system.mq.producer.advertisement.AdvertisementProducer;
|
||||
import com.cf.imes.module.system.service.dict.DictDataService;
|
||||
import com.cf.imes.module.system.util.SnowflakeIdWorker3rd;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 广告表 advertisement Service 实现类
|
||||
*
|
||||
* @author 晨丰科技
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class AdvertisementServiceImpl implements AdvertisementService{
|
||||
|
||||
private static final String ADVERTISEMENT_POSITION = "advertisement_position";
|
||||
|
||||
private static final String EMPTY_STRING = new String();
|
||||
|
||||
@Value("${chenfeng.info.name}")
|
||||
private String SOFT_WARE_ID; // 获取软件标识-可修改
|
||||
|
||||
@Resource
|
||||
private DictDataService dictDataService;
|
||||
|
||||
@Resource
|
||||
private AdvertisementMapper advertisementMapper;
|
||||
|
||||
@Resource
|
||||
private AdvertisementTaskMapper advertisementTaskMapper;
|
||||
|
||||
@Resource
|
||||
private SnowflakeIdWorker3rd idWorker;
|
||||
|
||||
@Resource
|
||||
private AdvertisementProducer advertisementProducer;
|
||||
|
||||
@Resource
|
||||
private AdImageFilePath adImageFilePath;
|
||||
|
||||
|
||||
private static final String FIELD_AD_ID = "广告ID为:";
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long create(AdvertisementSaveReqVO createReqVO) {
|
||||
|
||||
if(createReqVO.getStartTime().isAfter(createReqVO.getEndTime())){
|
||||
|
||||
throw exception(ADVERTISEMENT_TIME_ERROR);
|
||||
}
|
||||
|
||||
AdvertisementDO aDo = advertisementMapper.selectAdByAdName(createReqVO.getAdName(),null);
|
||||
|
||||
AssertUtils.empty(aDo,ADVERTISEMENT_NAME_IS_EXIST);
|
||||
|
||||
Long id = idWorker.nextId();
|
||||
|
||||
String filePath = "";
|
||||
if(createReqVO.getAdImageFile() != null) {
|
||||
filePath = uploadAdImageFile(createReqVO.getAdImageFile(), id);
|
||||
}
|
||||
|
||||
// 插入广告
|
||||
createReqVO.setId(id);
|
||||
AdvertisementDO advertisementDO = BeanUtils.toBean(createReqVO, AdvertisementDO.class)
|
||||
.setAdPosition(Arrays.toString(createReqVO.getAdPosition()))
|
||||
.setStatus(validateAdvertisementStatus(createReqVO.getStartTime()))
|
||||
.setAdImagePath(filePath)
|
||||
.setSoftwareId(SOFT_WARE_ID);
|
||||
|
||||
advertisementMapper.insert(advertisementDO);
|
||||
|
||||
return advertisementDO.getId();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(AdvertisementSaveReqVO reqVO) {
|
||||
|
||||
// 确认广告是否存在
|
||||
AdvertisementDO validated = validateAdvertisementExists(reqVO.getId());
|
||||
|
||||
AdvertisementDO aDo = advertisementMapper.selectAdByAdName(reqVO.getAdName(),reqVO.getId());
|
||||
|
||||
AssertUtils.empty(aDo,ADVERTISEMENT_NAME_IS_EXIST);
|
||||
|
||||
if(reqVO.getStartTime().isAfter(reqVO.getEndTime())){
|
||||
throw exception(ADVERTISEMENT_TIME_ERROR);
|
||||
}
|
||||
|
||||
|
||||
String adImagePath = validated.getAdImagePath();
|
||||
if(reqVO.getAdImageFile() != null) {
|
||||
adImagePath = uploadAdImageFile(reqVO.getAdImageFile(), reqVO.getId());
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 更新内容
|
||||
AdvertisementDO advertisementDO = BeanUtils.toBean(reqVO, AdvertisementDO.class)
|
||||
.setAdPosition(Arrays.toString(reqVO.getAdPosition()))
|
||||
.setStatus(validateAdvertisementStatus(reqVO.getStartTime()))
|
||||
.setAdImagePath(adImagePath)
|
||||
.setSoftwareId(SOFT_WARE_ID);
|
||||
|
||||
advertisementMapper.updateById(advertisementDO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void delete(Long id) {
|
||||
|
||||
// 确认广告是否存在
|
||||
AdvertisementDO advertisementDO = validateAdvertisementExists(id);
|
||||
|
||||
if(advertisementDO.getStatus().equals(AdvertisementStatusEnum.PUBLISHED.getStatus())){
|
||||
throw exception(ADVERTISEMENT_NO_DELETE);
|
||||
}
|
||||
|
||||
advertisementMapper.deleteById(id);
|
||||
|
||||
deleteFilesById(adImageFilePath.getFilePath(),id.toString());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public AdvertisementRespVO get(Long id) {
|
||||
|
||||
AdvertisementDO advertisementDO = validateAdvertisementExists(id);
|
||||
|
||||
AdvertisementRespVO respVO = BeanUtils.toBean(advertisementDO, AdvertisementRespVO.class);
|
||||
|
||||
viewImage(respVO);
|
||||
|
||||
return respVO;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public PageResult<AdvertisementRespVO> getPage(AdvertisementPageReqVO pageReqVO) {
|
||||
|
||||
PageResult<AdvertisementDO> pageResult = advertisementMapper.selectPage(pageReqVO);
|
||||
|
||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||
return new PageResult<>(pageResult.getTotal());
|
||||
}
|
||||
|
||||
List<AdvertisementRespVO> respVOS = BeanUtils.toBean(pageResult.getList(), AdvertisementRespVO.class);
|
||||
|
||||
respVOS.forEach(f->{
|
||||
f.setLaunchTime(f.getStartTime() + "~" + f.getEndTime());
|
||||
viewImage(f);
|
||||
});
|
||||
|
||||
return new PageResult<>(respVOS,pageResult.getTotal());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void updatePublishStatus(AdvertisementPublishReqVO reqVO) {
|
||||
|
||||
Long id = reqVO.getId();
|
||||
|
||||
Integer status = reqVO.getStatus();
|
||||
|
||||
AdvertisementDO advertisementDO = validateAdvertisementExists(id);
|
||||
|
||||
// 广告的开始时间
|
||||
LocalDate startTime = advertisementDO.getStartTime();
|
||||
|
||||
// 广告的结束时间
|
||||
LocalDate endTime = advertisementDO.getEndTime();
|
||||
|
||||
// 立即发布
|
||||
if (status.equals(AdvertisementStatusEnum.PUBLISHED.getStatus())) {
|
||||
|
||||
if (LocalDate.now().isAfter(startTime)) {
|
||||
throw exception(ADVERTISEMENT_STATUS_ERROR);
|
||||
}
|
||||
if (LocalDate.now().isAfter(endTime)) {
|
||||
throw exception(ADVERTISEMENT_STATUS_ERROR2);
|
||||
}
|
||||
|
||||
advertisementDO.setStatus(status);
|
||||
}
|
||||
// 结束发布
|
||||
else if (status.equals(AdvertisementStatusEnum.ENDED.getStatus())) {
|
||||
if (LocalDate.now().isBefore(startTime)) {
|
||||
throw exception(ADVERTISEMENT_END_ERROR);
|
||||
}
|
||||
if (LocalDate.now().isAfter(endTime)) {
|
||||
throw exception(ADVERTISEMENT_END_ERROR2);
|
||||
}
|
||||
|
||||
advertisementDO.setStatus(status);
|
||||
}
|
||||
// 重新发布
|
||||
else if(Boolean.TRUE.equals(reqVO.getIsRepublish())){
|
||||
|
||||
// 重新投放开始时间
|
||||
LocalDate isRepublishStartTime = Optional.ofNullable(reqVO.getStartTime()).orElseThrow(() -> new ServiceException(ADVERTISEMENT_REPUBLISH_NO_TIME));
|
||||
|
||||
// 重新投放结束时间
|
||||
LocalDate isRepublishEndTime = Optional.ofNullable(reqVO.getEndTime()).orElseThrow(() -> new ServiceException(ADVERTISEMENT_REPUBLISH_NO_TIME));
|
||||
|
||||
if(isRepublishStartTime.isAfter(isRepublishEndTime)){
|
||||
throw exception(ADVERTISEMENT_TIME_ERROR);
|
||||
}
|
||||
|
||||
validateAdvertisementStatus(isRepublishStartTime);
|
||||
|
||||
advertisementDO.setStatus(AdvertisementStatusEnum.PUBLISHED.getStatus());
|
||||
|
||||
}
|
||||
|
||||
advertisementMapper.updateById(advertisementDO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<AdvertisementRespVO> getAdvertisementByPosition(Integer adPosition) {
|
||||
|
||||
List<AdvertisementRespVO> respVOS = advertisementMapper.selectAdList(adPosition, AdvertisementStatusEnum.PUBLISHED.getStatus(), LocalDate.now());
|
||||
|
||||
if(CollUtil.isEmpty(respVOS)){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
respVOS.forEach(this::viewImage);
|
||||
|
||||
return respVOS;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 判断广告状态
|
||||
public int validateAdvertisementStatus(LocalDate startTime) {
|
||||
|
||||
// 当前时间
|
||||
LocalDate now = LocalDate.now();
|
||||
|
||||
if(now.equals(startTime)){
|
||||
// 已上架
|
||||
return AdvertisementStatusEnum.PUBLISHED.getStatus();
|
||||
|
||||
}else if(now.isAfter(startTime)){
|
||||
throw exception(ADVERTISEMENT_START_TIME_ERROR);
|
||||
|
||||
}else {
|
||||
// 未上架
|
||||
return AdvertisementStatusEnum.UNPUBLISHED.getStatus();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private AdvertisementDO validateAdvertisementExists(Long id) {
|
||||
|
||||
AdvertisementDO advertisementDO = advertisementMapper.selectOne(new LambdaQueryWrapperX<AdvertisementDO>()
|
||||
.eq(AdvertisementDO::getDeleted, false)
|
||||
.eq(AdvertisementDO::getId, id));
|
||||
if (advertisementDO == null) {
|
||||
throw exception(ADVERTISEMENT_NO_EXIST);
|
||||
}
|
||||
return advertisementDO;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 上传图片
|
||||
private String uploadAdImageFile(MultipartFile file,Long id){
|
||||
|
||||
try {
|
||||
|
||||
// 删除之前的图片
|
||||
deleteFilesById(adImageFilePath.getFilePath(),id.toString());
|
||||
|
||||
// 获取原始文件名并提取扩展名
|
||||
String originalFilename = file.getOriginalFilename();
|
||||
String extension = null;
|
||||
|
||||
int dotIndex = originalFilename.lastIndexOf('.');
|
||||
if (dotIndex != -1) {
|
||||
|
||||
extension = originalFilename.substring(dotIndex);
|
||||
}
|
||||
|
||||
// 文件名: id + .扩展名
|
||||
String filename = id + extension;
|
||||
|
||||
// 确保目录存在
|
||||
File dir = new File(adImageFilePath.getFilePath());
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
|
||||
File dest = new File(dir, filename);
|
||||
file.transferTo(dest);
|
||||
|
||||
return filename;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("图片上传失败:"+e.getMessage());
|
||||
throw exception(IMAGE_UPLOAD_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 删除图片
|
||||
public static void deleteFilesById(String directoryPath, String id) {
|
||||
File dir = new File(directoryPath);
|
||||
if (!dir.exists() || !dir.isDirectory()) {
|
||||
// 路径不存在或不是文件夹,不做处理
|
||||
return;
|
||||
}
|
||||
|
||||
File[] files = dir.listFiles();
|
||||
if (files == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (File file : files) {
|
||||
if (file.isFile()) {
|
||||
String fileName = file.getName();
|
||||
if (fileName.startsWith(id + ".")) {
|
||||
file.delete(); // 删除文件,不管结果(失败不会抛异常)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 查询图片,广告管理界面,广告位置查询,错误只写到日志,页面不显示错误
|
||||
public void viewImage(AdvertisementRespVO respVO) {
|
||||
|
||||
File dir = new File(adImageFilePath.getFilePath());
|
||||
if (!dir.exists()) {
|
||||
log.error(FIELD_AD_ID + respVO.getId() + ",的图片查询失败,其目录不存在");
|
||||
return;
|
||||
}
|
||||
|
||||
File[] matches = dir.listFiles((d, name) -> name.startsWith(respVO.getId().toString() + "."));
|
||||
if (matches == null || matches.length == 0) {
|
||||
log.error(FIELD_AD_ID + respVO.getId() + ",的图片查询失败,未找到对应图片");
|
||||
return;
|
||||
}
|
||||
|
||||
File imageFile = matches[0];
|
||||
|
||||
try {
|
||||
|
||||
// 图片字节数据
|
||||
byte[] imageBytes = Files.readAllBytes(imageFile.toPath());
|
||||
|
||||
// 图片的文件类型
|
||||
respVO.setAdImageFileType(Files.probeContentType(imageFile.toPath()));
|
||||
|
||||
// 图片的 Base64 字符串形式
|
||||
respVO.setAdImageBase64(Base64.getEncoder().encodeToString(imageBytes));
|
||||
|
||||
} catch (IOException e) {
|
||||
|
||||
log.error(FIELD_AD_ID + respVO.getId() + ",的图片读取失败," + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ResponseEntity<byte[]> getImage(Long adId){
|
||||
|
||||
|
||||
File dir = new File(adImageFilePath.getFilePath());
|
||||
|
||||
if (!dir.exists()) {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
// 找到文件名以 adId 开头的文件,例如 "123.png"
|
||||
File[] matches = dir.listFiles((d, name) -> name.startsWith(adId.toString() + "."));
|
||||
|
||||
if (matches == null || matches.length == 0) {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
|
||||
File imageFile = matches[0];
|
||||
|
||||
try {
|
||||
|
||||
byte[] imageBytes = Files.readAllBytes(imageFile.toPath());
|
||||
String contentType = Files.probeContentType(imageFile.toPath());
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.contentType(MediaType.parseMediaType(contentType))
|
||||
.body(imageBytes);
|
||||
} catch (IOException e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.cf.imes.module.system.service.funds.invoice;
|
||||
|
||||
|
||||
import com.cf.imes.module.system.controller.admin.funds.invoice.vo.InvoiceTitleReqVO;
|
||||
|
||||
/**
|
||||
* @author 发票管理接口
|
||||
*/
|
||||
public interface InvoiceService {
|
||||
|
||||
void insetInvoiceTitle(InvoiceTitleReqVO reqVO);
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package com.cf.imes.module.system.service.funds.invoice;
|
||||
|
||||
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.module.system.controller.admin.funds.invoice.vo.InvoiceTitleReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.invoice.InvoiceTitleInfoDO;
|
||||
import com.cf.imes.module.system.dal.mysql.funds.invoice.InvoiceTitleInfoMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
||||
/**
|
||||
* @author 发票管理接口 实现类
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class InvoiceServiceImpl implements InvoiceService{
|
||||
|
||||
|
||||
@Resource
|
||||
private InvoiceTitleInfoMapper invoiceTitleInfoMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public void insetInvoiceTitle(InvoiceTitleReqVO reqVO) {
|
||||
|
||||
|
||||
if(reqVO.getId() != null){
|
||||
InvoiceTitleInfoDO titleInfoDO = BeanUtils.toBean(reqVO, InvoiceTitleInfoDO.class);
|
||||
invoiceTitleInfoMapper.updateById(titleInfoDO);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
invoiceTitleInfoMapper.insert(InvoiceTitleInfoDO.builder()
|
||||
.invoiceTitle(reqVO.getInvoiceTitle())
|
||||
.invoiceType(reqVO.getInvoiceType())
|
||||
.issueType(reqVO.getIssueType())
|
||||
.taxpayerId(reqVO.getTaxpayerId())
|
||||
.bankName(reqVO.getBankName())
|
||||
.bankAccount(reqVO.getBankAccount())
|
||||
.registeredAddress(reqVO.getRegisteredAddress())
|
||||
.fixedPhone(reqVO.getFixedPhone())
|
||||
.email(reqVO.getEmail())
|
||||
.build());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.cf.imes.module.system.service.funds.organamount;
|
||||
|
||||
|
||||
import com.cf.imes.module.system.controller.admin.funds.organamount.vo.AllOrganAmountRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.organamount.vo.OrganAmountRespVO;
|
||||
|
||||
/**
|
||||
* @author 资金管理接口
|
||||
*/
|
||||
public interface OrganAmountService {
|
||||
|
||||
|
||||
OrganAmountRespVO getOrganAmount(Long organId);
|
||||
|
||||
|
||||
AllOrganAmountRespVO getOrganAmountAll();
|
||||
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
package com.cf.imes.module.system.service.funds.organamount;
|
||||
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.module.executor.api.funds.ExecutorFundsApi;
|
||||
import com.cf.imes.module.system.controller.admin.funds.organamount.vo.AllOrganAmountRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.organamount.vo.OrganAmountRespVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.organamount.OrganAmountDO;
|
||||
import com.cf.imes.module.system.dal.mysql.funds.organamount.OrganAmountMapper;
|
||||
import com.cf.imes.module.system.service.organ.OrganService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.ORGAN_AMOUNT_NO_EXIST;
|
||||
|
||||
/**
|
||||
* @author 资金管理接口 实现类
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class OrganAmountServiceImpl implements OrganAmountService {
|
||||
|
||||
|
||||
@Resource
|
||||
private OrganAmountMapper organAmountMapper;
|
||||
|
||||
@Resource
|
||||
private OrganService organService;
|
||||
|
||||
|
||||
@Resource
|
||||
private ExecutorFundsApi executorFundsApi;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public OrganAmountRespVO getOrganAmount(Long organId) {
|
||||
|
||||
organService.validOrgan(organId);
|
||||
|
||||
OrganAmountDO organAmountDO = validateOrganAmountExists(organId);
|
||||
|
||||
OrganAmountRespVO organAmountRespVO = BeanUtils.toBean(organAmountDO, OrganAmountRespVO.class);
|
||||
|
||||
organAmountRespVO.setAvailableAmount(organAmountRespVO.getAmount().add(organAmountRespVO.getGiftAmount()));
|
||||
|
||||
return organAmountRespVO;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public AllOrganAmountRespVO getOrganAmountAll() {
|
||||
|
||||
AllOrganAmountRespVO respVO = new AllOrganAmountRespVO();
|
||||
|
||||
BigDecimal allOrganAmount = organAmountMapper.selectAllOrganAmount();
|
||||
|
||||
BigDecimal examineAmount = executorFundsApi.getToExamineAmount().getCheckedData();
|
||||
|
||||
respVO.setAllOrganAmount(allOrganAmount);
|
||||
respVO.setToExamineAmount(examineAmount);
|
||||
|
||||
return respVO;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private OrganAmountDO validateOrganAmountExists(Long organId) {
|
||||
|
||||
OrganAmountDO organAmountDO = organAmountMapper.selectById(organId);
|
||||
|
||||
if (ObjectUtil.isNull(organAmountDO)) {
|
||||
throw exception(ORGAN_AMOUNT_NO_EXIST);
|
||||
}
|
||||
|
||||
return organAmountDO;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+4
-4
@@ -1,9 +1,9 @@
|
||||
package com.cf.imes.module.system.service.products;
|
||||
package com.cf.imes.module.system.service.funds.products;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.module.system.controller.admin.products.vo.productDetails.ProductDetailsPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.products.vo.productDetails.ProductDetailsSaveReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.products.ProductsDetailDO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.products.vo.productDetails.ProductDetailsPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.products.vo.productDetails.ProductDetailsSaveReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.products.ProductsDetailDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
+265
@@ -0,0 +1,265 @@
|
||||
package com.cf.imes.module.system.service.funds.products;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.nacos.common.utils.StringUtils;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.Assert.AssertUtils;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.system.controller.admin.funds.products.vo.productDetails.ProductDetailsPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.products.vo.productDetails.ProductDetailsSaveReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.products.ProductsDO;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.products.ProductsDetailDO;
|
||||
import com.cf.imes.module.system.dal.mysql.funds.products.ProductsDetailMapper;
|
||||
import com.cf.imes.module.system.dal.mysql.funds.products.ProductsMapper;
|
||||
import com.cf.imes.module.system.enums.products.DurationUnitEnum;
|
||||
import com.cf.imes.module.system.enums.products.ProductStatusEnum;
|
||||
import com.cf.imes.module.system.enums.products.ProductsPurchaseTypeEnum;
|
||||
import com.cf.imes.module.system.util.SnowflakeIdWorker3rd;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 产品明细 productsDetails Service 实现类
|
||||
*
|
||||
* @author 晨丰科技
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ProductsDetailServiceImpl implements ProductsDetailService {
|
||||
|
||||
@Resource
|
||||
private ProductsDetailMapper productDetailsMapper;
|
||||
|
||||
@Resource
|
||||
private ProductsMapper productsMapper;
|
||||
|
||||
@Resource
|
||||
private SnowflakeIdWorker3rd idWorker;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Long create(ProductDetailsSaveReqVO createReqVO) {
|
||||
|
||||
// 校验是否有这个产品
|
||||
validateProductExist(createReqVO.getProductId());
|
||||
|
||||
if (createReqVO.getPurchaseType().equals(ProductsPurchaseTypeEnum.DURATION.getStatus())) {
|
||||
|
||||
String duration = createReqVO.getDuration();
|
||||
|
||||
AssertUtils.notEmpty(duration,PRODUCTS_DURATION_NOT_NULL);
|
||||
|
||||
// 校验时长
|
||||
duration = checkDuration(duration);
|
||||
|
||||
String giftDuration = null;
|
||||
if (createReqVO.getGiftDuration() != null) {
|
||||
giftDuration = checkDuration(createReqVO.getGiftDuration());
|
||||
}
|
||||
|
||||
createReqVO.setDuration(duration)
|
||||
.setGiftDuration(giftDuration);
|
||||
|
||||
// 查询是否有重复的定价
|
||||
checkProductDetails(createReqVO);
|
||||
|
||||
} else if (createReqVO.getPurchaseType().equals(ProductsPurchaseTypeEnum.OUTPUT.getStatus())) {
|
||||
if (StringUtils.isBlank(createReqVO.getDuration())) {
|
||||
throw exception(PRODUCTS_OUTPUT_NOT_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
Long id = idWorker.nextId();
|
||||
createReqVO.setId(id);
|
||||
ProductsDetailDO productDetailsDO = BeanUtils.toBean(createReqVO, ProductsDetailDO.class).setId(id);
|
||||
productDetailsMapper.insert(productDetailsDO);
|
||||
return id;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void update(ProductDetailsSaveReqVO updateReqVO) {
|
||||
|
||||
validateProductExist(updateReqVO.getProductId());
|
||||
|
||||
validateProductDetailsExists(updateReqVO.getId());
|
||||
|
||||
if (updateReqVO.getPurchaseType().equals(ProductsPurchaseTypeEnum.DURATION.getStatus())) {
|
||||
|
||||
if (StringUtils.isBlank(updateReqVO.getDuration())) {
|
||||
throw exception(PRODUCTS_DURATION_NOT_NULL);
|
||||
}
|
||||
// 校验时长
|
||||
String duration = checkDuration(updateReqVO.getDuration());
|
||||
String giftDuration = null;
|
||||
if (updateReqVO.getGiftDuration() != null) {
|
||||
giftDuration = checkDuration(updateReqVO.getGiftDuration());
|
||||
}
|
||||
updateReqVO.setDuration(duration).setGiftDuration(giftDuration);
|
||||
|
||||
// 校验同时长是否还有其他的定价规则
|
||||
checkProductDetails(updateReqVO);
|
||||
|
||||
|
||||
} else if (updateReqVO.getPurchaseType().equals(ProductsPurchaseTypeEnum.OUTPUT.getStatus())) {
|
||||
if (StringUtils.isBlank(updateReqVO.getDuration())) {
|
||||
throw exception(PRODUCTS_OUTPUT_NOT_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
ProductsDetailDO productDetailsDO = BeanUtils.toBean(updateReqVO, ProductsDetailDO.class)
|
||||
.setDiscount(getZeroBigDecimal(updateReqVO.getDiscount()))
|
||||
.setOriginalPrice(getZeroBigDecimal(updateReqVO.getOriginalPrice()))
|
||||
.setIsDiscounted(updateReqVO.getIsDiscounted());
|
||||
productDetailsMapper.updateById(productDetailsDO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* value为空返回0.0
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
private BigDecimal getZeroBigDecimal(BigDecimal value) {
|
||||
return ObjectUtil.defaultIfNull(value, BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long id) {
|
||||
|
||||
ProductsDetailDO productsDetailDO = validateProductDetailsExists(id);
|
||||
|
||||
validateProductExist(productsDetailDO.getProductId());
|
||||
|
||||
productDetailsMapper.deleteById(id);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductsDetailDO> get(Long id) {
|
||||
validateProductDetailsExists(id);
|
||||
return productDetailsMapper.selectList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ProductsDetailDO> getPage(ProductDetailsPageReqVO pageReqVO) {
|
||||
return productDetailsMapper.selectPage(pageReqVO.setDeleted(0));
|
||||
}
|
||||
|
||||
|
||||
|
||||
private ProductsDetailDO validateProductDetailsExists(Long id) {
|
||||
if (id == null) {
|
||||
throw exception(PRODUCTS_DETAIL_NO_EXIST);
|
||||
}
|
||||
|
||||
ProductsDetailDO productsDetailDO = productDetailsMapper.selectOne(new LambdaQueryWrapperX<ProductsDetailDO>()
|
||||
.eq(ProductsDetailDO::getId, id)
|
||||
.eq(ProductsDetailDO::getDeleted, false));
|
||||
|
||||
if (productsDetailDO == null) {
|
||||
throw exception(PRODUCTS_DETAIL_NO_EXIST);
|
||||
}
|
||||
|
||||
return productsDetailDO;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 时长校验
|
||||
private String checkDuration(String duration){
|
||||
|
||||
if (duration == null || !duration.contains("-")) {
|
||||
throw new IllegalArgumentException("格式错误,格式为:时长值-单位,例如 10-月");
|
||||
}
|
||||
|
||||
String[] parts = duration.split("-", 2);
|
||||
String valueStr = parts[0].trim();
|
||||
String timeUnit = parts[1].trim();
|
||||
|
||||
// 校验时长值
|
||||
if (valueStr.isEmpty() || !valueStr.matches("^\\d+$")) {
|
||||
throw exception(PRODUCTS_DURATION_INT_ERR);
|
||||
}
|
||||
|
||||
// 去除前导 0
|
||||
valueStr = valueStr.replaceFirst("^0+(?!$)", "");
|
||||
|
||||
int timeValue = Integer.parseInt(valueStr);
|
||||
if (timeValue <= 0) {
|
||||
throw exception(PRODUCTS_DURATION_INT_ERR);
|
||||
}
|
||||
|
||||
// 校验时间单位
|
||||
if (timeUnit.isEmpty()
|
||||
|| !(timeUnit.equals(DurationUnitEnum.YEAR.getName())
|
||||
|| timeUnit.equals(DurationUnitEnum.MONTH.getName())
|
||||
|| timeUnit.equals(DurationUnitEnum.DAY.getName()))) {
|
||||
|
||||
throw exception(PRODUCTS_DURATION_UNIT_ERR);
|
||||
}
|
||||
|
||||
return timeValue + timeUnit;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 产品存在性校验
|
||||
private void validateProductExist(Long productId){
|
||||
ProductsDO productsDO = productsMapper.selectOne(new LambdaQueryWrapperX<ProductsDO>()
|
||||
.eq(ProductsDO::getId, productId)
|
||||
.eq(ProductsDO::getDeleted, false));
|
||||
|
||||
AssertUtils.notEmpty(productsDO,PRODUCTS_NO_EXIST);
|
||||
|
||||
if(productsDO.getStatus().equals(ProductStatusEnum.PRODUCT_UPDATES.getStatus())){
|
||||
throw exception(PRODUCTS_DETAIL_NO_UPDATE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 时长/产量去重
|
||||
private void checkProductDetails(ProductDetailsSaveReqVO createReqVO){
|
||||
int count;
|
||||
if (createReqVO.getPurchaseType() == 0){
|
||||
// 时长去重
|
||||
count = productDetailsMapper.selectCountByDuration(createReqVO.getDuration(), createReqVO.getProductId());
|
||||
if (count > 0) {
|
||||
throw exception(PRODUCTS_DETAIL_DURATION_EXIST);
|
||||
}
|
||||
}else if (createReqVO.getPurchaseType() == 1){
|
||||
//产量去重
|
||||
count = productDetailsMapper.selectCountByOutput(createReqVO.getOutput(), createReqVO.getProductId());
|
||||
if (count > 0) {
|
||||
throw exception(PRODUCTS_DETAIL_OUTPUT_EXIST);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
package com.cf.imes.module.system.service.products;
|
||||
package com.cf.imes.module.system.service.funds.products;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.module.system.controller.admin.products.vo.product.ProductPageReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.products.ProductsDO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.products.vo.product.ProductPageReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.products.ProductsDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
package com.cf.imes.module.system.service.funds.products;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.Assert.AssertUtils;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.system.controller.admin.funds.products.vo.product.ProductPageReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.products.ProductsDO;
|
||||
import com.cf.imes.module.system.dal.mysql.funds.products.ProductsMapper;
|
||||
import com.cf.imes.module.system.enums.products.ProductStatusEnum;
|
||||
import com.cf.imes.module.system.util.SnowflakeIdWorker3rd;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 产品 products Service 实现类
|
||||
*
|
||||
* @author 晨丰科技
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ProductsServiceImpl implements ProductsService{
|
||||
|
||||
@Resource
|
||||
private ProductsMapper productsMapper;
|
||||
|
||||
@Resource
|
||||
private SnowflakeIdWorker3rd idWorker;
|
||||
|
||||
@Override
|
||||
public Long create(String productName) {
|
||||
|
||||
List<ProductsDO> productsDOS = productsMapper.selectList(new LambdaQueryWrapperX<ProductsDO>()
|
||||
.eq(ProductsDO::getDeleted, false)
|
||||
.eq(ProductsDO::getProductName, productName)
|
||||
.select(ProductsDO::getId));
|
||||
|
||||
AssertUtils.empty(productsDOS,PRODUCTS_IS_EXIST);
|
||||
|
||||
Long id = idWorker.nextId();
|
||||
productsMapper.insert(
|
||||
new ProductsDO()
|
||||
.setId(id)
|
||||
.setProductName(productName)
|
||||
.setStatus(ProductStatusEnum.PRODUCT_WAITING_UPDATES.getStatus())
|
||||
.setSoftwareId(0)
|
||||
);
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void update(ProductsDO updateReqVO) {
|
||||
Integer status = validateProductPlateExists(updateReqVO.getId()).getStatus();
|
||||
|
||||
if(status.equals(ProductStatusEnum.PRODUCT_UPDATES.getStatus())){
|
||||
throw exception(PRODUCTS_NO_UPDATE);
|
||||
|
||||
}
|
||||
|
||||
productsMapper.updateById(updateReqVO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void delete(Long id) {
|
||||
|
||||
ProductsDO productsDO = validateProductPlateExists(id);
|
||||
|
||||
if(productsDO.getStatus().equals(ProductStatusEnum.PRODUCT_UPDATES.getStatus())){
|
||||
throw exception(PRODUCTS_NO_DELETE);
|
||||
}
|
||||
|
||||
productsMapper.update(new LambdaUpdateWrapper<ProductsDO>()
|
||||
.eq(ProductsDO::getId,id)
|
||||
.set(ProductsDO::getDeleted, true));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ProductsDO get(Long id) {
|
||||
return validateProductPlateExists(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ProductsDO> getPage(ProductPageReqVO pageReqVO) {
|
||||
return productsMapper.selectPage(pageReqVO, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private ProductsDO validateProductPlateExists(Long id) {
|
||||
ProductsDO productsDO = productsMapper.selectOne(new LambdaQueryWrapperX<ProductsDO>()
|
||||
.eq(ProductsDO::getId, id)
|
||||
.eq(ProductsDO::getDeleted, false));
|
||||
|
||||
if (productsDO == null) {
|
||||
throw exception(PRODUCTS_NO_EXIST);
|
||||
}
|
||||
return productsDO;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+4
-4
@@ -1,9 +1,9 @@
|
||||
package com.cf.imes.module.system.service.recharge;
|
||||
package com.cf.imes.module.system.service.funds.recharge;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.module.system.controller.admin.recharge.vo.RechargePageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.recharge.vo.RechargeSaveReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.recharge.GiftMoneyDetailsDO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.recharge.vo.RechargePageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.recharge.vo.RechargeSaveReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.recharge.GiftMoneyDetailsDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
package com.cf.imes.module.system.service.funds.recharge;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.Assert.AssertUtils;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.system.controller.admin.funds.recharge.vo.RechargePageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.recharge.vo.RechargeSaveReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.recharge.GiftMoneyDetailsDO;
|
||||
import com.cf.imes.module.system.dal.mysql.funds.recharge.GiftMoneyDetailsMapper;
|
||||
import com.cf.imes.module.system.util.SnowflakeIdWorker3rd;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.RECHARGE_ACTIVE_NAME_IS_EXIST;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.RECHARGE_ACTIVE_NO_EXIST;
|
||||
|
||||
/**
|
||||
* 充值活动详情表 gift_money_details Service 实现类
|
||||
*
|
||||
* @author 晨丰科技
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class RechargeActiveServiceImpl implements RechargeActiveService{
|
||||
|
||||
@Resource
|
||||
private SnowflakeIdWorker3rd idWorker;
|
||||
|
||||
@Resource
|
||||
private GiftMoneyDetailsMapper giftMoneyDetailsMapper;
|
||||
|
||||
@Override
|
||||
public Long create(RechargeSaveReqVO createReqVO) {
|
||||
|
||||
Long id = idWorker.nextId();
|
||||
|
||||
GiftMoneyDetailsDO giftMoneyDetailsDO = giftMoneyDetailsMapper.selectOne(new LambdaQueryWrapperX<GiftMoneyDetailsDO>()
|
||||
.eq(GiftMoneyDetailsDO::getDeleted, false)
|
||||
.eq(GiftMoneyDetailsDO::getActivityName,createReqVO.getActivityName()));
|
||||
|
||||
AssertUtils.empty(giftMoneyDetailsDO,RECHARGE_ACTIVE_NAME_IS_EXIST);
|
||||
|
||||
GiftMoneyDetailsDO giftMoneyDetailsDOn = BeanUtils.toBean(createReqVO, GiftMoneyDetailsDO.class).setId(id);
|
||||
giftMoneyDetailsMapper.insert(giftMoneyDetailsDOn);
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(RechargeSaveReqVO updateReqVO) {
|
||||
validateRechargeActiveExists(updateReqVO.getId());
|
||||
|
||||
GiftMoneyDetailsDO giftMoneyDetailsDO = giftMoneyDetailsMapper.selectOne(new LambdaQueryWrapperX<GiftMoneyDetailsDO>()
|
||||
.eq(GiftMoneyDetailsDO::getDeleted, false)
|
||||
.eq(GiftMoneyDetailsDO::getActivityName,updateReqVO.getActivityName())
|
||||
.ne(GiftMoneyDetailsDO::getId,updateReqVO.getId()));
|
||||
|
||||
AssertUtils.empty(giftMoneyDetailsDO,RECHARGE_ACTIVE_NAME_IS_EXIST);
|
||||
|
||||
GiftMoneyDetailsDO giftMoneyDetailsDOn = BeanUtils.toBean(updateReqVO, GiftMoneyDetailsDO.class);
|
||||
giftMoneyDetailsMapper.updateById(giftMoneyDetailsDOn);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void delete(Long id) {
|
||||
validateRechargeActiveExists(id);
|
||||
giftMoneyDetailsMapper.deleteById(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public GiftMoneyDetailsDO get(Long id) {
|
||||
return validateRechargeActiveExists(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PageResult<GiftMoneyDetailsDO> getPage(RechargePageReqVO pageReqVO) {
|
||||
return giftMoneyDetailsMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 校验是否存在
|
||||
private GiftMoneyDetailsDO validateRechargeActiveExists(Long id) {
|
||||
if (id == null) {
|
||||
throw exception(RECHARGE_ACTIVE_NO_EXIST);
|
||||
}
|
||||
GiftMoneyDetailsDO giftMoneyDetailsDO = giftMoneyDetailsMapper.selectOne(new LambdaQueryWrapperX<GiftMoneyDetailsDO>()
|
||||
.eq(GiftMoneyDetailsDO::getId, id)
|
||||
.eq(GiftMoneyDetailsDO::getDeleted, false));
|
||||
if (giftMoneyDetailsDO == null) {
|
||||
throw exception(RECHARGE_ACTIVE_NO_EXIST);
|
||||
}
|
||||
|
||||
return giftMoneyDetailsDO;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.cf.imes.module.system.service.parser;
|
||||
|
||||
|
||||
import com.cf.imes.module.system.controller.admin.parser.vo.ParserReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.parser.vo.ParserRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.parser.vo.ParserSimpleRespVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author 解析器管理 Service 接口
|
||||
*/
|
||||
public interface ParserService {
|
||||
|
||||
|
||||
void update(ParserReqVO reqVO);
|
||||
|
||||
|
||||
Map<Integer, List<ParserRespVO>> getParserTree(Long type);
|
||||
|
||||
|
||||
Map<Integer, List<ParserSimpleRespVO>> getParserSimple(Long type);
|
||||
|
||||
|
||||
ParserRespVO getParser(Long id);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
package com.cf.imes.module.system.service.parser;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.system.controller.admin.parser.vo.ParserReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.parser.vo.ParserRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.parser.vo.ParserSimpleRespVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.parser.ParserDO;
|
||||
import com.cf.imes.module.system.dal.mysql.parser.ParserMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.getUserOrganId;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.PARSER_NO_EXIST;
|
||||
|
||||
/**
|
||||
* @author 解析器管理 Service 实现类
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class ParserServiceImpl implements ParserService{
|
||||
|
||||
|
||||
|
||||
@Resource
|
||||
private ParserMapper parserMapper;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void update(ParserReqVO reqVO) {
|
||||
|
||||
ParserDO parserDO = validateParserExists(reqVO.getId());
|
||||
|
||||
parserDO.setName(reqVO.getName());
|
||||
parserDO.setSetting(reqVO.getSetting());
|
||||
|
||||
parserMapper.updateById(parserDO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Map<Integer, List<ParserRespVO>> getParserTree(Long type) {
|
||||
|
||||
|
||||
List<ParserDO> parserDOS = parserMapper.selectList(new LambdaQueryWrapperX<ParserDO>()
|
||||
.eqIfPresent(ParserDO::getOrganId, getUserOrganId())
|
||||
.eq(ParserDO::getDeleted,false)
|
||||
.eqIfPresent(ParserDO::getParserType, type));
|
||||
|
||||
|
||||
if(CollUtil.isEmpty(parserDOS)){
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
|
||||
List<ParserRespVO> respVOS = BeanUtils.toBean(parserDOS, ParserRespVO.class);
|
||||
|
||||
return respVOS.stream().collect(Collectors.groupingBy(ParserRespVO::getParserType));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Map<Integer, List<ParserSimpleRespVO>> getParserSimple(Long type) {
|
||||
|
||||
List<ParserDO> parserDOS = parserMapper.selectList(new LambdaQueryWrapperX<ParserDO>()
|
||||
.eqIfPresent(ParserDO::getOrganId, getUserOrganId())
|
||||
.eq(ParserDO::getDeleted,false)
|
||||
.eqIfPresent(ParserDO::getParserType, type)
|
||||
.select(ParserDO::getId,ParserDO::getName,ParserDO::getParserType));
|
||||
|
||||
if(CollUtil.isEmpty(parserDOS)){
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
List<ParserSimpleRespVO> respVOS = BeanUtils.toBean(parserDOS, ParserSimpleRespVO.class);
|
||||
|
||||
return respVOS.stream().collect(Collectors.groupingBy(ParserSimpleRespVO::getParserType));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ParserRespVO getParser(Long id) {
|
||||
|
||||
ParserDO parserDO = validateParserExists(id);
|
||||
|
||||
return BeanUtils.toBean(parserDO,ParserRespVO.class);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private ParserDO validateParserExists(Long id) {
|
||||
|
||||
ParserDO parserDO = parserMapper.selectById(id);
|
||||
if (parserDO == null) {
|
||||
|
||||
throw exception(PARSER_NO_EXIST);
|
||||
}
|
||||
|
||||
return parserDO;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.cf.imes.module.system.service.parser;
|
||||
|
||||
|
||||
import com.cf.imes.module.system.controller.admin.parser.vo.ParserTemplateReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.parser.vo.ParserTemplateRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.parser.vo.TemplateLimitReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.parser.vo.TemplateSimpleRespVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author 解析器模板管理 Service 接口
|
||||
*/
|
||||
public interface ParserTemplateService {
|
||||
|
||||
|
||||
void update(ParserTemplateReqVO reqVO);
|
||||
|
||||
|
||||
Map<Integer, List<ParserTemplateRespVO>> getParserTemplateTree(Long type);
|
||||
|
||||
|
||||
ParserTemplateRespVO getParserTemplate(Long id);
|
||||
|
||||
|
||||
void updateParserTemplateLimit(TemplateLimitReqVO reqVO);
|
||||
|
||||
Map<Integer, List<TemplateSimpleRespVO>> getParserTemplateSimple(Long type);
|
||||
|
||||
|
||||
List<Long> getOrganParserTemplateLimit(Long organId);
|
||||
|
||||
}
|
||||
+241
@@ -0,0 +1,241 @@
|
||||
package com.cf.imes.module.system.service.parser;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.system.controller.admin.parser.vo.ParserTemplateReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.parser.vo.ParserTemplateRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.parser.vo.TemplateLimitReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.parser.vo.TemplateSimpleRespVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.parser.ParserDO;
|
||||
import com.cf.imes.module.system.dal.dataobject.parser.ParserLimitDO;
|
||||
import com.cf.imes.module.system.dal.dataobject.parser.ParserTemplateDO;
|
||||
import com.cf.imes.module.system.dal.mysql.parser.ParserLimitMapper;
|
||||
import com.cf.imes.module.system.dal.mysql.parser.ParserMapper;
|
||||
import com.cf.imes.module.system.dal.mysql.parser.ParserTemplateMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.PARSER_TEMPLATE_NO_EXIST;
|
||||
|
||||
|
||||
/**
|
||||
* @author 解析器模板管理 Service 实现类
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ParserTemplateServiceImpl implements ParserTemplateService{
|
||||
|
||||
|
||||
@Resource
|
||||
private ParserTemplateMapper parserTemplateMapper;
|
||||
|
||||
@Resource
|
||||
private ParserMapper parserMapper;
|
||||
|
||||
|
||||
@Resource
|
||||
private ParserLimitMapper parserLimitMapper;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void update(ParserTemplateReqVO reqVO) {
|
||||
|
||||
ParserTemplateDO parserTemplateDO = validateParserTemplateExists(reqVO.getId());
|
||||
|
||||
parserTemplateDO.setName(reqVO.getName());
|
||||
parserTemplateDO.setSetting(reqVO.getSetting());
|
||||
parserTemplateDO.setIsEnabled(reqVO.getIsEnabled());
|
||||
|
||||
parserTemplateMapper.updateById(parserTemplateDO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Map<Integer, List<ParserTemplateRespVO>> getParserTemplateTree(Long type) {
|
||||
|
||||
List<ParserTemplateDO> parserTemplateDOS = parserTemplateMapper.selectList(new LambdaQueryWrapperX<ParserTemplateDO>()
|
||||
.eq(ParserTemplateDO::getDeleted,false)
|
||||
.eqIfPresent(ParserTemplateDO::getParserType, type));
|
||||
|
||||
if(CollUtil.isEmpty(parserTemplateDOS)){
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
List<ParserTemplateRespVO> respVOS = BeanUtils.toBean(parserTemplateDOS, ParserTemplateRespVO.class);
|
||||
|
||||
return respVOS.stream().collect(Collectors.groupingBy(ParserTemplateRespVO::getParserType));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ParserTemplateRespVO getParserTemplate(Long id) {
|
||||
|
||||
ParserTemplateDO parserTemplateDO = validateParserTemplateExists(id);
|
||||
|
||||
return BeanUtils.toBean(parserTemplateDO,ParserTemplateRespVO.class);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void updateParserTemplateLimit(TemplateLimitReqVO reqVO) {
|
||||
|
||||
Long organId = reqVO.getOrganId();
|
||||
|
||||
ParserLimitDO parserLimitDO = parserLimitMapper.selectById(organId);
|
||||
|
||||
if(parserLimitDO == null){
|
||||
return;
|
||||
}
|
||||
|
||||
List<Long> parserTemplateIds = reqVO.getParserTemplateIds();
|
||||
|
||||
if(CollUtil.isNotEmpty(parserTemplateIds)){
|
||||
|
||||
String templateIds = Optional.ofNullable(parserLimitDO.getParserIds()).orElse("[]");
|
||||
|
||||
List<Long> templateIdList = JSON.parseArray(templateIds).toJavaList(Long.class).stream().distinct().toList();
|
||||
|
||||
Result result = compareLists(parserTemplateIds, templateIdList);
|
||||
|
||||
// 组织新增解析器
|
||||
List<Long> onlyInA = result.onlyInA;
|
||||
if(CollUtil.isNotEmpty(onlyInA)){
|
||||
List<ParserTemplateDO> parserTemplateDOS = parserTemplateMapper.selectBatchIds(onlyInA);
|
||||
|
||||
List<ParserDO> parserDOS = new ArrayList<>();
|
||||
parserTemplateDOS.forEach(f-> parserDOS.add(
|
||||
ParserDO.builder()
|
||||
.parserType(f.getParserType())
|
||||
.parserTemplateId(f.getId())
|
||||
.organId(organId)
|
||||
.name(f.getName())
|
||||
.setting(f.getSetting())
|
||||
.build()
|
||||
));
|
||||
|
||||
parserMapper.insertBatch(parserDOS);
|
||||
|
||||
}
|
||||
|
||||
// 删除组织的解析器
|
||||
List<Long> onlyInB = result.onlyInB;
|
||||
if(CollUtil.isNotEmpty(onlyInB)){
|
||||
parserMapper.delete(new LambdaQueryWrapperX<ParserDO>()
|
||||
.eq(ParserDO::getOrganId, organId)
|
||||
.eq(ParserDO::getDeleted,false)
|
||||
.in(ParserDO::getId, onlyInB));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Map<Integer, List<TemplateSimpleRespVO>> getParserTemplateSimple(Long type) {
|
||||
|
||||
List<ParserTemplateDO> parserTemplateDOS = parserTemplateMapper.selectList(new LambdaQueryWrapperX<ParserTemplateDO>()
|
||||
.eq(ParserTemplateDO::getDeleted,false)
|
||||
.eq(ParserTemplateDO::getIsEnabled,true)
|
||||
.eqIfPresent(ParserTemplateDO::getParserType, type)
|
||||
.select(ParserTemplateDO::getId,ParserTemplateDO::getName,ParserTemplateDO::getParserType));
|
||||
|
||||
if(CollUtil.isEmpty(parserTemplateDOS)){
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
List<TemplateSimpleRespVO> respVOS = BeanUtils.toBean(parserTemplateDOS, TemplateSimpleRespVO.class);
|
||||
|
||||
return respVOS.stream().collect(Collectors.groupingBy(TemplateSimpleRespVO::getParserType));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<Long> getOrganParserTemplateLimit(Long organId) {
|
||||
|
||||
ParserLimitDO parserLimitDO = parserLimitMapper.selectById(organId);
|
||||
if(parserLimitDO == null){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
String templateIds = Optional.ofNullable(parserLimitDO.getParserIds()).orElse("[]");
|
||||
|
||||
return JSON.parseArray(templateIds).toJavaList(Long.class).stream().distinct().toList();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private ParserTemplateDO validateParserTemplateExists(Long id) {
|
||||
|
||||
ParserTemplateDO parserTemplateDO = parserTemplateMapper.selectById(id);
|
||||
if (parserTemplateDO == null) {
|
||||
|
||||
throw exception(PARSER_TEMPLATE_NO_EXIST);
|
||||
}
|
||||
|
||||
return parserTemplateDO;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static Result compareLists(List<Long> a, List<Long> b) {
|
||||
Set<Long> setA = new HashSet<>(a);
|
||||
Set<Long> setB = new HashSet<>(b);
|
||||
|
||||
// 创建副本用于计算差集
|
||||
Set<Long> onlyInA = new HashSet<>(setA);
|
||||
onlyInA.removeAll(setB); // A 中有但 B 中没有的
|
||||
|
||||
Set<Long> onlyInB = new HashSet<>(setB);
|
||||
onlyInB.removeAll(setA); // B 中有但 A 中没有的
|
||||
|
||||
return new Result(new ArrayList<>(onlyInA), new ArrayList<>(onlyInB));
|
||||
}
|
||||
|
||||
|
||||
|
||||
static class Result {
|
||||
List<Long> onlyInA;
|
||||
List<Long> onlyInB;
|
||||
|
||||
public Result(List<Long> onlyInA, List<Long> onlyInB) {
|
||||
this.onlyInA = onlyInA;
|
||||
this.onlyInB = onlyInB;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
-253
@@ -1,253 +0,0 @@
|
||||
package com.cf.imes.module.system.service.products;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.nacos.common.utils.StringUtils;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.system.controller.admin.products.vo.productDetails.ProductDetailsPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.products.vo.productDetails.ProductDetailsSaveReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.products.ProductsDO;
|
||||
import com.cf.imes.module.system.dal.dataobject.products.ProductsDetailDO;
|
||||
import com.cf.imes.module.system.dal.mysql.products.ProductsDetailMapper;
|
||||
import com.cf.imes.module.system.dal.mysql.products.ProductsMapper;
|
||||
import com.cf.imes.module.system.enums.products.DurationUnitEnum;
|
||||
import com.cf.imes.module.system.enums.products.ProductsPurchaseTypeEnum;
|
||||
import com.cf.imes.module.system.util.SnowflakeIdWorker3rd;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 产品明细 productsDetails Service 实现类
|
||||
*
|
||||
* @author 晨丰科技
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ProductsDetailServiceImpl implements ProductsDetailService {
|
||||
|
||||
@Resource
|
||||
private ProductsDetailMapper productDetailsMapper;
|
||||
|
||||
@Resource
|
||||
private ProductsMapper productsMapper;
|
||||
|
||||
@Resource
|
||||
private SnowflakeIdWorker3rd idWorker;
|
||||
|
||||
private static final String EMPTY_STRING = new String();
|
||||
private static final String DURATION_NUM = "\\d+";
|
||||
private static final String DURATION_UNIT = "[a-zA-Z]+";
|
||||
|
||||
@Override
|
||||
public Long create(ProductDetailsSaveReqVO createReqVO) {
|
||||
// 校验是否有这个产品
|
||||
validateProductExist(createReqVO.getProductId(), false);
|
||||
|
||||
if (createReqVO.getPurchaseType() == ProductsPurchaseTypeEnum.DURATION.getStatus()) {
|
||||
if (StringUtils.isBlank(createReqVO.getDuration())) {
|
||||
throw exception(PRODUCTS_DURATION_NOT_NULL);
|
||||
}
|
||||
// 校验时长
|
||||
String duration = checkDuration(createReqVO.getDuration());
|
||||
String giftDuration = null;
|
||||
if (createReqVO.getGiftDuration() != null) {
|
||||
giftDuration = checkDuration(createReqVO.getGiftDuration());
|
||||
}
|
||||
createReqVO.setDuration(duration).setGiftDuration(giftDuration);
|
||||
|
||||
// 时长/产量 去重
|
||||
checkProductDetails(createReqVO, false);
|
||||
} else if (createReqVO.getPurchaseType() == ProductsPurchaseTypeEnum.OUTPUT.getStatus()) {
|
||||
if (StringUtils.isBlank(createReqVO.getDuration())) {
|
||||
throw exception(PRODUCTS_OUTPUT_NOT_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
Long id = idWorker.nextId();
|
||||
createReqVO.setId(id);
|
||||
ProductsDetailDO productDetailsDO = BeanUtils.toBean(createReqVO, ProductsDetailDO.class).setId(id);
|
||||
productDetailsMapper.insert(productDetailsDO);
|
||||
return id ;
|
||||
}
|
||||
|
||||
// 时长校验
|
||||
private String checkDuration(String duration){
|
||||
int number = extractDuration(duration);
|
||||
String unit = extractDurationUnit(duration);
|
||||
return number + "-" + unit;
|
||||
}
|
||||
|
||||
// 数字提取
|
||||
private int extractDuration(String duration) {
|
||||
Pattern pattern = Pattern.compile(DURATION_NUM);
|
||||
Matcher matcher = pattern.matcher(duration);
|
||||
|
||||
List<String> numbers = new ArrayList<>();
|
||||
while (matcher.find()) {
|
||||
numbers.add(matcher.group());
|
||||
}
|
||||
|
||||
if (numbers.size() != 1) {
|
||||
throw exception(PRODUCTS_DURATION_NUM_ERR);
|
||||
}
|
||||
|
||||
String numberStr = numbers.get(0);
|
||||
int number;
|
||||
try {
|
||||
number = Integer.parseInt(numberStr);
|
||||
} catch (NumberFormatException e) {
|
||||
throw exception(PRODUCTS_DURATION_NUM_ERR);
|
||||
}
|
||||
|
||||
// 校验数值是否为正整数(>0)
|
||||
if (number < 0) {
|
||||
throw exception(PRODUCTS_DURATION_INT_ERR);
|
||||
}
|
||||
|
||||
// 校验字符串格式(禁止前导零)
|
||||
if (numberStr.startsWith("0") && numberStr.length() > 1) {
|
||||
throw exception(PRODUCTS_DURATION_NUM_ERR);
|
||||
}
|
||||
|
||||
return number;
|
||||
}
|
||||
|
||||
// 时长单位提取
|
||||
private String extractDurationUnit(String duration){
|
||||
Pattern pattern = Pattern.compile(DURATION_UNIT);
|
||||
Matcher matcher = pattern.matcher(duration);
|
||||
|
||||
while (matcher.find()) {
|
||||
String unit = matcher.group();
|
||||
if (DurationUnitEnum.isYear(unit)) {
|
||||
return DurationUnitEnum.YEAR.getName();
|
||||
} else if (DurationUnitEnum.isMonth(unit)) {
|
||||
return DurationUnitEnum.MONTH.getName();
|
||||
} else if (DurationUnitEnum.isDay(unit)) {
|
||||
return DurationUnitEnum.DAY.getName();
|
||||
}
|
||||
}
|
||||
throw exception(PRODUCTS_DURATION_UNIT_ERR);
|
||||
}
|
||||
// 产品存在性校验
|
||||
private void validateProductExist(Long productId, boolean deleted){
|
||||
ProductsDO productsDO = productsMapper.selectOne(new LambdaQueryWrapperX<ProductsDO>()
|
||||
.eq(ProductsDO::getId, productId)
|
||||
.eq(ProductsDO::getDeleted, deleted));
|
||||
if (productsDO == null) {
|
||||
throw exception(PRODUCTS_NO_EXIST);
|
||||
}
|
||||
}
|
||||
// 时长/产量去重
|
||||
private void checkProductDetails(ProductDetailsSaveReqVO createReqVO, Boolean flag){
|
||||
int count;
|
||||
if (createReqVO.getPurchaseType() == 0){
|
||||
//时长去重
|
||||
count = productDetailsMapper.selectCountByDuration(createReqVO.getDuration(), createReqVO.getProductId(), flag);
|
||||
if (count > 0) {
|
||||
throw exception(PRODUCTS_DETAIL_DURATION_EXIST);
|
||||
}
|
||||
}else if (createReqVO.getPurchaseType() == 1){
|
||||
//产量去重
|
||||
count = productDetailsMapper.selectCountByOutput(createReqVO.getOutput(), createReqVO.getProductId(), flag);
|
||||
if (count > 0) {
|
||||
throw exception(PRODUCTS_DETAIL_OUTPUT_EXIST);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(ProductDetailsSaveReqVO updateReqVO) {
|
||||
// 校验是否有这个产品
|
||||
validateProductExist(updateReqVO.getProductId(), false);
|
||||
|
||||
validateProductDetailsExists(updateReqVO.getId(), false);
|
||||
|
||||
if (updateReqVO.getPurchaseType() == ProductsPurchaseTypeEnum.DURATION.getStatus()) {
|
||||
if (StringUtils.isBlank(updateReqVO.getDuration())) {
|
||||
throw exception(PRODUCTS_DURATION_NOT_NULL);
|
||||
}
|
||||
// 校验时长
|
||||
String duration = checkDuration(updateReqVO.getDuration());
|
||||
String giftDuration = null;
|
||||
if (updateReqVO.getGiftDuration() != null) {
|
||||
giftDuration = checkDuration(updateReqVO.getGiftDuration());
|
||||
}
|
||||
updateReqVO.setDuration(duration).setGiftDuration(giftDuration);
|
||||
|
||||
// 时长/产量 去重
|
||||
checkProductDetails(updateReqVO, true);
|
||||
} else if (updateReqVO.getPurchaseType() == ProductsPurchaseTypeEnum.OUTPUT.getStatus()) {
|
||||
if (StringUtils.isBlank(updateReqVO.getDuration())) {
|
||||
throw exception(PRODUCTS_OUTPUT_NOT_NULL);
|
||||
}
|
||||
}
|
||||
ProductsDetailDO productDetailsDO = BeanUtils.toBean(updateReqVO, ProductsDetailDO.class)
|
||||
.setDiscount(getZeroBigDecimal(updateReqVO.getDiscount()))
|
||||
.setOriginalPrice(getZeroBigDecimal(updateReqVO.getOriginalPrice()))
|
||||
.setIsDiscounted(updateReqVO.getIsDiscounted() ? Boolean.TRUE : Boolean.FALSE);
|
||||
productDetailsMapper.updateById(productDetailsDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* value为空返回EMPTY_STRING
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
private String getEmpty(String value) {
|
||||
return StringUtils.defaultIfEmpty(value, EMPTY_STRING);
|
||||
}
|
||||
|
||||
/**
|
||||
* value为空返回0.0
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
private BigDecimal getZeroBigDecimal(BigDecimal value) {
|
||||
return ObjectUtil.defaultIfNull(value, BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long id) {
|
||||
// 判单是否存在
|
||||
validateProductDetailsExists(id, false);
|
||||
productDetailsMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductsDetailDO> get(Long id) {
|
||||
validateProductDetailsExists(id, false);
|
||||
return productDetailsMapper.selectList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ProductsDetailDO> getPage(ProductDetailsPageReqVO pageReqVO) {
|
||||
return productDetailsMapper.selectPage(pageReqVO.setDeleted(0));
|
||||
}
|
||||
|
||||
// 判断是否存在
|
||||
private void validateProductDetailsExists(Long id, boolean deleted) {
|
||||
if (id == null) {
|
||||
throw exception(PRODUCTS_DETAIL_NO_EXIST);
|
||||
}
|
||||
if (productDetailsMapper.selectOne(new LambdaQueryWrapperX<ProductsDetailDO>()
|
||||
.eq(ProductsDetailDO::getId, id)
|
||||
.eq(ProductsDetailDO::getDeleted, false)) == null) {
|
||||
throw exception(PRODUCTS_DETAIL_NO_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-86
@@ -1,86 +0,0 @@
|
||||
package com.cf.imes.module.system.service.products;
|
||||
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.system.controller.admin.products.vo.product.ProductPageReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.products.ProductsDO;
|
||||
import com.cf.imes.module.system.dal.mysql.products.ProductsMapper;
|
||||
import com.cf.imes.module.system.util.SnowflakeIdWorker3rd;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.PRODUCTS_NO_EXIST;
|
||||
|
||||
/**
|
||||
* 产品 products Service 实现类
|
||||
*
|
||||
* @author 晨丰科技
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ProductsServiceImpl implements ProductsService{
|
||||
|
||||
@Resource
|
||||
private ProductsMapper productsMapper;
|
||||
|
||||
@Resource
|
||||
private SnowflakeIdWorker3rd idWorker;
|
||||
|
||||
@Override
|
||||
public Long create(String productName) {
|
||||
Long id = idWorker.nextId();
|
||||
productsMapper.insert(
|
||||
new ProductsDO()
|
||||
.setId(id)
|
||||
.setProductName(productName)
|
||||
.setStatus(1)
|
||||
.setSoftwareId(0)
|
||||
);
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(ProductsDO updateReqVO) {
|
||||
validateProductPlateExists(updateReqVO.getId());
|
||||
|
||||
productsMapper.updateById(updateReqVO);
|
||||
}
|
||||
|
||||
private void validateProductPlateExists(Long id) {
|
||||
ProductsDO productsDO = getProductWithFalse(id);
|
||||
if (productsDO == null) {
|
||||
throw exception(PRODUCTS_NO_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
public ProductsDO getProductWithFalse(Long id) {
|
||||
return productsMapper.selectOne(new LambdaQueryWrapperX<ProductsDO>()
|
||||
.eq(ProductsDO::getId, id)
|
||||
.eq(ProductsDO::getDeleted, false));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long id) {
|
||||
validateProductPlateExists(id);
|
||||
productsMapper.updateById(
|
||||
new ProductsDO()
|
||||
.setId(id)
|
||||
.setDeleted(true)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductsDO get(Long id) {
|
||||
return getProductWithFalse(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ProductsDO> getPage(ProductPageReqVO pageReqVO) {
|
||||
return productsMapper.selectPage(pageReqVO, false);
|
||||
}
|
||||
}
|
||||
-75
@@ -1,75 +0,0 @@
|
||||
package com.cf.imes.module.system.service.recharge;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.system.controller.admin.recharge.vo.RechargePageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.recharge.vo.RechargeSaveReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.recharge.GiftMoneyDetailsDO;
|
||||
import com.cf.imes.module.system.dal.mysql.recharge.GiftMoneyDetailsMapper;
|
||||
import com.cf.imes.module.system.util.SnowflakeIdWorker3rd;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.RECHARGE_ACTIVE_NO_EXIST;
|
||||
|
||||
/**
|
||||
* 充值活动详情表 gift_money_details Service 实现类
|
||||
*
|
||||
* @author 晨丰科技
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class RechargeActiveServiceImpl implements RechargeActiveService{
|
||||
|
||||
@Resource
|
||||
private SnowflakeIdWorker3rd idWorker;
|
||||
|
||||
@Resource
|
||||
private GiftMoneyDetailsMapper giftMoneyDetailsMapper;
|
||||
|
||||
@Override
|
||||
public Long create(RechargeSaveReqVO createReqVO) {
|
||||
Long id = idWorker.nextId();
|
||||
GiftMoneyDetailsDO giftMoneyDetailsDOn = BeanUtils.toBean(createReqVO, GiftMoneyDetailsDO.class).setId(id);
|
||||
giftMoneyDetailsMapper.insert(giftMoneyDetailsDOn);
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(RechargeSaveReqVO updateReqVO) {
|
||||
validateRechargeActiveExists(updateReqVO.getId(), false);
|
||||
}
|
||||
|
||||
// 校验是否存在
|
||||
private void validateRechargeActiveExists(Long id, boolean deleted) {
|
||||
if (id == null) {
|
||||
throw exception(RECHARGE_ACTIVE_NO_EXIST);
|
||||
}
|
||||
GiftMoneyDetailsDO dictType = giftMoneyDetailsMapper.selectOne(new LambdaQueryWrapperX<GiftMoneyDetailsDO>()
|
||||
.eq(GiftMoneyDetailsDO::getId, id)
|
||||
.eq(GiftMoneyDetailsDO::getDeleted, deleted));
|
||||
if (dictType == null) {
|
||||
throw exception(RECHARGE_ACTIVE_NO_EXIST);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void delete(Long id) {
|
||||
validateRechargeActiveExists(id, false);
|
||||
giftMoneyDetailsMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GiftMoneyDetailsDO get(Long id) {
|
||||
validateRechargeActiveExists(id, false);
|
||||
return giftMoneyDetailsMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<GiftMoneyDetailsDO> getPage(RechargePageReqVO pageReqVO) {
|
||||
return giftMoneyDetailsMapper.selectPage(pageReqVO);
|
||||
}
|
||||
}
|
||||
@@ -88,6 +88,10 @@ xxl:
|
||||
admin:
|
||||
addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址
|
||||
|
||||
# 广告图片文件
|
||||
adImageFile:
|
||||
filepath: E:\ceshi123\
|
||||
|
||||
--- #################### 服务保障相关配置 ####################
|
||||
|
||||
# Lock4j 配置项
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
<?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.cf.imes.module.system.dal.mysql.funds.advertisement.AdvertisementMapper">
|
||||
|
||||
|
||||
<update id="updateAdStatusIsPublish">
|
||||
|
||||
update advertisement
|
||||
set stats = 1
|
||||
where deleted = false
|
||||
and start_time = #{now}
|
||||
and status = #{status}
|
||||
|
||||
</update>
|
||||
|
||||
|
||||
<update id="updateAdStatusIsEndPublished">
|
||||
|
||||
|
||||
update advertisement
|
||||
set stats = 2
|
||||
where deleted = false
|
||||
and end_time = #{now}
|
||||
and status = #{status}
|
||||
|
||||
</update>
|
||||
|
||||
|
||||
|
||||
<select id="selectAdList"
|
||||
resultType="com.cf.imes.module.system.controller.admin.funds.advertisement.vo.AdvertisementRespVO">
|
||||
|
||||
|
||||
select id,
|
||||
ad_image_path,
|
||||
sort,
|
||||
ad_redirect_url
|
||||
|
||||
from advertisement
|
||||
|
||||
where deleted = false
|
||||
and ad_image_path like concat('%', #{adPosition},'%')
|
||||
and status = #{status}
|
||||
and start_time <= #{now}
|
||||
and end_time >= #{now}
|
||||
order by sort desc , update_time desc
|
||||
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user