|
@@ -19,25 +19,22 @@ import com.zhongzheng.modules.distribution.bo.*;
|
|
|
import com.zhongzheng.modules.distribution.domain.*;
|
|
|
import com.zhongzheng.modules.distribution.mapper.DistributionActivityMapper;
|
|
|
import com.zhongzheng.modules.distribution.service.*;
|
|
|
-import com.zhongzheng.modules.distribution.vo.DistributionActivityGoodsVo;
|
|
|
-import com.zhongzheng.modules.distribution.vo.DistributionActivityVo;
|
|
|
-import com.zhongzheng.modules.distribution.vo.DistributionGoodsListVo;
|
|
|
-import com.zhongzheng.modules.distribution.vo.SellerOrderVo;
|
|
|
+import com.zhongzheng.modules.distribution.vo.*;
|
|
|
import com.zhongzheng.modules.goods.bo.GoodsPullResultBo;
|
|
|
import com.zhongzheng.modules.goods.bo.GoodsPullTenantBo;
|
|
|
import com.zhongzheng.modules.goods.domain.Goods;
|
|
|
import com.zhongzheng.modules.goods.domain.GoodsSpecAttributeRelation;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsSpecAttributeRelationService;
|
|
|
+import com.zhongzheng.modules.top.distribution.bo.DistributionCashTopQueryBo;
|
|
|
import com.zhongzheng.modules.top.distribution.bo.TenantOrderQueryBo;
|
|
|
import com.zhongzheng.modules.top.distribution.bo.TenantSortNoticeQueryBo;
|
|
|
+import com.zhongzheng.modules.top.distribution.bo.TopSellerOrderQueryBo;
|
|
|
import com.zhongzheng.modules.top.distribution.domain.DistributionActivityTemplate;
|
|
|
import com.zhongzheng.modules.top.distribution.domain.DistributionActivityTemplateGoods;
|
|
|
import com.zhongzheng.modules.top.distribution.service.IDistributionActivityTemplateGoodsService;
|
|
|
import com.zhongzheng.modules.top.distribution.service.IDistributionActivityTemplateService;
|
|
|
-import com.zhongzheng.modules.top.distribution.vo.TenantOrderCashVo;
|
|
|
-import com.zhongzheng.modules.top.distribution.vo.TenantOrderVo;
|
|
|
-import com.zhongzheng.modules.top.distribution.vo.TenantSortNoticeVo;
|
|
|
+import com.zhongzheng.modules.top.distribution.vo.*;
|
|
|
import com.zhongzheng.modules.top.goods.domain.TopActivityGoodsPrice;
|
|
|
import com.zhongzheng.modules.top.goods.domain.TopGoods;
|
|
|
import com.zhongzheng.modules.top.goods.service.ITopActivityGoodsPriceService;
|
|
@@ -90,7 +87,7 @@ public class DistributionActivityServiceImpl extends ServiceImpl<DistributionAct
|
|
|
private IDistributionSellerService iDistributionSellerService;
|
|
|
|
|
|
@Override
|
|
|
- public DistributionActivityVo queryById(Long distributionId){
|
|
|
+ public DistributionActivityVo queryById(Long distributionId) {
|
|
|
DistributionActivity db = this.baseMapper.selectById(distributionId);
|
|
|
DistributionActivityVo vo = BeanUtil.toBean(db, DistributionActivityVo.class);
|
|
|
//获取商品信息
|
|
@@ -98,12 +95,12 @@ public class DistributionActivityServiceImpl extends ServiceImpl<DistributionAct
|
|
|
.list(new LambdaQueryWrapper<DistributionActivityGoods>()
|
|
|
.eq(DistributionActivityGoods::getStatus, 1)
|
|
|
.eq(DistributionActivityGoods::getDistributionId, vo.getDistributionId()));
|
|
|
- if (CollectionUtils.isNotEmpty(templateGoodsList)){
|
|
|
+ if (CollectionUtils.isNotEmpty(templateGoodsList)) {
|
|
|
List<DistributionActivityGoodsVo> templateGoodsVos = templateGoodsList.stream().map(item -> {
|
|
|
DistributionActivityGoodsVo goodsVo = BeanUtil.toBean(item, DistributionActivityGoodsVo.class);
|
|
|
Goods goods = iGoodsService.getById(goodsVo.getGoodsId());
|
|
|
goodsVo.setGoodsName(goods.getGoodsName());
|
|
|
- if (item.getProfitType() == 1){
|
|
|
+ if (item.getProfitType() == 1) {
|
|
|
//百分比
|
|
|
goodsVo.setProfitMax(item.getProfitMax().multiply(new BigDecimal(100)));
|
|
|
goodsVo.setProfitOne(item.getProfitOne().multiply(new BigDecimal(100)));
|
|
@@ -116,7 +113,7 @@ public class DistributionActivityServiceImpl extends ServiceImpl<DistributionAct
|
|
|
.eq(ActivityGoodsPrice::getGoodsId, item.getGoodsId())
|
|
|
.eq(ActivityGoodsPrice::getStatus, 1)
|
|
|
.last("limit 1"));
|
|
|
- if (ObjectUtils.isNotNull(price)){
|
|
|
+ if (ObjectUtils.isNotNull(price)) {
|
|
|
goodsVo.setGoodsPrice(price.getGoodsPrice());
|
|
|
}
|
|
|
return goodsVo;
|
|
@@ -139,7 +136,7 @@ public class DistributionActivityServiceImpl extends ServiceImpl<DistributionAct
|
|
|
lqw.eq(bo.getPosterId() != null, DistributionActivity::getPosterId, bo.getPosterId());
|
|
|
lqw.orderByDesc(DistributionActivity::getDistributionId);
|
|
|
List<DistributionActivityVo> voList = entity2Vo(this.list(lqw));
|
|
|
- if (CollectionUtils.isEmpty(voList)){
|
|
|
+ if (CollectionUtils.isEmpty(voList)) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
voList.forEach(item -> {
|
|
@@ -151,19 +148,19 @@ public class DistributionActivityServiceImpl extends ServiceImpl<DistributionAct
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 实体类转化成视图对象
|
|
|
- *
|
|
|
- * @param collection 实体类集合
|
|
|
- * @return
|
|
|
- */
|
|
|
+ * 实体类转化成视图对象
|
|
|
+ *
|
|
|
+ * @param collection 实体类集合
|
|
|
+ * @return
|
|
|
+ */
|
|
|
private List<DistributionActivityVo> entity2Vo(Collection<DistributionActivity> collection) {
|
|
|
List<DistributionActivityVo> voList = collection.stream()
|
|
|
.map(any -> BeanUtil.toBean(any, DistributionActivityVo.class))
|
|
|
.collect(Collectors.toList());
|
|
|
if (collection instanceof Page) {
|
|
|
- Page<DistributionActivity> page = (Page<DistributionActivity>)collection;
|
|
|
+ Page<DistributionActivity> page = (Page<DistributionActivity>) collection;
|
|
|
Page<DistributionActivityVo> pageVo = new Page<>();
|
|
|
- BeanUtil.copyProperties(page,pageVo);
|
|
|
+ BeanUtil.copyProperties(page, pageVo);
|
|
|
pageVo.addAll(voList);
|
|
|
voList = pageVo;
|
|
|
}
|
|
@@ -180,11 +177,11 @@ public class DistributionActivityServiceImpl extends ServiceImpl<DistributionAct
|
|
|
add.setUpdateTime(DateUtils.getNowTime());
|
|
|
this.save(add);
|
|
|
//活动商品
|
|
|
- if (CollectionUtils.isNotEmpty(bo.getGoodsList())){
|
|
|
+ if (CollectionUtils.isNotEmpty(bo.getGoodsList())) {
|
|
|
List<DistributionActivityGoods> collect = bo.getGoodsList().stream().map(item -> {
|
|
|
DistributionActivityGoods entity = BeanUtil.toBean(item, DistributionActivityGoods.class);
|
|
|
entity.setDistributionId(add.getDistributionId());
|
|
|
- if (ObjectUtils.isNotNull(item.getProfitType()) && item.getProfitType() == 1){
|
|
|
+ if (ObjectUtils.isNotNull(item.getProfitType()) && item.getProfitType() == 1) {
|
|
|
//佣金是百分比
|
|
|
entity.setProfitMax(item.getProfitMax().divide(new BigDecimal(100)));
|
|
|
entity.setProfitOne(item.getProfitOne().divide(new BigDecimal(100)));
|
|
@@ -203,10 +200,10 @@ public class DistributionActivityServiceImpl extends ServiceImpl<DistributionAct
|
|
|
.eq(ActivityGoodsPrice::getActivityCode, add.getCode())
|
|
|
.eq(ActivityGoodsPrice::getGoodsId, item.getGoodsId())
|
|
|
.last("limit 1"));
|
|
|
- if (ObjectUtils.isNotNull(goodsPrice)){
|
|
|
+ if (ObjectUtils.isNotNull(goodsPrice)) {
|
|
|
goodsPrice.setGoodsPrice(item.getGoodsPrice());
|
|
|
iActivityGoodsPriceService.updateById(goodsPrice);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
ActivityGoodsPrice price = new ActivityGoodsPrice();
|
|
|
price.setGoodsPrice(item.getGoodsPrice());
|
|
|
price.setActivityCode(add.getCode());
|
|
@@ -227,7 +224,7 @@ public class DistributionActivityServiceImpl extends ServiceImpl<DistributionAct
|
|
|
public Boolean updateByEditBo(DistributionActivityEditBo bo) {
|
|
|
//校验
|
|
|
DistributionActivity activityTemp = getById(bo.getDistributionId());
|
|
|
- if (activityTemp.getStatus() == 1){
|
|
|
+ if (activityTemp.getStatus() == 1) {
|
|
|
throw new CustomException("活动已启用,不能修改!");
|
|
|
}
|
|
|
DistributionActivity update = BeanUtil.toBean(bo, DistributionActivity.class);
|
|
@@ -236,15 +233,15 @@ public class DistributionActivityServiceImpl extends ServiceImpl<DistributionAct
|
|
|
this.updateById(update);
|
|
|
//删除活动商品重新绑定
|
|
|
iDistributionActivityGoodsService.remove(new LambdaQueryWrapper<DistributionActivityGoods>()
|
|
|
- .eq(DistributionActivityGoods::getDistributionId,bo.getDistributionId()));
|
|
|
+ .eq(DistributionActivityGoods::getDistributionId, bo.getDistributionId()));
|
|
|
iActivityGoodsPriceService.remove(new LambdaQueryWrapper<ActivityGoodsPrice>()
|
|
|
- .eq(ActivityGoodsPrice::getActivityCode,activityTemp.getCode()));
|
|
|
+ .eq(ActivityGoodsPrice::getActivityCode, activityTemp.getCode()));
|
|
|
//活动商品
|
|
|
- if (CollectionUtils.isNotEmpty(bo.getGoodsList())){
|
|
|
+ if (CollectionUtils.isNotEmpty(bo.getGoodsList())) {
|
|
|
List<DistributionActivityGoods> collect = bo.getGoodsList().stream().map(item -> {
|
|
|
DistributionActivityGoods entity = BeanUtil.toBean(item, DistributionActivityGoods.class);
|
|
|
entity.setDistributionId(update.getDistributionId());
|
|
|
- if (ObjectUtils.isNotNull(item.getProfitType()) && item.getProfitType() == 1){
|
|
|
+ if (ObjectUtils.isNotNull(item.getProfitType()) && item.getProfitType() == 1) {
|
|
|
//佣金是百分比
|
|
|
entity.setProfitMax(item.getProfitMax().divide(new BigDecimal(100)));
|
|
|
entity.setProfitOne(item.getProfitOne().divide(new BigDecimal(100)));
|
|
@@ -263,10 +260,10 @@ public class DistributionActivityServiceImpl extends ServiceImpl<DistributionAct
|
|
|
.eq(ActivityGoodsPrice::getActivityCode, activityTemp.getCode())
|
|
|
.eq(ActivityGoodsPrice::getGoodsId, item.getGoodsId())
|
|
|
.last("limit 1"));
|
|
|
- if (ObjectUtils.isNotNull(goodsPrice)){
|
|
|
+ if (ObjectUtils.isNotNull(goodsPrice)) {
|
|
|
goodsPrice.setGoodsPrice(item.getGoodsPrice());
|
|
|
iActivityGoodsPriceService.updateById(goodsPrice);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
ActivityGoodsPrice price = new ActivityGoodsPrice();
|
|
|
price.setGoodsPrice(item.getGoodsPrice());
|
|
|
price.setActivityCode(activityTemp.getCode());
|
|
@@ -287,13 +284,13 @@ public class DistributionActivityServiceImpl extends ServiceImpl<DistributionAct
|
|
|
*
|
|
|
* @param entity 实体类数据
|
|
|
*/
|
|
|
- private void validEntityBeforeSave(DistributionActivity entity){
|
|
|
+ private void validEntityBeforeSave(DistributionActivity entity) {
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
- if(isValid){
|
|
|
+ if (isValid) {
|
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
|
}
|
|
|
return this.removeByIds(ids);
|
|
@@ -301,27 +298,27 @@ public class DistributionActivityServiceImpl extends ServiceImpl<DistributionAct
|
|
|
|
|
|
@Override
|
|
|
public boolean editStatus(DistributionStatusEditBo bo) {
|
|
|
- if (ObjectUtils.isNull(bo.getStatus())){
|
|
|
+ if (ObjectUtils.isNull(bo.getStatus())) {
|
|
|
throw new CustomException("状态不能为空");
|
|
|
}
|
|
|
DistributionActivity activity = getById(bo.getDistributionId());
|
|
|
- if (bo.getStatus() == 1){
|
|
|
+ if (bo.getStatus() == 1) {
|
|
|
//启用活动
|
|
|
- if (DateUtils.getNowTime()< activity.getStartTime() || DateUtils.getNowTime() > activity.getEndTime()){
|
|
|
+ if (DateUtils.getNowTime() < activity.getStartTime() || DateUtils.getNowTime() > activity.getEndTime()) {
|
|
|
throw new CustomException("不在活动时间内,禁止启用!");
|
|
|
}
|
|
|
- if (ObjectUtils.isNotNull(activity.getTempId())){
|
|
|
+ if (ObjectUtils.isNotNull(activity.getTempId())) {
|
|
|
//总平台下发活动对比商品是否缺失
|
|
|
List<DistributionActivityGoods> activityGoods = iDistributionActivityGoodsService
|
|
|
.list(new LambdaQueryWrapper<DistributionActivityGoods>()
|
|
|
- .eq(DistributionActivityGoods::getDistributionId, activity.getDistributionId())
|
|
|
- .eq(DistributionActivityGoods::getStatus, 1));
|
|
|
+ .eq(DistributionActivityGoods::getDistributionId, activity.getDistributionId())
|
|
|
+ .eq(DistributionActivityGoods::getStatus, 1));
|
|
|
List<DistributionActivityTemplateGoods> templateGoods = iDistributionActivityTemplateGoodsService
|
|
|
.list(new LambdaQueryWrapper<DistributionActivityTemplateGoods>()
|
|
|
- .eq(DistributionActivityTemplateGoods::getDistributionTempId, activity.getTempId())
|
|
|
- .eq(DistributionActivityTemplateGoods::getStatus, 1));
|
|
|
- if (activityGoods.size() != templateGoods.size()){
|
|
|
- throw new CustomException("活动商品缺失,请先拉取商品信息",777);
|
|
|
+ .eq(DistributionActivityTemplateGoods::getDistributionTempId, activity.getTempId())
|
|
|
+ .eq(DistributionActivityTemplateGoods::getStatus, 1));
|
|
|
+ if (activityGoods.size() != templateGoods.size()) {
|
|
|
+ throw new CustomException("活动商品缺失,请先拉取商品信息", 777);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -333,7 +330,7 @@ public class DistributionActivityServiceImpl extends ServiceImpl<DistributionAct
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean pullGoods(Long distributionId) {
|
|
|
DistributionActivity activity = getById(distributionId);
|
|
|
- if (ObjectUtils.isNull(activity.getTempId())){
|
|
|
+ if (ObjectUtils.isNull(activity.getTempId())) {
|
|
|
//不是总平台下发的活动
|
|
|
return true;
|
|
|
}
|
|
@@ -343,17 +340,17 @@ public class DistributionActivityServiceImpl extends ServiceImpl<DistributionAct
|
|
|
.eq(DistributionActivityGoods::getDistributionId, activity.getDistributionId())
|
|
|
.eq(DistributionActivityGoods::getStatus, 1));
|
|
|
List<DistributionActivityTemplateGoods> templateGoods = iDistributionActivityTemplateGoodsService.getListEntity(activity.getTempId());
|
|
|
- if (activityGoods.size() == templateGoods.size()){
|
|
|
+ if (activityGoods.size() == templateGoods.size()) {
|
|
|
//不缺失商品信息
|
|
|
return true;
|
|
|
}
|
|
|
- if (CollectionUtils.isEmpty(templateGoods)){
|
|
|
+ if (CollectionUtils.isEmpty(templateGoods)) {
|
|
|
//总平台活动商品没有
|
|
|
return true;
|
|
|
}
|
|
|
DistributionActivityTemplate activityTemplate = iDistributionActivityTemplateService.getEntityById(activity.getTempId());
|
|
|
Long tenantId = Long.valueOf(ServletUtils.getRequest().getHeader("TenantId"));
|
|
|
- if (CollectionUtils.isEmpty(activityGoods)){
|
|
|
+ if (CollectionUtils.isEmpty(activityGoods)) {
|
|
|
//全部缺失
|
|
|
List<TopGoods> topGoods = iTopGoodsService.listEntityByIds(templateGoods.stream().map(DistributionActivityTemplateGoods::getGoodsId).collect(Collectors.toList()));
|
|
|
GoodsPullTenantBo bo = new GoodsPullTenantBo();
|
|
@@ -370,8 +367,8 @@ public class DistributionActivityServiceImpl extends ServiceImpl<DistributionAct
|
|
|
if (ObjectUtils.isNotNull(pul)) {
|
|
|
activityGo.setGoodsId(pul.getNewGoodsId());
|
|
|
//商品活动价格
|
|
|
- TopActivityGoodsPrice topGoodsPrice = iTopActivityGoodsPriceService.getEntity(item.getGoodsId(),activityTemplate.getCode());
|
|
|
- if (ObjectUtils.isNotNull(topGoodsPrice)){
|
|
|
+ TopActivityGoodsPrice topGoodsPrice = iTopActivityGoodsPriceService.getEntity(item.getGoodsId(), activityTemplate.getCode());
|
|
|
+ if (ObjectUtils.isNotNull(topGoodsPrice)) {
|
|
|
ActivityGoodsPrice goodsPrice = BeanUtil.toBean(topGoodsPrice, ActivityGoodsPrice.class);
|
|
|
goodsPrice.setGoodsId(pul.getNewGoodsId());
|
|
|
goodsPrice.setTenantId(tenantId);
|
|
@@ -382,13 +379,13 @@ public class DistributionActivityServiceImpl extends ServiceImpl<DistributionAct
|
|
|
}).collect(Collectors.toList());
|
|
|
iDistributionActivityGoodsService.saveBatch(distributionActivityGo);
|
|
|
iActivityGoodsPriceService.saveBatch(goodsPriceList);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
//部分缺失
|
|
|
List<Goods> goodsList = iGoodsService.listByIds(activityGoods.stream().map(DistributionActivityGoods::getGoodsId).collect(Collectors.toList()));
|
|
|
List<TopGoods> topGoods = iTopGoodsService.listEntityByIds(templateGoods.stream().map(DistributionActivityTemplateGoods::getGoodsId).collect(Collectors.toList()));
|
|
|
List<String> codes = goodsList.stream().map(Goods::getCode).collect(Collectors.toList());
|
|
|
List<TopGoods> goods = topGoods.stream().filter(item -> !codes.contains(item.getCode())).collect(Collectors.toList());
|
|
|
- if (CollectionUtils.isNotEmpty(goods)){
|
|
|
+ if (CollectionUtils.isNotEmpty(goods)) {
|
|
|
GoodsPullTenantBo bo = new GoodsPullTenantBo();
|
|
|
bo.setGoodsList(goods);
|
|
|
bo.setTenantId(tenantId);
|
|
@@ -405,8 +402,8 @@ public class DistributionActivityServiceImpl extends ServiceImpl<DistributionAct
|
|
|
if (ObjectUtils.isNotNull(pul)) {
|
|
|
activityGo.setGoodsId(pul.getNewGoodsId());
|
|
|
//商品活动价格
|
|
|
- TopActivityGoodsPrice topGoodsPrice = iTopActivityGoodsPriceService.getEntity(item.getGoodsId(),activityTemplate.getCode());
|
|
|
- if (ObjectUtils.isNotNull(topGoodsPrice)){
|
|
|
+ TopActivityGoodsPrice topGoodsPrice = iTopActivityGoodsPriceService.getEntity(item.getGoodsId(), activityTemplate.getCode());
|
|
|
+ if (ObjectUtils.isNotNull(topGoodsPrice)) {
|
|
|
ActivityGoodsPrice goodsPrice = BeanUtil.toBean(topGoodsPrice, ActivityGoodsPrice.class);
|
|
|
goodsPrice.setGoodsId(pul.getNewGoodsId());
|
|
|
goodsPrice.setTenantId(tenantId);
|
|
@@ -431,27 +428,27 @@ public class DistributionActivityServiceImpl extends ServiceImpl<DistributionAct
|
|
|
@Override
|
|
|
public List<DistributionGoodsListVo> getGoodsList(Long distributionId) {
|
|
|
List<DistributionGoodsListVo> list = baseMapper.getGoodsList(distributionId);
|
|
|
- if (CollectionUtils.isEmpty(list)){
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
list.forEach(item -> {
|
|
|
//商品活动价格
|
|
|
ActivityGoodsPrice goodsPrice = iActivityGoodsPriceService
|
|
|
.getOne(new LambdaQueryWrapper<ActivityGoodsPrice>()
|
|
|
- .eq(ActivityGoodsPrice::getActivityCode, item.getDistributionCode())
|
|
|
- .eq(ActivityGoodsPrice::getGoodsId, item.getGoodsId())
|
|
|
- .eq(ActivityGoodsPrice::getStatus, 1)
|
|
|
- .last("limit 1"));
|
|
|
- if (ObjectUtils.isNotNull(goodsPrice)){
|
|
|
+ .eq(ActivityGoodsPrice::getActivityCode, item.getDistributionCode())
|
|
|
+ .eq(ActivityGoodsPrice::getGoodsId, item.getGoodsId())
|
|
|
+ .eq(ActivityGoodsPrice::getStatus, 1)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtils.isNotNull(goodsPrice)) {
|
|
|
item.setStandPrice(goodsPrice.getGoodsPrice());
|
|
|
}
|
|
|
|
|
|
//多规格下的价格区间
|
|
|
- if (ObjectUtils.isNotNull(item.getSpecTemplateId())){
|
|
|
+ if (ObjectUtils.isNotNull(item.getSpecTemplateId())) {
|
|
|
List<GoodsSpecAttributeRelation> specAttributeRelations = goodsSpecAttributeRelationService
|
|
|
.list(new LambdaQueryWrapper<GoodsSpecAttributeRelation>()
|
|
|
.eq(GoodsSpecAttributeRelation::getSpecTemplateId, item.getSpecTemplateId()));
|
|
|
- if (CollectionUtils.isNotEmpty(specAttributeRelations)){
|
|
|
+ if (CollectionUtils.isNotEmpty(specAttributeRelations)) {
|
|
|
List<Long> goodsIds = specAttributeRelations.stream().filter(x -> ObjectUtils.isNotNull(x.getGoodsId())).map(GoodsSpecAttributeRelation::getGoodsId).collect(Collectors.toList());
|
|
|
List<Goods> goodsList = iGoodsService.listByIds(goodsIds);
|
|
|
//从小到大排序
|
|
@@ -467,22 +464,22 @@ public class DistributionActivityServiceImpl extends ServiceImpl<DistributionAct
|
|
|
@Override
|
|
|
public List<SellerOrderVo> getSellerOrder(SellerOrderQueryBo bo) {
|
|
|
List<SellerOrderVo> orderVos = baseMapper.getSellerOrder(bo);
|
|
|
- if (CollectionUtils.isEmpty(orderVos)){
|
|
|
+ if (CollectionUtils.isEmpty(orderVos)) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
orderVos.forEach(item -> {
|
|
|
-// if (item.getCashType() == 1){
|
|
|
-// //百分比
|
|
|
-// item.setCashRatio(item.getCashRatio().multiply(new BigDecimal("100.00")));
|
|
|
-// }
|
|
|
+ if (item.getCashType() == 1){
|
|
|
+ //百分比
|
|
|
+ item.setCashRatio(item.getCashRatio().multiply(new BigDecimal("100.00")));
|
|
|
+ }
|
|
|
//差看佣金状态
|
|
|
DistributionCashLog cashLog = iDistributionCashLogService
|
|
|
.getOne(new LambdaQueryWrapper<DistributionCashLog>()
|
|
|
- .eq(DistributionCashLog::getSellerId, item.getSellerId())
|
|
|
- .eq(DistributionCashLog::getRelatedSn, item.getOrderSn())
|
|
|
- .last("limit 1"));
|
|
|
- if (ObjectUtils.isNotNull(cashLog)){
|
|
|
- item.setCashStatus(cashLog.getType() > 1?2:1);
|
|
|
+ .eq(DistributionCashLog::getSellerId, item.getSellerId())
|
|
|
+ .eq(DistributionCashLog::getRelatedSn, item.getOrderSn())
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtils.isNotNull(cashLog) && item.getCashStatus() == 3 ) {
|
|
|
+ item.setCashStatus(cashLog.getType() > 1 ? 2 : 1);
|
|
|
}
|
|
|
});
|
|
|
return orderVos;
|
|
@@ -496,16 +493,99 @@ public class DistributionActivityServiceImpl extends ServiceImpl<DistributionAct
|
|
|
@Override
|
|
|
public List<TenantOrderVo> getOrgOrder(TenantOrderQueryBo bo) {
|
|
|
List<TenantOrderVo> orderVos = baseMapper.getOrgOrder(bo);
|
|
|
- if (CollectionUtils.isEmpty(orderVos)){
|
|
|
+ if (CollectionUtils.isEmpty(orderVos)) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ orderVos.forEach(item -> {
|
|
|
+ //佣金详情
|
|
|
+ List<DistributionRebate> list = iDistributionRebateService
|
|
|
+ .list(new LambdaQueryWrapper<DistributionRebate>()
|
|
|
+ .eq(DistributionRebate::getOrderSn, item.getOrderSn())
|
|
|
+ .eq(DistributionRebate::getStatus, 1));
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ List<TenantOrderCashVo> cashVoList = list.stream().map(rebate -> {
|
|
|
+ TenantOrderCashVo cashVo = new TenantOrderCashVo();
|
|
|
+ cashVo.setSellerId(rebate.getSellerId());
|
|
|
+ cashVo.setCash(rebate.getCash());
|
|
|
+ cashVo.setCashStatus(rebate.getCashStatus());
|
|
|
+ cashVo.setCashTime(rebate.getCreateTime());
|
|
|
+ cashVo.setCashType(rebate.getProfitType());
|
|
|
+ if (rebate.getProfitType() == 1){
|
|
|
+ //百分比
|
|
|
+ cashVo.setCashRatio(rebate.getProfit().multiply(new BigDecimal("100.00")));
|
|
|
+ }else {
|
|
|
+ cashVo.setCashRatio(rebate.getProfit());
|
|
|
+ }
|
|
|
+ DistributionSeller seller = iDistributionSellerService.getById(rebate.getSellerId());
|
|
|
+ cashVo.setSellerName(seller.getRealname());
|
|
|
+ return cashVo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ item.setCashVoList(cashVoList);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return orderVos;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public SellerOrderVo getCashDetail(Long id) {
|
|
|
+ SellerOrderVo orderVo = baseMapper.getCashDetail(id);
|
|
|
+ if (ObjectUtils.isNull(orderVo)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (orderVo.getCashType() == 1){
|
|
|
+ //百分比
|
|
|
+ orderVo.setCashRatio(orderVo.getCash().multiply(new BigDecimal("100.00")));
|
|
|
+ }
|
|
|
+ //差看佣金状态
|
|
|
+ DistributionCashLog cashLog = iDistributionCashLogService
|
|
|
+ .getOne(new LambdaQueryWrapper<DistributionCashLog>()
|
|
|
+ .eq(DistributionCashLog::getSellerId, orderVo.getSellerId())
|
|
|
+ .eq(DistributionCashLog::getRelatedSn, orderVo.getOrderSn())
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtils.isNotNull(cashLog) &&
|
|
|
+ orderVo.getCashStatus() == 3 ) {
|
|
|
+ orderVo.setCashStatus(cashLog.getType() > 1 ? 2 : 1);
|
|
|
+ }
|
|
|
+ return orderVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<DistributionCashVo> getCashList(DistributionCashQueryBo bo) {
|
|
|
+ List<DistributionCashVo> cashVoList = baseMapper.getCashList(bo);
|
|
|
+ if (CollectionUtils.isEmpty(cashVoList)){
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(bo.getStartTime()) && ObjectUtils.isNotNull(bo.getEndTime())){
|
|
|
+ cashVoList.forEach(item -> {
|
|
|
+ //总佣金
|
|
|
+ List<DistributionRebate> list = iDistributionRebateService
|
|
|
+ .list(new LambdaQueryWrapper<DistributionRebate>()
|
|
|
+ .eq(DistributionRebate::getSellerId, item.getSellerId())
|
|
|
+ .ne(DistributionRebate::getCashStatus, 3)
|
|
|
+ .ge(DistributionRebate::getCreateTime, bo.getStartTime())
|
|
|
+ .le(DistributionRebate::getCreateTime, bo.getEndTime()));
|
|
|
+ if (CollectionUtils.isNotEmpty(list)){
|
|
|
+ BigDecimal reduce = list.stream().map(DistributionRebate::getCash).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setCashTotal(reduce);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return cashVoList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<DistributionOrderVo> getOrderList(DistributionOrderQueryBo bo) {
|
|
|
+ List<DistributionOrderVo> orderVos = baseMapper.getOrderList(bo);
|
|
|
+ if (CollectionUtils.isEmpty(orderVos)) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
orderVos.forEach(item -> {
|
|
|
//佣金详情
|
|
|
List<DistributionRebate> list = iDistributionRebateService
|
|
|
.list(new LambdaQueryWrapper<DistributionRebate>()
|
|
|
- .eq(DistributionRebate::getOrderSn, item.getOrderSn())
|
|
|
- .eq(DistributionRebate::getStatus,1));
|
|
|
- if (CollectionUtils.isNotEmpty(list)){
|
|
|
+ .eq(DistributionRebate::getOrderSn, item.getOrderSn())
|
|
|
+ .eq(DistributionRebate::getStatus, 1));
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
List<TenantOrderCashVo> cashVoList = list.stream().map(rebate -> {
|
|
|
TenantOrderCashVo cashVo = new TenantOrderCashVo();
|
|
|
cashVo.setSellerId(rebate.getSellerId());
|
|
@@ -513,7 +593,12 @@ public class DistributionActivityServiceImpl extends ServiceImpl<DistributionAct
|
|
|
cashVo.setCashStatus(rebate.getCashStatus());
|
|
|
cashVo.setCashTime(rebate.getCreateTime());
|
|
|
cashVo.setCashType(rebate.getProfitType());
|
|
|
- cashVo.setCashRatio(rebate.getProfit());
|
|
|
+ if (rebate.getProfitType() == 1) {
|
|
|
+ //百分比
|
|
|
+ cashVo.setCashRatio(rebate.getProfit().multiply(new BigDecimal("100.00")));
|
|
|
+ } else {
|
|
|
+ cashVo.setCashRatio(rebate.getProfit());
|
|
|
+ }
|
|
|
DistributionSeller seller = iDistributionSellerService.getById(rebate.getSellerId());
|
|
|
cashVo.setSellerName(seller.getRealname());
|
|
|
return cashVo;
|
|
@@ -523,4 +608,52 @@ public class DistributionActivityServiceImpl extends ServiceImpl<DistributionAct
|
|
|
});
|
|
|
return orderVos;
|
|
|
}
|
|
|
-}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<DistributionCashTopVo> getOrgCashList(DistributionCashTopQueryBo bo) {
|
|
|
+ List<DistributionCashTopVo> cashVoList = baseMapper.getOrgCashList(bo);
|
|
|
+ if (CollectionUtils.isEmpty(cashVoList)){
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(bo.getStartTime()) && ObjectUtils.isNotNull(bo.getEndTime())){
|
|
|
+ cashVoList.forEach(item -> {
|
|
|
+ //总佣金
|
|
|
+ List<DistributionRebate> list = iDistributionRebateService
|
|
|
+ .list(new LambdaQueryWrapper<DistributionRebate>()
|
|
|
+ .eq(DistributionRebate::getSellerId, item.getSellerId())
|
|
|
+ .ne(DistributionRebate::getCashStatus, 3)
|
|
|
+ .ge(DistributionRebate::getCreateTime, bo.getStartTime())
|
|
|
+ .le(DistributionRebate::getCreateTime, bo.getEndTime()));
|
|
|
+ if (CollectionUtils.isNotEmpty(list)){
|
|
|
+ BigDecimal reduce = list.stream().map(DistributionRebate::getCash).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setCashTotal(reduce);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return cashVoList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<TopSellerOrderVo> getOrgCashDetail(TopSellerOrderQueryBo bo) {
|
|
|
+ List<TopSellerOrderVo> orderVos = baseMapper.getOrgCashDetail(bo);
|
|
|
+ if (CollectionUtils.isEmpty(orderVos)) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ orderVos.forEach(item -> {
|
|
|
+ if (item.getCashType() == 1){
|
|
|
+ //百分比
|
|
|
+ item.setCashRatio(item.getCashRatio().multiply(new BigDecimal("100.00")));
|
|
|
+ }
|
|
|
+ //差看佣金状态
|
|
|
+ DistributionCashLog cashLog = iDistributionCashLogService
|
|
|
+ .getOne(new LambdaQueryWrapper<DistributionCashLog>()
|
|
|
+ .eq(DistributionCashLog::getSellerId, item.getSellerId())
|
|
|
+ .eq(DistributionCashLog::getRelatedSn, item.getOrderSn())
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtils.isNotNull(cashLog) && item.getCashStatus() == 3 ) {
|
|
|
+ item.setCashStatus(cashLog.getType() > 1 ? 2 : 1);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return orderVos;
|
|
|
+ }
|
|
|
+}
|