1、新增评分量化表

2、新增费用项
3、新增币种
4、新增客商类型
5、其他bug修复
This commit is contained in:
2026-07-16 17:04:46 +08:00
parent 29bbd5144d
commit 0eba4ca98d
57 changed files with 4740 additions and 0 deletions

View File

@@ -0,0 +1,171 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.excel.util.ExcelUtil;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.excel.CurrencyExcel;
import org.springblade.system.excel.CurrencyImporter;
import org.springblade.system.pojo.entity.Currency;
import org.springblade.system.pojo.vo.CurrencyVO;
import org.springblade.system.service.ICurrencyService;
import org.springblade.system.wrapper.CurrencyWrapper;
import org.springframework.web.bind.annotation.GetMapping;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 币种主数据 控制器
*
* @author Chill
*/
@NonDS
@RestController
@AllArgsConstructor
@PreAuth(menu = "currency")
@RequestMapping("/currency")
@Tag(name = "币种主数据", description = "币种主数据")
public class CurrencyController extends BladeController {
private final ICurrencyService currencyService;
/**
* 详情
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@Operation(summary = "详情", description = "传入currency")
public R<CurrencyVO> detail(Currency currency) {
Currency detail = currencyService.getOne(Condition.getQueryWrapper(currency));
return R.data(CurrencyWrapper.build().entityVO(detail));
}
/**
* 分页
*/
@GetMapping("/list")
@ApiOperationSupport(order = 2)
@Operation(summary = "分页", description = "传入currency")
public R<IPage<CurrencyVO>> list(CurrencyVO currency, Query query) {
IPage<CurrencyVO> pages = currencyService.selectCurrencyPage(Condition.getPage(query), currency);
return R.data(pages);
}
/**
* 新增或修改
*/
@PostMapping("/submit")
@ApiOperationSupport(order = 3)
@Operation(summary = "新增或修改", description = "传入currency")
public R submit(@Valid @RequestBody Currency currency) {
return R.status(currencyService.submit(currency));
}
/**
* 删除
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 4)
@Operation(summary = "逻辑删除", description = "传入ids")
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
return R.status(currencyService.deleteLogic(Func.toLongList(ids)));
}
/**
* 启用或停用
*/
@PostMapping("/status")
@ApiOperationSupport(order = 5)
@Operation(summary = "启用或停用", description = "传入id和status")
public R status(@Parameter(description = "主键", required = true) @RequestParam Long id,
@Parameter(description = "状态", required = true) @RequestParam Integer status) {
return R.status(currencyService.changeStatus(id, status));
}
/**
* 导入币种主数据
*/
@PostMapping("/import-currency")
@ApiOperationSupport(order = 6)
@Operation(summary = "导入币种主数据", description = "传入excel")
public R importCurrency(MultipartFile file) {
CurrencyImporter currencyImporter = new CurrencyImporter(currencyService);
ExcelUtil.save(file, currencyImporter, CurrencyExcel.class);
return R.success("操作成功");
}
/**
* 导出币种主数据
*/
@GetMapping("/export-currency")
@ApiOperationSupport(order = 7)
@Operation(summary = "导出币种主数据")
public void exportCurrency(@Parameter(hidden = true) @RequestParam Map<String, Object> currency, HttpServletResponse response) {
Object ids = currency.remove("ids");
QueryWrapper<Currency> queryWrapper = Condition.getQueryWrapper(currency, Currency.class);
if (Func.isNotEmpty(ids)) {
queryWrapper.lambda().in(Currency::getId, Func.toLongList(ids.toString()));
}
List<CurrencyExcel> list = currencyService.exportCurrency(queryWrapper);
ExcelUtil.export(response, "币种主数据" + DateUtil.time(), "币种主数据表", list, CurrencyExcel.class);
}
/**
* 导出模板
*/
@GetMapping("/export-template")
@ApiOperationSupport(order = 8)
@Operation(summary = "导出模板")
public void exportTemplate(HttpServletResponse response) {
List<CurrencyExcel> list = new ArrayList<>();
ExcelUtil.export(response, "币种主数据模板", "币种主数据表", list, CurrencyExcel.class);
}
}

View File

