联调同步。

master
Tom Li 2 weeks ago
parent 7b284dc530
commit 1c0767d144
  1. 12
      src/main/java/org/springblade/modules/jinchao/controller/CustomerController.java
  2. 54
      src/main/java/org/springblade/modules/jinchao/controller/ProductController.java
  3. 7
      src/main/java/org/springblade/modules/jinchao/controller/ProductObjController.java
  4. 7
      src/main/java/org/springblade/modules/jinchao/pojo/entity/BizPriceEntity.java
  5. 5
      src/main/java/org/springblade/modules/jinchao/pojo/entity/ProductEntity.java
  6. 24
      src/main/java/org/springblade/modules/jinchao/pojo/vo/CustomerVO.java
  7. 4
      src/main/java/org/springblade/modules/jinchao/service/ICustomerService.java
  8. 46
      src/main/java/org/springblade/modules/jinchao/service/impl/CustomerServiceImpl.java
  9. 39
      src/main/java/org/springblade/modules/jinchao/service/impl/ProductServiceImpl.java

@ -33,15 +33,14 @@ import lombok.AllArgsConstructor;
import jakarta.validation.Valid;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.annotation.IsAdmin;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.jinchao.constant.BaseCol;
import org.springblade.modules.jinchao.pojo.request.CustomerSearch;
import org.springblade.modules.jinchao.pojo.request.CustomerSubmit;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -80,9 +79,12 @@ public class CustomerController extends BladeController {
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@Operation(summary = "详情", description = "传入customer")
public R<CustomerVO> detail(CustomerEntity customer) {
public R<CustomerSubmit> detail(CustomerEntity customer) {
CustomerEntity detail = service.getOne(Condition.getQueryWrapper(customer));
return R.data(CustomerWrapper.build().entityVO(detail));
CustomerSubmit submit = new CustomerSubmit();
BeanUtils.copyProperties(detail, submit);
service.setVoValueDetail(submit);
return R.data(submit);
}
/**
@ -100,7 +102,7 @@ public class CustomerController extends BladeController {
.orderByDesc(BaseCol.CREATE_TIME)
);
IPage<CustomerVO> pagesVo = CustomerWrapper.build().pageVO(pages);
pagesVo.getRecords().stream().peek(service::setVoValue).collect(Collectors.toList());
pagesVo.getRecords().stream().peek(service::setVoValueMain).collect(Collectors.toList());
return R.data(pagesVo);
}

@ -29,6 +29,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;
import jakarta.validation.Valid;
@ -37,8 +38,11 @@ import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.jinchao.constant.BaseCol;
import org.springblade.modules.jinchao.constant.ProductConst;
import org.springblade.modules.jinchao.pojo.entity.BizPriceEntity;
import org.springblade.modules.jinchao.pojo.vo.ProductVO;
import org.springblade.modules.jinchao.service.IBizPriceService;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -53,6 +57,7 @@ import org.springblade.core.excel.util.ExcelUtil;
import java.util.Map;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import jakarta.servlet.http.HttpServletResponse;
@ -68,7 +73,10 @@ import jakarta.servlet.http.HttpServletResponse;
@Tag(name = "[产品]", description = "[产品]接口")
public class ProductController extends BladeController {
private final IProductService service;
@Resource
private IProductService service;
@Resource
private IBizPriceService bizPriceService;
/**
* [产品] 详情
@ -157,24 +165,38 @@ public class ProductController extends BladeController {
@ApiOperationSupport(order = 6)
@Operation(summary = "批量新增或修改", description = "ProductEntity List")
public R submitBat(@Valid @RequestBody List<ProductVO> vos) {
// todo:删除的情况
//
if (vos != null && !vos.isEmpty()) {
for (ProductVO vo : vos) {
if (vo != null && Objects.equals(vo.getBizType(), ProductConst.TYPE_PRICE_CUSTOM)) {
// 跳过
continue;
}
if (Objects.requireNonNull(vo).getId() == null || vo.getId() == 0L) {
// 新增check
if (service.existsCode(vo.getCode())) {
return R.fail("已经存在此code");
}
if (service.existsNameCn(vo.getNameCn())) {
return R.fail("已经存在此nameCn");
final Integer bizType = vo.getBizType();
if (Objects.equals(bizType, ProductConst.TYPE_PRICE_STANDARD)) { // 标准价
if (Objects.requireNonNull(vo).getId() == null || vo.getId() == 0L) {
// 新增check
if (service.existsCode(vo.getCode())) {
return R.fail("已经存在此code");
}
if (service.existsNameCn(vo.getNameCn())) {
return R.fail("已经存在此nameCn");
}
// 新增
service.save(vo);
} else {
service.updateById(vo);
}
// 新增
service.save(vo);
} else {
service.updateById(vo);
} else if (Objects.equals(bizType, ProductConst.TYPE_PRICE_CUSTOM)) { // 指定价
QueryWrapper<BizPriceEntity> qw = new QueryWrapper<BizPriceEntity>()
.eq(BaseCol.ID, vo.getBizPriceId());
Optional<BizPriceEntity> opt = bizPriceService.getOneOpt(qw);
opt.ifPresent(
bp -> {
bp.setSaleUserId(vo.getSaleUserId());
bp.setCustomerId(vo.getCustomerId());
bp.setBizPrice(vo.getBizPrice());
bizPriceService.save(bp);
}
);
}
}
}

@ -41,6 +41,7 @@ import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.jinchao.constant.BaseCol;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -94,7 +95,11 @@ public class ProductObjController extends BladeController {
@ApiOperationSupport(order = 2)
@Operation(summary = "list分页", description = "传入productObj")
public R<IPage<ProductObjVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> productObj, Query query) {
IPage<ProductObjEntity> pages = productObjService.page(Condition.getPage(query), Condition.getQueryWrapper(productObj, ProductObjEntity.class));
IPage<ProductObjEntity> pages = productObjService.page(
Condition.getPage(query),
Condition.getQueryWrapper(productObj, ProductObjEntity.class)
.orderByAsc(BaseCol.ID)
);
return R.data(ProductObjWrapper.build().pageVO(pages));
}

@ -30,6 +30,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity;
import java.io.Serial;
/**
@ -47,6 +48,8 @@ public class BizPriceEntity extends TenantEntity {
@Serial
private static final long serialVersionUID = 1L;
public static final String COL_PRODUCT_ID = "product_id";
/**
* [产品]id
*/
@ -63,8 +66,8 @@ public class BizPriceEntity extends TenantEntity {
@Schema(description = "[客户]id")
private Long customerId;
/**
* 特定用户价格
* 特定业务员价格
*/
@Schema(description = "特定用户价格")
@Schema(description = "特定业务员价格")
private Double bizPrice;
}

@ -30,6 +30,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity;
import java.io.Serial;
/**
@ -47,6 +48,10 @@ public class ProductEntity extends TenantEntity {
@Serial
private static final long serialVersionUID = 1L;
public static final String COL_CODE = "code";
public static final String COL_NAME_CN = "name_cn";
/**
* 编号
*/

@ -32,6 +32,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.time.LocalDateTime;
/**
* [客户] 视图实体类
@ -46,22 +47,39 @@ public class CustomerVO extends CustomerEntity {
@Serial
private static final long serialVersionUID = 1L;
/**
* 创建人 真名
*/
@Schema(description = "创建人 真名")
private String createUserRealName;
/**
* 所属国家dict
*/
@Schema(description = "所属国家dict")
private String countryValue;
/**
* 客户来源dict
*/
@Schema(description = "客户来源dict")
private String fromTypeValue;
/**
* 主要[客户联系人]
*/
@Schema(description = "主要[客户联系人]")
private ContactEntity contactMain;
/**
* 最近订单状态
*/
@Schema(description = "最近订单状态")
private Integer lastOrderStatus = 2;
/**
* 最近订单状态
*/
@Schema(description = "最近订单状态")
private String lastOrderStatusValue = "已付款";
/**
* 最近成交时间
*/
@Schema(description = "最近成交时间")
private LocalDateTime lastOrderDealDateTime = LocalDateTime.now();
}

@ -69,5 +69,7 @@ public interface ICustomerService extends BaseService<CustomerEntity> {
R<List<CustomerEntity>> listForSelect();
void setVoValue(CustomerVO vo);
void setVoValueMain(CustomerVO vo);
void setVoValueDetail(CustomerSubmit submit);
}

@ -41,7 +41,9 @@ import org.springblade.modules.jinchao.excel.CustomerExcel;
import org.springblade.modules.jinchao.mapper.CustomerMapper;
import org.springblade.modules.jinchao.service.IContactService;
import org.springblade.modules.jinchao.service.ICustomerService;
import org.springblade.modules.system.pojo.entity.User;
import org.springblade.modules.system.service.IDictService;
import org.springblade.modules.system.service.IUserService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
@ -70,6 +72,8 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerMapper, Custome
private IContactService contactService;
@Resource
private IDictService dictService;
@Resource
private IUserService userService;
@Override
public IPage<CustomerVO> selectCustomerPage(IPage<CustomerVO> page, CustomerVO customer) {
@ -91,19 +95,19 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerMapper, Custome
if (submit.getContacts() == null || submit.getContacts().isEmpty()) {
return R.fail("contacts为空");
}
CustomerEntity cu = new CustomerEntity();
BeanUtils.copyProperties(submit, cu);
boolean save = save(cu);
CustomerEntity c = new CustomerEntity();
BeanUtils.copyProperties(submit, c);
boolean save = save(c);
for (int i = 0; i < submit.getContacts().size(); i++) {
ContactEntity co = submit.getContacts().get(i);
co.setId(null);
if (i == 1) {
if (i == 0) {
co.setContactType(ContactConst.TYPE_MAIN);
} else {
co.setContactType(ContactConst.TYPE_SECONDARY);
}
co.setSort(i);
co.setCustomerId(cu.getId());
co.setSort(i + 1);
co.setCustomerId(c.getId());
}
contactService.saveBatch(submit.getContacts());
return R.status(save);
@ -116,25 +120,29 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerMapper, Custome
}
CustomerEntity cu = new CustomerEntity();
BeanUtils.copyProperties(submit, cu);
boolean save = updateById(cu);
// 更新客户
boolean update = updateById(cu);
// List<ContactEntity> existList = contactService.list(
// new QueryWrapper<ContactEntity>().eq("", "")
// );
for (int i = 0; i < submit.getContacts().size(); i++) {
ContactEntity co = submit.getContacts().get(i);
co.setCustomerId(cu.getId());
if (co.getSort() == null || co.getSort() == 0L) {
co.setSort(i);
co.setSort(i + 1);
}
if (co.getContactType() == null || co.getContactType() == 0L) {
co.setContactType(ContactConst.TYPE_SECONDARY);
}
}
contactService.saveOrUpdateBatch(submit.getContacts());
return R.status(save);
return R.status(update);
}
@Override
public IPage<CustomerVO> search(IPage<CustomerVO> page, CustomerSearch search) {
IPage<CustomerVO> pagesVo = page.setRecords(baseMapper.searchPage(page, search));
pagesVo.getRecords().stream().peek(this::setVoValue).collect(Collectors.toList());
pagesVo.getRecords().stream().peek(this::setVoValueMain).collect(Collectors.toList());
return pagesVo;
}
@ -147,7 +155,7 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerMapper, Custome
}
@Override
public void setVoValue(CustomerVO vo) {
public void setVoValueMain(CustomerVO vo) {
vo.setCountryValue(dictService.getValue(ContactConst.DICT_CUSTOMER_COUNTRY, vo.getCountry()));
vo.setFromTypeValue(dictService.getValue(ContactConst.DICT_CUSTOMER_FROM_TYPE, vo.getFromType()));
{
@ -160,5 +168,21 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerMapper, Custome
vo.setContactMain(contactF);
}
}
{
User uC = userService.getById(vo.getCreateUser());
if (uC != null) {
vo.setCreateUserRealName(uC.getRealName());
}
}
}
@Override
public void setVoValueDetail(CustomerSubmit submit) {
List<ContactEntity> list = contactService.list(
new QueryWrapper<ContactEntity>()
.eq("customer_id", submit.getId())
.orderByAsc("sort")
);
submit.setContacts(list);
}
}

