Compare commits

..

No commits in common. "473c8f3240a02d90ac06a6816dccd84cd01adb45" and "94bdcf4a6bf488d60b60cde99ec6d2901731be3b" have entirely different histories.

19 changed files with 31 additions and 407 deletions

View File

@ -23,7 +23,6 @@ import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.net.URL;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
@ -37,9 +36,14 @@ import java.util.Objects;
@RequestMapping("/file")
public class FileController extends ControllerBase {
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
@Resource
private IGongfuFileService fileService;
@Resource
private FileUploadService fileUploadService;
/**
* 文件搜索
*/
@ -55,24 +59,35 @@ public class FileController extends ControllerBase {
/**
* 文件上传
* @param type 类型1服务月报
* @param type 类型1服务月报
* @param fileName 文件名称
* @param fileUrl 文件地址
* @param file 文件
*/
@PostMapping("/upload")
public ApiResult<Void> upload(@RequestParam Integer type, @RequestParam String fileName, @RequestParam String fileUrl) throws IOException {
public ApiResult<Void> upload(@RequestParam Integer type,@RequestParam String fileName,@RequestParam MultipartFile file) throws IOException {
String url = fileUploadService.upload(buildFilePath(getFileType(file.getOriginalFilename())), file);
fileService.save(
new GongfuFile()
.setType(type)
.setFileName(fileName)
.setFileSuffix(FilenameUtils.getExtension(new URL(fileUrl).getPath()))
.setFileUrl(fileUrl)
.setFileSize(file.getSize())
.setFileSuffix(FilenameUtils.getExtension(file.getOriginalFilename()))
.setFileUrl(url)
.setCreateBy(AdminUserUtil.getUserName())
.setCreateTime(LocalDateTime.now())
);
return ApiResult.success();
}
private String buildFilePath(String fileType) {
return StrUtil.format("gongfu/{}/{}/{}/{}{}", LocalDateTime.now().format(FORMATTER), AdminUserUtil.getUserId()
, RandomUtil.randomString(4), IdUtil.fastUUID(), fileType);
}
private String getFileType(String fileName) {
return "." + FilenameUtils.getExtension(fileName).toLowerCase();
}
/**
* 文件删除
*/

View File

@ -26,7 +26,6 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Collections;
@ -79,7 +78,7 @@ public class ShoppingController extends ControllerBase {
/**
* 获取报价对象
*/
@GetMapping("/cart/getTargets")
@GetMapping("/getTargets")
public ApiResult<List<SimpleUserVO>> getTargets() {
if (AppUserUtil.isAgent()) {
return ApiResult.success(appUserService.getCustomers(AppUserUtil.getUserId())
@ -103,7 +102,7 @@ public class ShoppingController extends ControllerBase {
/**
* 根据机型查询售价
*/
@PostMapping("/cart/init")
@PostMapping("/init")
public ApiResult<ShoppingCartVO> init(@Valid @RequestBody ShoppingInitRequest request) {
Long categoryId = getCategoryId();
ModelPrice1VO modelPrice = priceService.getModelPrice(request.getModelId(), categoryId);
@ -128,7 +127,7 @@ public class ShoppingController extends ControllerBase {
}
}
//系数
Pair<BigDecimal, BigDecimal> pair = getRatio(request.getModelId());
Pair<BigDecimal, BigDecimal> pair = getRatio(request.getModelId(), categoryId);
BigDecimal standardRatio = pair.getLeft(), optionalRatio = pair.getRight();
log.debug("机型【{}】标准配件系数为{},可选配件系数为{}", request.getModelNo(), standardRatio, optionalRatio);
vo.setActualFee(vo.getActualFee().multiply(standardRatio));
@ -172,7 +171,7 @@ public class ShoppingController extends ControllerBase {
* 保存购物车
*/
@Transactional
@PostMapping("/cart/save")
@PostMapping("/save")
public ApiResult<Long> save(@Valid @RequestBody ShoppingSaveRequest request) {
QuotationShoppingCart cart;
if (Objects.nonNull(request.getId())) {
@ -238,54 +237,12 @@ public class ShoppingController extends ControllerBase {
/**
* 查询购物车
*/
@PostMapping("/cart/search")
public ApiResult<PageData<ShoppingSearchVO>> search(@Valid @RequestBody ShoppingSearchRequest request) {
return ApiResult.success(shoppingCartService.search(request, MultilingualUtil.getLanguage()));
@PostMapping("/search")
public ApiResult<PageData<ShoppingSearchVO>> search(@Valid @RequestBody ShoppingSearchRequest request){
return ApiResult.success(shoppingCartService.search(request,MultilingualUtil.getLanguage()));
}
/**
* 删除购物车
*/
@Transactional
@PostMapping("/cart/delete")
public ApiResult<Void> delete(@RequestParam Long id) {
QuotationShoppingCart cart = shoppingCartService.getById(id);
VUtils.trueThrowBusinessError(Objects.isNull(cart)).throwMessage("未找到购物车信息");
VUtils.trueThrowBusinessError(cart.getStatus() == 1).throwMessage("已生成报价单不能删除");
shoppingCartItemService.lambdaUpdate()
.eq(QuotationShoppingCartItem::getCartId, id)
.remove();
shoppingCartAccessoryService.lambdaUpdate()
.eq(QuotationShoppingCartAccessory::getCartId, id)
.remove();
shoppingCartServiceService.lambdaUpdate()
.eq(QuotationShoppingCartService::getCartId, id)
.remove();
shoppingCartService.removeById(id);
return ApiResult.success();
}
/**
* 生成报价单
*/
@PostMapping("/quotation/generate")
private ApiResult<Void> generate(@RequestBody @NotEmpty List<Long> cartIds) {
List<QuotationShoppingCart> carts = shoppingCartService.lambdaQuery()
.eq(QuotationShoppingCart::getStatus, 0)
.eq(QuotationShoppingCart::getCreateByType, AppUserUtil.isAgent() ? 1 : 0)
.eq(QuotationShoppingCart::getCreateById, AppUserUtil.getUserId())
.in(QuotationShoppingCart::getId, cartIds)
.list();
VUtils.trueThrowBusinessError(CollectionUtil.isEmpty(carts)).throwMessage("未找到购物车信息");
VUtils.trueThrowBusinessError(carts.stream().map(QuotationShoppingCart::getCustomerName).collect(Collectors.toSet()).size() > 1)
.throwMessage("客户名称不一致");
VUtils.trueThrowBusinessError(carts.stream().map(QuotationShoppingCart::getTargetId).collect(Collectors.toSet()).size() > 1)
.throwMessage("报价对象不一致");
//TODO
return ApiResult.success();
}
private Pair<BigDecimal, BigDecimal> getRatio(Long modelId) {
private Pair<BigDecimal, BigDecimal> getRatio(Long modelId, Long categoryId) {
Pair<BigDecimal, BigDecimal> pair = Pair.of(BigDecimal.ONE, BigDecimal.ONE);
if (AppUserUtil.isAgent()) {
//代理商

View File

@ -153,6 +153,7 @@ public class ShoppingSaveRequest {
/**
* 汇率
*/
@NotNull
private BigDecimal exchangeRate;
/**

View File

@ -1,93 +0,0 @@
package com.nflg.mobilebroken.repository.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
/**
* <p>
* 报价-报价单
* </p>
*
* @author 代码生成器生成
* @since 2026
*/
@Getter
@Setter
@Accessors(chain = true)
@TableName("quotation_shopping_order")
public class QuotationShoppingOrder implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
/**
* 报价编号
*/
private String no;
/**
* 客户名称
*/
private String customerName;
/**
* 报价对象
*/
private Integer targetId;
/**
* 优惠金额
*/
private BigDecimal discount;
/**
* 总价
*/
private BigDecimal totalFee;
/**
* 实际总价
*/
private BigDecimal actualFee;
/**
* 报价生效时间
*/
private String effectiveStartTime;
/**
* 报价失效时间
*/
private String effectiveEndTime;
/**
* 创建人类型0内部人员1代理商
*/
private Integer createByType;
/**
* 创建人id
*/
private Integer createById;
/**
* 创建人
*/
private String createBy;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 最后修改时间
*/
private LocalDateTime updateTime;
}

View File

@ -1,48 +0,0 @@
package com.nflg.mobilebroken.repository.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
/**
* <p>
* 报价-报价单-调价记录
* </p>
*
* @author 代码生成器生成
* @since 2026
*/
@Getter
@Setter
@Accessors(chain = true)
@TableName("quotation_shopping_order_adjust")
public class QuotationShoppingOrderAdjust implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
/**
* 报价单id
*/
private Long orderId;
/**
* 优惠金额
*/
private BigDecimal discount;
/**
* 实际总价
*/
private BigDecimal actualFee;
/**
* 创建时间
*/
private LocalDateTime createTime;
}

View File

@ -1,37 +0,0 @@
package com.nflg.mobilebroken.repository.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
/**
* <p>
* 报价-报价单-子项
* </p>
*
* @author 代码生成器生成
* @since 2026
*/
@Getter
@Setter
@Accessors(chain = true)
@TableName("quotation_shopping_order_item")
public class QuotationShoppingOrderItem implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
/**
* 购物车id
*/
private Long cartId;
/**
* 标配价格调价后价格
*/
private BigDecimal standardFee;
}

View File

@ -1,16 +0,0 @@
package com.nflg.mobilebroken.repository.mapper;
import com.nflg.mobilebroken.repository.entity.QuotationShoppingOrderAdjust;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 报价-报价单-调价记录 Mapper 接口
* </p>
*
* @author 代码生成器生成
* @since 2026
*/
public interface QuotationShoppingOrderAdjustMapper extends BaseMapper<QuotationShoppingOrderAdjust> {
}

View File

@ -1,16 +0,0 @@
package com.nflg.mobilebroken.repository.mapper;
import com.nflg.mobilebroken.repository.entity.QuotationShoppingOrderItem;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 报价-报价单-子项 Mapper 接口
* </p>
*
* @author 代码生成器生成
* @since 2026
*/
public interface QuotationShoppingOrderItemMapper extends BaseMapper<QuotationShoppingOrderItem> {
}

View File

@ -1,16 +0,0 @@
package com.nflg.mobilebroken.repository.mapper;
import com.nflg.mobilebroken.repository.entity.QuotationShoppingOrder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 报价-报价单 Mapper 接口
* </p>
*
* @author 代码生成器生成
* @since 2026
*/
public interface QuotationShoppingOrderMapper extends BaseMapper<QuotationShoppingOrder> {
}

View File

@ -1,16 +0,0 @@
package com.nflg.mobilebroken.repository.service;
import com.nflg.mobilebroken.repository.entity.QuotationShoppingOrderAdjust;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 报价-报价单-调价记录 服务类
* </p>
*
* @author 代码生成器生成
* @since 2026
*/
public interface IQuotationShoppingOrderAdjustService extends IService<QuotationShoppingOrderAdjust> {
}

View File

@ -1,16 +0,0 @@
package com.nflg.mobilebroken.repository.service;
import com.nflg.mobilebroken.repository.entity.QuotationShoppingOrderItem;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 报价-报价单-子项 服务类
* </p>
*
* @author 代码生成器生成
* @since 2026
*/
public interface IQuotationShoppingOrderItemService extends IService<QuotationShoppingOrderItem> {
}

View File

@ -1,16 +0,0 @@
package com.nflg.mobilebroken.repository.service;
import com.nflg.mobilebroken.repository.entity.QuotationShoppingOrder;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 报价-报价单 服务类
* </p>
*
* @author 代码生成器生成
* @since 2026
*/
public interface IQuotationShoppingOrderService extends IService<QuotationShoppingOrder> {
}

View File

@ -1,20 +0,0 @@
package com.nflg.mobilebroken.repository.service.impl;
import com.nflg.mobilebroken.repository.entity.QuotationShoppingOrderAdjust;
import com.nflg.mobilebroken.repository.mapper.QuotationShoppingOrderAdjustMapper;
import com.nflg.mobilebroken.repository.service.IQuotationShoppingOrderAdjustService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 报价-报价单-调价记录 服务实现类
* </p>
*
* @author 代码生成器生成
* @since 2026
*/
@Service
public class QuotationShoppingOrderAdjustServiceImpl extends ServiceImpl<QuotationShoppingOrderAdjustMapper, QuotationShoppingOrderAdjust> implements IQuotationShoppingOrderAdjustService {
}

View File

@ -1,20 +0,0 @@
package com.nflg.mobilebroken.repository.service.impl;
import com.nflg.mobilebroken.repository.entity.QuotationShoppingOrderItem;
import com.nflg.mobilebroken.repository.mapper.QuotationShoppingOrderItemMapper;
import com.nflg.mobilebroken.repository.service.IQuotationShoppingOrderItemService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 报价-报价单-子项 服务实现类
* </p>
*
* @author 代码生成器生成
* @since 2026
*/
@Service
public class QuotationShoppingOrderItemServiceImpl extends ServiceImpl<QuotationShoppingOrderItemMapper, QuotationShoppingOrderItem> implements IQuotationShoppingOrderItemService {
}

View File

@ -1,20 +0,0 @@
package com.nflg.mobilebroken.repository.service.impl;
import com.nflg.mobilebroken.repository.entity.QuotationShoppingOrder;
import com.nflg.mobilebroken.repository.mapper.QuotationShoppingOrderMapper;
import com.nflg.mobilebroken.repository.service.IQuotationShoppingOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 报价-报价单 服务实现类
* </p>
*
* @author 代码生成器生成
* @since 2026
*/
@Service
public class QuotationShoppingOrderServiceImpl extends ServiceImpl<QuotationShoppingOrderMapper, QuotationShoppingOrder> implements IQuotationShoppingOrderService {
}

View File

@ -1,5 +0,0 @@
<?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.nflg.mobilebroken.repository.mapper.QuotationShoppingOrderAdjustMapper">
</mapper>

View File

@ -1,5 +0,0 @@
<?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.nflg.mobilebroken.repository.mapper.QuotationShoppingOrderItemMapper">
</mapper>

View File

@ -1,5 +0,0 @@
<?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.nflg.mobilebroken.repository.mapper.QuotationShoppingOrderMapper">
</mapper>

View File

@ -33,7 +33,7 @@ public class CodeGeneratorTest {
, Paths.get(System.getProperty("user.dir")) + "/src/main/resources/mapper"))
)
.strategyConfig(builder -> {
builder.addInclude("quotation_shopping_order_adjust") //只生成指定表
builder.addInclude("quotation_shopping_cart_service") //只生成指定表
.entityBuilder()
.enableLombok()
.enableChainModel()