@@ -0,0 +1,121 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.pojo.entity.CustomerType;
import org.springblade.system.pojo.vo.CustomerTypeVO;
import org.springblade.system.service.ICustomerTypeService;
import org.springblade.system.wrapper.CustomerTypeWrapper;
import org.springframework.web.bind.annotation.GetMapping;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* 客商类型 控制器
*
* @author Chill
*/
@NonDS
@RestController
@AllArgsConstructor
@PreAuth(menu = "customer_type")
@RequestMapping("/customer-type")
@Tag(name = "客商类型", description = "客商类型")
public class CustomerTypeController extends BladeController {
private final ICustomerTypeService customerTypeService;
/**
* 详情
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@Operation(summary = "详情", description = "传入customerType")
public R<CustomerTypeVO> detail(CustomerType customerType) {
CustomerType detail = customerTypeService.getOne(Condition.getQueryWrapper(customerType));
return R.data(CustomerTypeWrapper.build().entityVO(detail));
}
/**
* 分页
*/
@GetMapping("/list")
@ApiOperationSupport(order = 2)
@Operation(summary = "分页", description = "传入customerType")
public R<IPage<CustomerTypeVO>> list(CustomerTypeVO customerType, Query query) {
IPage<CustomerTypeVO> pages = customerTypeService.selectCustomerTypePage(Condition.getPage(query), customerType);
return R.data(pages);
}
/**
* 新增或修改
*/
@PostMapping("/submit")
@ApiOperationSupport(order = 3)
@Operation(summary = "新增或修改", description = "传入customerType")
public R submit(@Valid @RequestBody CustomerType customerType) {
return R.status(customerTypeService.submit(customerType));
}
/**
* 删除
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 4)
@Operation(summary = "逻辑删除", description = "传入ids")
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
return R.status(customerTypeService.deleteLogic(Func.toLongList(ids)));
}
/**
* 启用或停用
*/
@PostMapping("/status")
@ApiOperationSupport(order = 5)
@Operation(summary = "启用或停用", description = "传入id和status")
public R status(@Parameter(description = "主键", required = true) @RequestParam Long id,
@Parameter(description = "状态", required = true) @RequestParam Integer status) {
return R.status(customerTypeService.changeStatus(id, status));
}
}

View File

@@ -0,0 +1,121 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.pojo.entity.FeeItem;
import org.springblade.system.pojo.vo.FeeItemVO;
import org.springblade.system.service.IFeeItemService;
import org.springblade.system.wrapper.FeeItemWrapper;
import org.springframework.web.bind.annotation.GetMapping;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* 费用项 控制器
*
* @author Chill
*/
@NonDS
@RestController
@AllArgsConstructor
@PreAuth(menu = "fee_item")
@RequestMapping("/fee-item")
@Tag(name = "费用项", description = "费用项")
public class FeeItemController extends BladeController {
private final IFeeItemService feeItemService;
/**
* 详情
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@Operation(summary = "详情", description = "传入feeItem")
public R<FeeItemVO> detail(FeeItem feeItem) {
FeeItem detail = feeItemService.getOne(Condition.getQueryWrapper(feeItem));
return R.data(FeeItemWrapper.build().entityVO(detail));
}
/**
* 分页
*/
@GetMapping("/list")
@ApiOperationSupport(order = 2)
@Operation(summary = "分页", description = "传入feeItem")
public R<IPage<FeeItemVO>> list(FeeItemVO feeItem, Query query) {
IPage<FeeItemVO> pages = feeItemService.selectFeeItemPage(Condition.getPage(query), feeItem);
return R.data(pages);
}
/**
* 新增或修改
*/
@PostMapping("/submit")
@ApiOperationSupport(order = 3)
@Operation(summary = "新增或修改", description = "传入feeItem")
public R submit(@Valid @RequestBody FeeItem feeItem) {
return R.status(feeItemService.submit(feeItem));
}
/**
* 删除
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 4)
@Operation(summary = "逻辑删除", description = "传入ids")
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
return R.status(feeItemService.deleteLogic(Func.toLongList(ids)));
}
/**
* 启用或停用
*/
@PostMapping("/status")
@ApiOperationSupport(order = 5)
@Operation(summary = "启用或停用", description = "传入id和status")
public R status(@Parameter(description = "主键", required = true) @RequestParam Long id,
@Parameter(description = "状态", required = true) @RequestParam Integer status) {
return R.status(feeItemService.changeStatus(id, status));
}
}

View File