@ -79,7 +79,7 @@ public class ProductServiceImpl extends BaseServiceImpl<ProductMapper, ProductEn
private ICustomerService customerService;
@Override
public IPage<org.springblade.modules.jinchao.pojo.vo.ProductVO> selectProductPage(IPage<org.springblade.modules.jinchao.pojo.vo.ProductVO> page, org.springblade.modules.jinchao.pojo.vo.ProductVO product) {
public IPage<ProductVO> selectProductPage(IPage<ProductVO> page, ProductVO product) {
return page.setRecords(baseMapper.selectProductPage(page, product));
}
@ -101,30 +101,35 @@ public class ProductServiceImpl extends BaseServiceImpl<ProductMapper, ProductEn
IPage<ProductVO> pagesVo = ProductWrapper.build().pageVO(pages);
ListIterator<ProductVO> it = pagesVo.getRecords().listIterator();
while (it.hasNext()) {
ProductVO vo = it.next();
vo.setBizType(ProductConst.TYPE_PRICE_STANDARD);
ProductVO vo1 = it.next();
// 默认
vo1.setBizType(ProductConst.TYPE_PRICE_STANDARD);
// TYPE_PRICE_CUSTOM 数据是拼接上的
long count = bizPriceService.count(
new QueryWrapper<BizPriceEntity>().eq("product_id", vo.getId())
new QueryWrapper<BizPriceEntity>().eq(BizPriceEntity.COL_PRODUCT_ID, vo1.getId())
);
if (count != 0L) {
List<BizPriceEntity> listBP = bizPriceService.listByProductId(vo.getId());
List<BizPriceEntity> listBP = bizPriceService.listByProductId(vo1.getId());
listBP.forEach(bp -> {
log.info("bp = {}", bp);
ProductVO vo2 = new ProductVO();
BeanUtils.copyProperties(vo, vo2);
BeanUtils.copyProperties(vo1, vo2);
vo2.setId(vo1.getId());
// 特定价
vo2.setBizType(ProductConst.TYPE_PRICE_CUSTOM);
vo2.setBizPriceId(bp.getId());
BeanUtils.copyProperties(bp, vo2);
User u = userService.getById(vo2.getSaleUserId());
if (u != null) {
vo2.setSaleUserRealName(u.getRealName());
//
CustomerEntity customer = customerService.getById(bp.getCustomerId());
if (customer != null) {
vo2.setBizRemark("客户:" + customer.getCompanyName());
vo2.setCustomerCompanyName(customer.getCompanyName());
}
CustomerEntity c = customerService.getById(vo2.getCustomerId());
if (c != null) {
vo2.setCustomerCompanyName(c.getCompanyName());
{
User u = userService.getById(vo2.getSaleUserId());
if (u != null) {
vo2.setSaleUserRealName(u.getRealName());
}
}
vo2.setBizRemark("客户:" + customerService.getById(bp.getCustomerId()).getCompanyName());
it.add(vo2);
});
} else {
@ -136,12 +141,12 @@ public class ProductServiceImpl extends BaseServiceImpl<ProductMapper, ProductEn
@Override
public Boolean existsCode(String code) {
return baseMapper.exists(new QueryWrapper<ProductEntity>().eq("code", code));
return baseMapper.exists(new QueryWrapper<ProductEntity>().eq(ProductEntity.COL_CODE, code));
}
@Override
public Boolean existsNameCn(String nameCn) {
return baseMapper.exists(new QueryWrapper<ProductEntity>().eq("name_cn", nameCn));
return baseMapper.exists(new QueryWrapper<ProductEntity>().eq(ProductEntity.COL_NAME_CN, nameCn));
}
/**
@ -162,7 +167,7 @@ public class ProductServiceImpl extends BaseServiceImpl<ProductMapper, ProductEn
public R<List<ProductVO>> oneKeyMatch(List<ProductVO> list) {
List<ProductVO> listNew = list.stream()
.map(vo -> {
ProductEntity pFind = getOne(new QueryWrapper<ProductEntity>().eq("name_cn", vo.getNameCn()));
ProductEntity pFind = getOne(new QueryWrapper<ProductEntity>().eq(ProductEntity.COL_NAME_CN, vo.getNameCn()));
if (pFind != null) {
ProductVO voNew = new ProductVO();
BeanUtils.copyProperties(pFind, voNew);

Loading…
Cancel
Save