|
|
|
|
@ -36,6 +36,7 @@ import lombok.EqualsAndHashCode; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
import org.apache.velocity.runtime.directive.Break; |
|
|
|
|
import org.springblade.common.cache.UserCache; |
|
|
|
|
import org.springblade.core.mp.base.BaseEntity; |
|
|
|
|
import org.springblade.core.mp.support.Condition; |
|
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
|
@ -123,6 +124,7 @@ public class ProductServiceImpl extends BaseServiceImpl<ProductMapper, ProductEn |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public R<IPage<ProductVO>> list(Map<String, Object> map, Query query) { |
|
|
|
|
BladeUser user = AuthUtil.getUser(); |
|
|
|
|
Long customerId = map.get("customerId") == null ? null : Long.parseLong(map.get("customerId").toString()); |
|
|
|
|
Long catalogId = Long.parseLong((String) map.get("catalogId")); // 是Id [坏笑]。不是ld
|
|
|
|
|
if (catalogId == null || catalogId == 0L) { |
|
|
|
|
@ -140,6 +142,7 @@ public class ProductServiceImpl extends BaseServiceImpl<ProductMapper, ProductEn |
|
|
|
|
if (p != null) { |
|
|
|
|
ProductVO vo = ProductWrapper.build().entityVO(p); |
|
|
|
|
vo.setCatalogId(catalogId); |
|
|
|
|
vo.setBizType(ProductConst.BIZ_TYPE_PRICE_STANDARD); |
|
|
|
|
CatalogEntity catalogTwo = catalogService.getById(vo.getCatalogId()); |
|
|
|
|
CatalogEntity catalogOne = catalogService.getById(catalogTwo.getParentId()); |
|
|
|
|
vo.setCatalogOne(catalogOne.getName()); |
|
|
|
|
@ -151,53 +154,56 @@ public class ProductServiceImpl extends BaseServiceImpl<ProductMapper, ProductEn |
|
|
|
|
IPage<ProductVO> pagesVO = Condition.getPage(query); |
|
|
|
|
pagesVO.setRecords(listVO); |
|
|
|
|
pagesVO.setSize(listVO.size()); |
|
|
|
|
// 迭代器去添加元素。
|
|
|
|
|
ListIterator<ProductVO> it = pagesVO.getRecords().listIterator(); |
|
|
|
|
while (it.hasNext()) { |
|
|
|
|
ProductVO vo1 = it.next(); |
|
|
|
|
// 默认
|
|
|
|
|
vo1.setBizType(ProductConst.BIZ_TYPE_PRICE_STANDARD); |
|
|
|
|
// TYPE_PRICE_CUSTOM 数据是拼接上的
|
|
|
|
|
LambdaQueryWrapper<BizPriceEntity> wrapper = new LambdaQueryWrapper(); |
|
|
|
|
wrapper.eq(BizPriceEntity::getProductId,vo1.getId()); |
|
|
|
|
if(customerId != null){ |
|
|
|
|
wrapper.eq(BizPriceEntity::getCustomerId,customerId); |
|
|
|
|
} |
|
|
|
|
long count = bizPriceService.count(wrapper); |
|
|
|
|
if (count != 0L) { |
|
|
|
|
List<BizPriceEntity> listBP = bizPriceService.listByProductId(vo1.getId(),customerId); |
|
|
|
|
listBP.forEach(bp -> { |
|
|
|
|
ProductVO vo2 = new ProductVO(); |
|
|
|
|
BeanUtils.copyProperties(vo1, vo2); |
|
|
|
|
BeanUtils.copyProperties(bp, vo2); |
|
|
|
|
vo2.setId(vo1.getId()); |
|
|
|
|
// 特定价
|
|
|
|
|
vo2.setBizType(ProductConst.BIZ_TYPE_PRICE_CUSTOM); |
|
|
|
|
vo2.setBizPriceId(bp.getId()); |
|
|
|
|
vo2.setStandardPrice(bp.getBizPrice()); |
|
|
|
|
//
|
|
|
|
|
CustomerEntity customer = customerService.getById(bp.getCustomerId()); |
|
|
|
|
if (customer != null) { |
|
|
|
|
String countryValue = dictService.getValue(ContactConst.DICT_CUSTOMER_COUNTRY, customer.getCountry()); |
|
|
|
|
String sbRemark = |
|
|
|
|
countryValue + |
|
|
|
|
customer.getCompanyName() + |
|
|
|
|
"专用"; |
|
|
|
|
vo2.setBizRemark(sbRemark); |
|
|
|
|
vo2.setCustomerCompanyName(customer.getCompanyName()); |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
User u = userService.getById(vo2.getSaleUserId()); |
|
|
|
|
if (u != null) { |
|
|
|
|
vo2.setSaleUserRealName(u.getRealName()); |
|
|
|
|
if(user.getRoleName().equals("administrator")){ |
|
|
|
|
// 迭代器去添加元素。
|
|
|
|
|
ListIterator<ProductVO> it = pagesVO.getRecords().listIterator(); |
|
|
|
|
while (it.hasNext()) { |
|
|
|
|
ProductVO vo1 = it.next(); |
|
|
|
|
// 默认
|
|
|
|
|
vo1.setBizType(ProductConst.BIZ_TYPE_PRICE_STANDARD); |
|
|
|
|
// TYPE_PRICE_CUSTOM 数据是拼接上的
|
|
|
|
|
LambdaQueryWrapper<BizPriceEntity> wrapper = new LambdaQueryWrapper(); |
|
|
|
|
wrapper.eq(BizPriceEntity::getProductId,vo1.getId()); |
|
|
|
|
if(customerId != null){ |
|
|
|
|
wrapper.eq(BizPriceEntity::getCustomerId,customerId); |
|
|
|
|
} |
|
|
|
|
long count = bizPriceService.count(wrapper); |
|
|
|
|
if (count != 0L) { |
|
|
|
|
List<BizPriceEntity> listBP = bizPriceService.listByProductId(vo1.getId(),customerId); |
|
|
|
|
listBP.forEach(bp -> { |
|
|
|
|
ProductVO vo2 = new ProductVO(); |
|
|
|
|
BeanUtils.copyProperties(vo1, vo2); |
|
|
|
|
BeanUtils.copyProperties(bp, vo2); |
|
|
|
|
vo2.setId(vo1.getId()); |
|
|
|
|
// 特定价
|
|
|
|
|
vo2.setBizType(ProductConst.BIZ_TYPE_PRICE_CUSTOM); |
|
|
|
|
vo2.setBizPriceId(bp.getId()); |
|
|
|
|
vo2.setStandardPrice(bp.getBizPrice()); |
|
|
|
|
//
|
|
|
|
|
CustomerEntity customer = customerService.getById(bp.getCustomerId()); |
|
|
|
|
if (customer != null) { |
|
|
|
|
String countryValue = dictService.getValue(ContactConst.DICT_CUSTOMER_COUNTRY, customer.getCountry()); |
|
|
|
|
String sbRemark = |
|
|
|
|
countryValue + |
|
|
|
|
customer.getCompanyName() + |
|
|
|
|
"专用"; |
|
|
|
|
vo2.setBizRemark(sbRemark); |
|
|
|
|
vo2.setCustomerCompanyName(customer.getCompanyName()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
it.add(vo2); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
log.info("not contain."); |
|
|
|
|
{ |
|
|
|
|
User u = userService.getById(vo2.getSaleUserId()); |
|
|
|
|
if (u != null) { |
|
|
|
|
vo2.setSaleUserRealName(u.getRealName()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
it.add(vo2); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
log.info("not contain."); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//筛选
|
|
|
|
|
if(map.get("nameCn") != null || map.get("bizRemark") != null){ |
|
|
|
|
IPage<ProductVO> pagesVO1 = Condition.getPage(query); |
|
|
|
|
@ -384,6 +390,8 @@ public class ProductServiceImpl extends BaseServiceImpl<ProductMapper, ProductEn |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Boolean updateCostPrice(ProductEntity product) { |
|
|
|
|
BladeUser bladeUser = AuthUtil.getUser(); |
|
|
|
|
User user = UserCache.getUser(bladeUser.getUserId()); |
|
|
|
|
ProductEntity old = this.getById(product.getId()); |
|
|
|
|
Double costPriceOld = old.getCostPrice(); |
|
|
|
|
Double costPrice = product.getCostPrice(); |
|
|
|
|
@ -393,7 +401,7 @@ public class ProductServiceImpl extends BaseServiceImpl<ProductMapper, ProductEn |
|
|
|
|
history.setCostPrice(costPrice); |
|
|
|
|
history.setRemarks(product.getRemarkCn()); |
|
|
|
|
history.setCreateTime(new Date()); |
|
|
|
|
history.setCreateUserName(AuthUtil.getUser().getNickName()); |
|
|
|
|
history.setCreateUserName(user.getRealName()); |
|
|
|
|
productHistoryService.save(history); |
|
|
|
|
product.setUpdateTime(new Date()); |
|
|
|
|
this.updateById(product); |
|
|
|
|
@ -414,7 +422,7 @@ public class ProductServiceImpl extends BaseServiceImpl<ProductMapper, ProductEn |
|
|
|
|
if (productObjService.existsCode(vo.getCode())) { |
|
|
|
|
return R.fail("已经存在产品实物编号:" + vo.getCode()); |
|
|
|
|
} |
|
|
|
|
if (existsNameCn(vo.getNameCn())) { |
|
|
|
|
if (existsNameCn(vo.getCatalogId(),vo.getNameCn())) { |
|
|
|
|
return R.fail("已经存在产品名称:" + vo.getNameCn()); |
|
|
|
|
} |
|
|
|
|
if (productObjService.existsName(vo.getNameCn())) { |
|
|
|
|
@ -434,7 +442,7 @@ public class ProductServiceImpl extends BaseServiceImpl<ProductMapper, ProductEn |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (!StringUtils.equals(vo.getNameCn(), f.getNameCn())) { |
|
|
|
|
if (existsNameCn(vo.getNameCn())) { |
|
|
|
|
if (existsNameCn(vo.getCatalogId(),vo.getNameCn())) { |
|
|
|
|
return R.fail("已经存在产品名称:" + vo.getNameCn()); |
|
|
|
|
} |
|
|
|
|
if (productObjService.existsName(vo.getNameCn())) { |
|
|
|
|
|