@@ -0,0 +1,88 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.excel;
import cn.idev.excel.annotation.ExcelIgnore;
import cn.idev.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.write.style.ColumnWidth;
import cn.idev.excel.annotation.write.style.ContentRowHeight;
import cn.idev.excel.annotation.write.style.HeadRowHeight;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 币种主数据 Excel
*
* @author Chill
*/
@Data
@ColumnWidth(18)
@HeadRowHeight(20)
@ContentRowHeight(18)
public class CurrencyExcel implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@ExcelIgnore
private Long id;
@ExcelProperty("币种代码")
private String code;
@ExcelProperty("币种中文名称")
private String name;
@ExcelProperty("币种英文名称")
private String englishName;
@ExcelProperty("货币符号")
private String symbol;
@ExcelProperty("小数位数")
private Integer decimalPlaces;
@ExcelProperty("汇率")
private BigDecimal exchangeRate;
@ExcelProperty("是否本位币")
private String baseCurrencyName;
@ExcelProperty("数据来源")
private String dataSource;
@ExcelProperty("状态")
private String statusName;
@ExcelProperty("备注")
private String remark;
@ExcelProperty("报错文案")
private String errorMessage;
}

View File

@@ -0,0 +1,49 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.excel;
import lombok.RequiredArgsConstructor;
import org.springblade.core.excel.support.ExcelImporter;
import org.springblade.system.service.ICurrencyService;
import java.util.List;
/**
* 币种主数据导入类
*
* @author Chill
*/
@RequiredArgsConstructor
public class CurrencyImporter implements ExcelImporter<CurrencyExcel> {
private final ICurrencyService service;
@Override
public void save(List<CurrencyExcel> data) {
service.importCurrency(data);
}
}

View File

@@ -0,0 +1,52 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.springblade.system.pojo.entity.Currency;
import org.springblade.system.pojo.vo.CurrencyVO;
import java.util.List;
/**
* 币种主数据 Mapper 接口
*
* @author Chill
*/
public interface CurrencyMapper extends BaseMapper<Currency> {
/**
* 自定义分页
*
* @param page 分页参数
* @param currency 查询参数
* @return 币种分页
*/
List<CurrencyVO> selectCurrencyPage(IPage<CurrencyVO> page, @Param("currency") CurrencyVO currency);
}

View File

@@ -0,0 +1,56 @@
<?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="org.springblade.system.mapper.CurrencyMapper">
<resultMap id="currencyResultMap" type="org.springblade.system.pojo.vo.CurrencyVO">
<result column="id" property="id"/>
<result column="create_user" property="createUser"/>
<result column="create_dept" property="createDept"/>
<result column="create_time" property="createTime"/>
<result column="update_user" property="updateUser"/>
<result column="update_time" property="updateTime"/>
<result column="status" property="status"/>
<result column="is_deleted" property="isDeleted"/>
<result column="code" property="code"/>
<result column="name" property="name"/>
<result column="english_name" property="englishName"/>
<result column="symbol" property="symbol"/>
<result column="decimal_places" property="decimalPlaces"/>
<result column="exchange_rate" property="exchangeRate"/>
<result column="is_base_currency" property="baseCurrency"/>
<result column="data_source" property="dataSource"/>
<result column="remark" property="remark"/>
</resultMap>
<select id="selectCurrencyPage" resultMap="currencyResultMap">
SELECT
*
FROM
blade_currency
WHERE
is_deleted = 0
<if test="currency.code != null and currency.code != ''">
<bind name="codeLike" value="'%' + currency.code + '%'"/>
AND code LIKE #{codeLike}
</if>
<if test="currency.name != null and currency.name != ''">
<bind name="nameLike" value="'%' + currency.name + '%'"/>
AND name LIKE #{nameLike}
</if>
<if test="currency.englishName != null and currency.englishName != ''">
<bind name="englishNameLike" value="'%' + currency.englishName + '%'"/>
AND english_name LIKE #{englishNameLike}
</if>
<if test="currency.baseCurrency != null">
AND is_base_currency = #{currency.baseCurrency}
</if>
<if test="currency.dataSource != null and currency.dataSource != ''">
AND data_source = #{currency.dataSource}
</if>
<if test="currency.status != null">
AND status = #{currency.status}
</if>
ORDER BY update_time DESC, create_time DESC
</select>
</mapper>

View File

@@ -0,0 +1,52 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.springblade.system.pojo.entity.CustomerType;
import org.springblade.system.pojo.vo.CustomerTypeVO;
import java.util.List;
/**
* 客商类型 Mapper 接口
*
* @author Chill
*/
public interface CustomerTypeMapper extends BaseMapper<CustomerType> {
/**
* 自定义分页
*
* @param page 分页参数
* @param customerType 查询参数
* @return 客商类型分页
*/
List<CustomerTypeVO> selectCustomerTypePage(IPage<CustomerTypeVO> page, @Param("customerType") CustomerTypeVO customerType);
}

View File

@@ -0,0 +1,39 @@
<?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="org.springblade.system.mapper.CustomerTypeMapper">
<resultMap id="customerTypeResultMap" type="org.springblade.system.pojo.vo.CustomerTypeVO">
<result column="id" property="id"/>
<result column="create_user" property="createUser"/>
<result column="create_dept" property="createDept"/>
<result column="create_time" property="createTime"/>
<result column="update_user" property="updateUser"/>
<result column="update_time" property="updateTime"/>
<result column="status" property="status"/>
<result column="is_deleted" property="isDeleted"/>
<result column="name" property="name"/>
<result column="english_name" property="englishName"/>
</resultMap>
<select id="selectCustomerTypePage" resultMap="customerTypeResultMap">
SELECT
*
FROM
blade_customer_type
WHERE
is_deleted = 0
<if test="customerType.name != null and customerType.name != ''">
<bind name="nameLike" value="'%' + customerType.name + '%'"/>
AND name LIKE #{nameLike}
</if>
<if test="customerType.englishName != null and customerType.englishName != ''">
<bind name="englishNameLike" value="'%' + customerType.englishName + '%'"/>
AND english_name LIKE #{englishNameLike}
</if>
<if test="customerType.status != null">
AND status = #{customerType.status}
</if>
ORDER BY update_time DESC, create_time DESC
</select>
</mapper>

View File

@@ -0,0 +1,52 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.springblade.system.pojo.entity.FeeItem;
import org.springblade.system.pojo.vo.FeeItemVO;
import java.util.List;
/**
* 费用项 Mapper 接口
*
* @author Chill
*/
public interface FeeItemMapper extends BaseMapper<FeeItem> {
/**
* 自定义分页
*
* @param page 分页参数
* @param feeItem 查询参数
* @return 费用项分页
*/
List<FeeItemVO> selectFeeItemPage(IPage<FeeItemVO> page, @Param("feeItem") FeeItemVO feeItem);
}

View File

@@ -0,0 +1,39 @@
<?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="org.springblade.system.mapper.FeeItemMapper">
<resultMap id="feeItemResultMap" type="org.springblade.system.pojo.vo.FeeItemVO">
<result column="id" property="id"/>
<result column="create_user" property="createUser"/>
<result column="create_dept" property="createDept"/>
<result column="create_time" property="createTime"/>
<result column="update_user" property="updateUser"/>
<result column="update_time" property="updateTime"/>
<result column="status" property="status"/>
<result column="is_deleted" property="isDeleted"/>
<result column="name" property="name"/>
<result column="english_name" property="englishName"/>
</resultMap>
<select id="selectFeeItemPage" resultMap="feeItemResultMap">
SELECT
*
FROM
blade_fee_item
WHERE
is_deleted = 0
<if test="feeItem.name != null and feeItem.name != ''">
<bind name="nameLike" value="'%' + feeItem.name + '%'"/>
AND name LIKE #{nameLike}
</if>
<if test="feeItem.englishName != null and feeItem.englishName != ''">
<bind name="englishNameLike" value="'%' + feeItem.englishName + '%'"/>
AND english_name LIKE #{englishNameLike}
</if>
<if test="feeItem.status != null">
AND status = #{feeItem.status}
</if>
ORDER BY update_time DESC, create_time DESC
</select>
</mapper>

View File

@@ -0,0 +1,85 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import org.springblade.system.excel.CurrencyExcel;
import org.springblade.system.pojo.entity.Currency;
import org.springblade.system.pojo.vo.CurrencyVO;
import java.util.List;
/**
* 币种主数据 服务类
*
* @author Chill
*/
public interface ICurrencyService extends BaseService<Currency> {
/**
* 自定义分页
*
* @param page 分页参数
* @param currency 查询参数
* @return 币种分页
*/
IPage<CurrencyVO> selectCurrencyPage(IPage<CurrencyVO> page, CurrencyVO currency);
/**
* 新增或修改币种
*
* @param currency 币种
* @return 是否成功
*/
boolean submit(Currency currency);
/**
* 启用或停用
*
* @param id 主键
* @param status 状态
* @return 是否成功
*/
boolean changeStatus(Long id, Integer status);
/**
* 导入币种
*
* @param data 导入数据
*/
void importCurrency(List<CurrencyExcel> data);
/**
* 导出币种
*
* @param queryWrapper 查询条件
* @return 导出数据
*/
List<CurrencyExcel> exportCurrency(Wrapper<Currency> queryWrapper);
}

View File

@@ -0,0 +1,66 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import org.springblade.system.pojo.entity.CustomerType;
import org.springblade.system.pojo.vo.CustomerTypeVO;
/**
* 客商类型 服务类
*
* @author Chill
*/
public interface ICustomerTypeService extends BaseService<CustomerType> {
/**
* 自定义分页
*
* @param page 分页参数
* @param customerType 查询参数
* @return 客商类型分页
*/
IPage<CustomerTypeVO> selectCustomerTypePage(IPage<CustomerTypeVO> page, CustomerTypeVO customerType);
/**
* 新增或修改客商类型
*
* @param customerType 客商类型
* @return 是否成功
*/
boolean submit(CustomerType customerType);
/**
* 启用或停用
*
* @param id 主键
* @param status 状态
* @return 是否成功
*/
boolean changeStatus(Long id, Integer status);
}

View File

@@ -0,0 +1,66 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import org.springblade.system.pojo.entity.FeeItem;
import org.springblade.system.pojo.vo.FeeItemVO;
/**
* 费用项 服务类
*
* @author Chill
*/
public interface IFeeItemService extends BaseService<FeeItem> {
/**
* 自定义分页
*
* @param page 分页参数
* @param feeItem 查询参数
* @return 费用项分页
*/
IPage<FeeItemVO> selectFeeItemPage(IPage<FeeItemVO> page, FeeItemVO feeItem);
/**
* 新增或修改费用项
*
* @param feeItem 费用项
* @return 是否成功
*/
boolean submit(FeeItem feeItem);
/**
* 启用或停用
*
* @param id 主键
* @param status 状态
* @return 是否成功
*/
boolean changeStatus(Long id, Integer status);
}

View File

@@ -0,0 +1,234 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.excel.CurrencyExcel;
import org.springblade.system.mapper.CurrencyMapper;
import org.springblade.system.pojo.entity.Currency;
import org.springblade.system.pojo.vo.CurrencyVO;
import org.springblade.system.service.ICurrencyService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.regex.Pattern;
/**
* 币种主数据 服务实现类
*
* @author Chill
*/
@Service
public class CurrencyServiceImpl extends BaseServiceImpl<CurrencyMapper, Currency> implements ICurrencyService {
private static final String SOURCE_BATCH = "批量导入";
private static final String SOURCE_MANUAL = "手工导入";
private static final int STATUS_ENABLED = 1;
private static final int STATUS_DISABLED = 2;
private static final int YES = 1;
private static final int NO = 0;
private static final int REMARK_MAX_LENGTH = 200;
private static final int MIN_DECIMAL_PLACES = 0;
private static final int MAX_DECIMAL_PLACES = 8;
private static final Pattern CURRENCY_CODE_PATTERN = Pattern.compile("^[A-Z]{3}$");
@Override
public IPage<CurrencyVO> selectCurrencyPage(IPage<CurrencyVO> page, CurrencyVO currency) {
return page.setRecords(baseMapper.selectCurrencyPage(page, currency));
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean submit(Currency currency) {
prepare(currency, SOURCE_MANUAL);
validate(currency);
return saveOrUpdate(currency);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean changeStatus(Long id, Integer status) {
if (Func.isEmpty(id)) {
throw new ServiceException("主键不能为空");
}
Currency currency = getById(id);
if (Func.isEmpty(currency)) {
throw new ServiceException("币种不存在");
}
if (!Objects.equals(status, STATUS_ENABLED) && !Objects.equals(status, STATUS_DISABLED)) {
throw new ServiceException("启停状态不正确");
}
Currency update = new Currency();
update.setId(id);
update.setStatus(status);
return updateById(update);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void importCurrency(List<CurrencyExcel> data) {
List<String> errorList = new ArrayList<>();
for (int index = 0; index < data.size(); index++) {
CurrencyExcel excel = data.get(index);
try {
Currency currency = Objects.requireNonNull(BeanUtil.copyProperties(excel, Currency.class));
currency.setBaseCurrency(parseBaseCurrency(excel.getBaseCurrencyName()));
currency.setDataSource(SOURCE_BATCH);
currency.setStatus(STATUS_ENABLED);
prepare(currency, SOURCE_BATCH);
validate(currency);
save(currency);
} catch (Exception exception) {
String message = exception instanceof ServiceException ? exception.getMessage() : "导入失败";
errorList.add("" + (index + 2) + "行:" + message);
}
}
if (Func.isNotEmpty(errorList)) {
throw new ServiceException(String.join("", errorList));
}
}
@Override
public List<CurrencyExcel> exportCurrency(Wrapper<Currency> queryWrapper) {
List<Currency> currencyList = list(queryWrapper);
return currencyList.stream().map(currency -> {
CurrencyExcel excel = Objects.requireNonNull(BeanUtil.copyProperties(currency, CurrencyExcel.class));
excel.setBaseCurrencyName(Objects.equals(currency.getBaseCurrency(), YES) ? "" : "");
excel.setStatusName(Objects.equals(currency.getStatus(), STATUS_ENABLED) ? "启用" : "停用");
return excel;
}).toList();
}
private void prepare(Currency currency, String defaultDataSource) {
currency.setCode(trimToEmpty(currency.getCode()).toUpperCase(Locale.ROOT));
currency.setName(trimToEmpty(currency.getName()));
currency.setEnglishName(trimToNull(currency.getEnglishName()));
currency.setSymbol(trimToNull(currency.getSymbol()));
currency.setRemark(trimToNull(currency.getRemark()));
currency.setDataSource(Func.toStrWithEmpty(currency.getDataSource(), defaultDataSource));
if (Func.isEmpty(currency.getDecimalPlaces())) {
currency.setDecimalPlaces(2);
}
if (Func.isEmpty(currency.getExchangeRate())) {
currency.setExchangeRate(BigDecimal.ONE);
}
if (Func.isEmpty(currency.getBaseCurrency())) {
currency.setBaseCurrency(NO);
}
if (Func.isEmpty(currency.getStatus())) {
currency.setStatus(STATUS_ENABLED);
}
}
private void validate(Currency currency) {
if (Func.isEmpty(currency.getCode())) {
throw new ServiceException("币种代码不能为空");
}
if (!CURRENCY_CODE_PATTERN.matcher(currency.getCode()).matches()) {
throw new ServiceException("币种代码为3位大写字母");
}
if (Func.isEmpty(currency.getName())) {
throw new ServiceException("币种中文名称不能为空");
}
if (currency.getDecimalPlaces() < MIN_DECIMAL_PLACES || currency.getDecimalPlaces() > MAX_DECIMAL_PLACES) {
throw new ServiceException("小数位数范围为0到8");
}
if (currency.getExchangeRate().compareTo(BigDecimal.ZERO) <= 0) {
throw new ServiceException("汇率必须大于0");
}
if (!Objects.equals(currency.getBaseCurrency(), YES) && !Objects.equals(currency.getBaseCurrency(), NO)) {
throw new ServiceException("是否本位币取值不正确");
}
if (Objects.equals(currency.getBaseCurrency(), YES) && currency.getExchangeRate().compareTo(BigDecimal.ONE) != 0) {
throw new ServiceException("本位币汇率必须为1");
}
if (Func.isNotEmpty(currency.getRemark()) && currency.getRemark().length() > REMARK_MAX_LENGTH) {
throw new ServiceException("备注不能超过200字");
}
validateUnique(currency, Currency::getCode, currency.getCode(), "该币种代码已存在");
validateBaseCurrency(currency);
}
private void validateUnique(Currency currency, com.baomidou.mybatisplus.core.toolkit.support.SFunction<Currency, ?> column, String value, String message) {
LambdaQueryWrapper<Currency> queryWrapper = Wrappers.<Currency>lambdaQuery()
.eq(column, value)
.eq(Currency::getIsDeleted, 0);
if (Func.isNotEmpty(currency.getId())) {
queryWrapper.ne(Currency::getId, currency.getId());
}
if (count(queryWrapper) > 0L) {
throw new ServiceException(message);
}
}
private void validateBaseCurrency(Currency currency) {
if (!Objects.equals(currency.getBaseCurrency(), YES)) {
return;
}
LambdaQueryWrapper<Currency> queryWrapper = Wrappers.<Currency>lambdaQuery()
.eq(Currency::getBaseCurrency, YES)
.eq(Currency::getIsDeleted, 0);
if (Func.isNotEmpty(currency.getId())) {
queryWrapper.ne(Currency::getId, currency.getId());
}
if (count(queryWrapper) > 0L) {
throw new ServiceException("本位币只能设置一个");
}
}
private Integer parseBaseCurrency(String value) {
String trimValue = trimToEmpty(value);
if (Func.isEmpty(trimValue) || "".equals(trimValue) || "0".equals(trimValue)) {
return NO;
}
if ("".equals(trimValue) || "1".equals(trimValue)) {
return YES;
}
throw new ServiceException("是否本位币只能填写是或否");
}
private String trimToEmpty(String value) {
return value == null ? "" : value.trim();
}
private String trimToNull(String value) {
String trimValue = trimToEmpty(value);
return trimValue.isEmpty() ? null : trimValue;
}
}

View File

@@ -0,0 +1,130 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.mapper.CustomerTypeMapper;
import org.springblade.system.pojo.entity.CustomerType;
import org.springblade.system.pojo.vo.CustomerTypeVO;
import org.springblade.system.service.ICustomerTypeService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Objects;
/**
* 客商类型 服务实现类
*
* @author Chill
*/
@Service
public class CustomerTypeServiceImpl extends BaseServiceImpl<CustomerTypeMapper, CustomerType> implements ICustomerTypeService {
private static final int STATUS_ENABLED = 1;
private static final int STATUS_DISABLED = 2;
private static final int NAME_MAX_LENGTH = 50;
private static final int ENGLISH_NAME_MAX_LENGTH = 100;
@Override
public IPage<CustomerTypeVO> selectCustomerTypePage(IPage<CustomerTypeVO> page, CustomerTypeVO customerType) {
return page.setRecords(baseMapper.selectCustomerTypePage(page, customerType));
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean submit(CustomerType customerType) {
prepare(customerType);
validate(customerType);
return saveOrUpdate(customerType);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean changeStatus(Long id, Integer status) {
if (Func.isEmpty(id)) {
throw new ServiceException("主键不能为空");
}
CustomerType customerType = getById(id);
if (Func.isEmpty(customerType)) {
throw new ServiceException("客商类型不存在");
}
if (!Objects.equals(status, STATUS_ENABLED) && !Objects.equals(status, STATUS_DISABLED)) {
throw new ServiceException("启停状态不正确");
}
CustomerType update = new CustomerType();
update.setId(id);
update.setStatus(status);
return updateById(update);
}
private void prepare(CustomerType customerType) {
customerType.setName(trimToEmpty(customerType.getName()));
customerType.setEnglishName(trimToNull(customerType.getEnglishName()));
if (Func.isEmpty(customerType.getStatus())) {
customerType.setStatus(STATUS_ENABLED);
}
}
private void validate(CustomerType customerType) {
if (Func.isEmpty(customerType.getName())) {
throw new ServiceException("中文名称不能为空");
}
if (customerType.getName().length() > NAME_MAX_LENGTH) {
throw new ServiceException("中文名称不能超过50字");
}
if (Func.isNotEmpty(customerType.getEnglishName()) && customerType.getEnglishName().length() > ENGLISH_NAME_MAX_LENGTH) {
throw new ServiceException("英文名称不能超过100字");
}
validateUniqueName(customerType);
}
private void validateUniqueName(CustomerType customerType) {
LambdaQueryWrapper<CustomerType> queryWrapper = Wrappers.<CustomerType>lambdaQuery()
.eq(CustomerType::getName, customerType.getName())
.eq(CustomerType::getIsDeleted, 0);
if (Func.isNotEmpty(customerType.getId())) {
queryWrapper.ne(CustomerType::getId, customerType.getId());
}
if (count(queryWrapper) > 0L) {
throw new ServiceException("该中文名称已存在");
}
}
private String trimToEmpty(String value) {
return value == null ? "" : value.trim();
}
private String trimToNull(String value) {
String trimValue = trimToEmpty(value);
return trimValue.isEmpty() ? null : trimValue;
}
}

View File

@@ -0,0 +1,130 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.mapper.FeeItemMapper;
import org.springblade.system.pojo.entity.FeeItem;
import org.springblade.system.pojo.vo.FeeItemVO;
import org.springblade.system.service.IFeeItemService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Objects;
/**
* 费用项 服务实现类
*
* @author Chill
*/
@Service
public class FeeItemServiceImpl extends BaseServiceImpl<FeeItemMapper, FeeItem> implements IFeeItemService {
private static final int STATUS_ENABLED = 1;
private static final int STATUS_DISABLED = 2;
private static final int NAME_MAX_LENGTH = 50;
private static final int ENGLISH_NAME_MAX_LENGTH = 100;
@Override
public IPage<FeeItemVO> selectFeeItemPage(IPage<FeeItemVO> page, FeeItemVO feeItem) {
return page.setRecords(baseMapper.selectFeeItemPage(page, feeItem));
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean submit(FeeItem feeItem) {
prepare(feeItem);
validate(feeItem);
return saveOrUpdate(feeItem);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean changeStatus(Long id, Integer status) {
if (Func.isEmpty(id)) {
throw new ServiceException("主键不能为空");
}
FeeItem feeItem = getById(id);
if (Func.isEmpty(feeItem)) {
throw new ServiceException("费用项不存在");
}
if (!Objects.equals(status, STATUS_ENABLED) && !Objects.equals(status, STATUS_DISABLED)) {
throw new ServiceException("启停状态不正确");
}
FeeItem update = new FeeItem();
update.setId(id);
update.setStatus(status);
return updateById(update);
}
private void prepare(FeeItem feeItem) {
feeItem.setName(trimToEmpty(feeItem.getName()));
feeItem.setEnglishName(trimToNull(feeItem.getEnglishName()));
if (Func.isEmpty(feeItem.getStatus())) {
feeItem.setStatus(STATUS_ENABLED);
}
}
private void validate(FeeItem feeItem) {
if (Func.isEmpty(feeItem.getName())) {
throw new ServiceException("中文名称不能为空");
}
if (feeItem.getName().length() > NAME_MAX_LENGTH) {
throw new ServiceException("中文名称不能超过50字");
}
if (Func.isNotEmpty(feeItem.getEnglishName()) && feeItem.getEnglishName().length() > ENGLISH_NAME_MAX_LENGTH) {
throw new ServiceException("英文名称不能超过100字");
}
validateUniqueName(feeItem);
}
private void validateUniqueName(FeeItem feeItem) {
LambdaQueryWrapper<FeeItem> queryWrapper = Wrappers.<FeeItem>lambdaQuery()
.eq(FeeItem::getName, feeItem.getName())
.eq(FeeItem::getIsDeleted, 0);
if (Func.isNotEmpty(feeItem.getId())) {
queryWrapper.ne(FeeItem::getId, feeItem.getId());
}
if (count(queryWrapper) > 0L) {
throw new ServiceException("该中文名称已存在");
}
}
private String trimToEmpty(String value) {
return value == null ? "" : value.trim();
}
private String trimToNull(String value) {
String trimValue = trimToEmpty(value);
return trimValue.isEmpty() ? null : trimValue;
}
}

View File

@@ -0,0 +1,51 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.wrapper;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.system.pojo.entity.Currency;
import org.springblade.system.pojo.vo.CurrencyVO;
import java.util.Objects;
/**
* 币种主数据包装类
*
* @author Chill
*/
public class CurrencyWrapper extends BaseEntityWrapper<Currency, CurrencyVO> {
public static CurrencyWrapper build() {
return new CurrencyWrapper();
}
@Override
public CurrencyVO entityVO(Currency currency) {
return Objects.requireNonNull(BeanUtil.copyProperties(currency, CurrencyVO.class));
}
}

View File

@@ -0,0 +1,51 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.wrapper;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.system.pojo.entity.CustomerType;
import org.springblade.system.pojo.vo.CustomerTypeVO;
import java.util.Objects;
/**
* 客商类型包装类
*
* @author Chill
*/
public class CustomerTypeWrapper extends BaseEntityWrapper<CustomerType, CustomerTypeVO> {
public static CustomerTypeWrapper build() {
return new CustomerTypeWrapper();
}
@Override
public CustomerTypeVO entityVO(CustomerType customerType) {
return Objects.requireNonNull(BeanUtil.copyProperties(customerType, CustomerTypeVO.class));
}
}

View File

@@ -0,0 +1,51 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.wrapper;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.system.pojo.entity.FeeItem;
import org.springblade.system.pojo.vo.FeeItemVO;
import java.util.Objects;
/**
* 费用项包装类
*
* @author Chill
*/
public class FeeItemWrapper extends BaseEntityWrapper<FeeItem, FeeItemVO> {
public static FeeItemWrapper build() {
return new FeeItemWrapper();
}
@Override
public FeeItemVO entityVO(FeeItem feeItem) {
return Objects.requireNonNull(BeanUtil.copyProperties(feeItem, FeeItemVO.class));
}
}