|
|
@ -28,21 +28,31 @@ package com.yxt.anrui.as.biz.asservicepackage; |
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.yxt.anrui.as.api.asservicepackage.*; |
|
|
|
import com.yxt.anrui.as.api.asservicepackageaitem.AsServicePackageAitem; |
|
|
|
import com.yxt.anrui.as.api.asservicepackagegoods.AsServicePackageGoods; |
|
|
|
import com.yxt.anrui.as.api.asservicepackagesitem.AsServicePackageSitem; |
|
|
|
import com.yxt.anrui.as.biz.asservicepackageaitem.AsServicePackageAitemService; |
|
|
|
import com.yxt.anrui.as.biz.asservicepackagegoods.AsServicePackageGoodsService; |
|
|
|
import com.yxt.anrui.as.biz.asservicepackagesitem.AsServicePackageSitemService; |
|
|
|
import com.yxt.anrui.as.feign.portal.sysstafforg.SysStaffOrgFeign; |
|
|
|
import com.yxt.anrui.as.feign.wms.wmsgoods.WmsGoodsFeign; |
|
|
|
import com.yxt.anrui.as.feign.wms.wmsgoods.WmsGoodsPackageQuery; |
|
|
|
import com.yxt.anrui.as.feign.wms.wmsgoods.WmsGoodsPackageVo; |
|
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
|
import com.yxt.common.base.utils.PagerUtil; |
|
|
|
import com.yxt.common.core.query.PagerQuery; |
|
|
|
import com.yxt.common.core.vo.PagerVo; |
|
|
|
import com.yxt.anrui.as.api.asservicepackage.AsServicePackage; |
|
|
|
import com.yxt.anrui.as.api.asservicepackage.AsServicePackageQuery; |
|
|
|
import com.yxt.anrui.as.api.asservicepackage.AsServicePackageVo; |
|
|
|
import com.yxt.anrui.as.api.asservicepackage.AsServicePackageDetailsVo; |
|
|
|
import com.yxt.anrui.as.api.asservicepackage.AsServicePackageDto; |
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
|
* Project: yxt-as(售后服务) <br/> |
|
|
@ -61,6 +71,14 @@ import org.springframework.stereotype.Service; |
|
|
|
public class AsServicePackageService extends MybatisBaseService<AsServicePackageMapper, AsServicePackage> { |
|
|
|
@Autowired |
|
|
|
private SysStaffOrgFeign sysStaffOrgFeign; |
|
|
|
@Autowired |
|
|
|
private AsServicePackageGoodsService asServicePackageGoodsService; |
|
|
|
@Autowired |
|
|
|
private AsServicePackageAitemService asServicePackageAitemService; |
|
|
|
@Autowired |
|
|
|
private AsServicePackageSitemService asServicePackageSitemService; |
|
|
|
@Resource |
|
|
|
private WmsGoodsFeign wmsGoodsFeign; |
|
|
|
|
|
|
|
private QueryWrapper<AsServicePackage> createQueryWrapper(AsServicePackageQuery query) { |
|
|
|
// todo: 这里根据具体业务调整查询条件
|
|
|
@ -73,6 +91,7 @@ public class AsServicePackageService extends MybatisBaseService<AsServicePackage |
|
|
|
if (StringUtils.isNotBlank(query.getPackageName())) { |
|
|
|
qw.like("packageName", query.getPackageName()); |
|
|
|
} |
|
|
|
qw.eq("1", "1"); |
|
|
|
qw.orderByDesc("createTime"); |
|
|
|
return qw; |
|
|
|
} |
|
|
@ -115,6 +134,169 @@ public class AsServicePackageService extends MybatisBaseService<AsServicePackage |
|
|
|
AsServicePackage entity = fetchBySid(sid); |
|
|
|
AsServicePackageDetailsVo vo = new AsServicePackageDetailsVo(); |
|
|
|
BeanUtil.copyProperties(entity, vo); |
|
|
|
List<PackageItemVo> itemVos = new ArrayList<>(); |
|
|
|
List<PackageGoodsVo> goodsVos = new ArrayList<>(); |
|
|
|
List<PackageAttachItemVo> attachItemVos = new ArrayList<>(); |
|
|
|
List<AsServicePackageSitem> sitemList = asServicePackageSitemService.getByMainSid(sid); |
|
|
|
List<AsServicePackageGoods> goodsList = asServicePackageGoodsService.getByMainSid(sid); |
|
|
|
List<AsServicePackageAitem> asList = asServicePackageAitemService.getByMainSid(sid); |
|
|
|
if (!sitemList.isEmpty()) { |
|
|
|
for (AsServicePackageSitem packageSitem : sitemList) { |
|
|
|
PackageItemVo itemVo = new PackageItemVo(); |
|
|
|
BeanUtil.copyProperties(packageSitem, itemVo); |
|
|
|
itemVos.add(itemVo); |
|
|
|
} |
|
|
|
vo.setItemVos(itemVos); |
|
|
|
} |
|
|
|
if (!goodsList.isEmpty()) { |
|
|
|
for (AsServicePackageGoods goods : goodsList) { |
|
|
|
PackageGoodsVo goodsVo = new PackageGoodsVo(); |
|
|
|
BeanUtil.copyProperties(goods, goodsVo); |
|
|
|
goodsVos.add(goodsVo); |
|
|
|
} |
|
|
|
vo.setGoodsVos(goodsVos); |
|
|
|
} |
|
|
|
if (!asList.isEmpty()) { |
|
|
|
for (AsServicePackageAitem aitem : asList) { |
|
|
|
PackageAttachItemVo attachItemVo = new PackageAttachItemVo(); |
|
|
|
BeanUtil.copyProperties(aitem, attachItemVo); |
|
|
|
attachItemVos.add(attachItemVo); |
|
|
|
} |
|
|
|
vo.setAttachItemVos(attachItemVos); |
|
|
|
} |
|
|
|
return vo; |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void savePackage(AsServicePackageDto dto) { |
|
|
|
String orgPath = dto.getOrgPath(); |
|
|
|
if (StringUtils.isNotBlank(dto.getSid())) { |
|
|
|
String sid = dto.getSid(); |
|
|
|
AsServicePackage asServicePackage = fetchBySid(sid); |
|
|
|
BeanUtil.copyProperties(dto, asServicePackage, "id", "sid"); |
|
|
|
baseMapper.updateById(asServicePackage); |
|
|
|
asServicePackageAitemService.delByMainSid(sid); |
|
|
|
asServicePackageSitemService.delByMainSid(sid); |
|
|
|
asServicePackageGoodsService.delByMainSid(sid); |
|
|
|
//保存服务项目信息
|
|
|
|
List<PackageItemVo> itemVos = dto.getItemVos(); |
|
|
|
if (!itemVos.isEmpty()) { |
|
|
|
for (PackageItemVo itemVo : itemVos) { |
|
|
|
AsServicePackageSitem packageSitem = new AsServicePackageSitem(); |
|
|
|
packageSitem.setPackageSid(sid); |
|
|
|
BeanUtil.copyProperties(itemVo, packageSitem, "id", "sid"); |
|
|
|
asServicePackageSitemService.insert(packageSitem); |
|
|
|
} |
|
|
|
} |
|
|
|
//保存商品信息
|
|
|
|
List<PackageGoodsVo> goodsVos = dto.getGoodsVos(); |
|
|
|
if (!goodsVos.isEmpty()) { |
|
|
|
for (PackageGoodsVo goodsVo : goodsVos) { |
|
|
|
AsServicePackageGoods goods = new AsServicePackageGoods(); |
|
|
|
goods.setPackageSid(sid); |
|
|
|
BeanUtil.copyProperties(goodsVo, goods, "id", "sid"); |
|
|
|
asServicePackageGoodsService.insert(goods); |
|
|
|
} |
|
|
|
} |
|
|
|
//保存附加项目
|
|
|
|
List<PackageAttachItemVo> attachItemVos = dto.getAttachItemVos(); |
|
|
|
if (!attachItemVos.isEmpty()) { |
|
|
|
for (PackageAttachItemVo attachItemVo : attachItemVos) { |
|
|
|
AsServicePackageAitem aitem = new AsServicePackageAitem(); |
|
|
|
aitem.setPackageSid(sid); |
|
|
|
BeanUtil.copyProperties(attachItemVo, aitem, "id", "sid"); |
|
|
|
asServicePackageAitemService.insert(aitem); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
//保存套餐信息
|
|
|
|
AsServicePackage entity = new AsServicePackage(); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
ResultBean<String> orgSidByPath = sysStaffOrgFeign.getOrgSidByPath(orgPath); |
|
|
|
if (orgSidByPath.getSuccess()) { |
|
|
|
String useOrgSid = orgSidByPath.getData(); |
|
|
|
entity.setUseOrgSid(useOrgSid); |
|
|
|
entity.setCreateOrgSid(useOrgSid); |
|
|
|
} |
|
|
|
baseMapper.insert(entity); |
|
|
|
//保存服务项目信息
|
|
|
|
List<PackageItemVo> itemVos = dto.getItemVos(); |
|
|
|
if (!itemVos.isEmpty()) { |
|
|
|
for (PackageItemVo itemVo : itemVos) { |
|
|
|
AsServicePackageSitem packageSitem = new AsServicePackageSitem(); |
|
|
|
packageSitem.setPackageSid(entity.getSid()); |
|
|
|
BeanUtil.copyProperties(itemVo, packageSitem, "id", "sid"); |
|
|
|
asServicePackageSitemService.insert(packageSitem); |
|
|
|
} |
|
|
|
} |
|
|
|
//保存商品信息
|
|
|
|
List<PackageGoodsVo> goodsVos = dto.getGoodsVos(); |
|
|
|
if (!goodsVos.isEmpty()) { |
|
|
|
for (PackageGoodsVo goodsVo : goodsVos) { |
|
|
|
AsServicePackageGoods goods = new AsServicePackageGoods(); |
|
|
|
goods.setPackageSid(entity.getSid()); |
|
|
|
BeanUtil.copyProperties(goodsVo, goods, "id", "sid"); |
|
|
|
asServicePackageGoodsService.insert(goods); |
|
|
|
} |
|
|
|
} |
|
|
|
//保存附加项目
|
|
|
|
List<PackageAttachItemVo> attachItemVos = dto.getAttachItemVos(); |
|
|
|
if (!attachItemVos.isEmpty()) { |
|
|
|
for (PackageAttachItemVo attachItemVo : attachItemVos) { |
|
|
|
AsServicePackageAitem aitem = new AsServicePackageAitem(); |
|
|
|
aitem.setPackageSid(entity.getSid()); |
|
|
|
BeanUtil.copyProperties(attachItemVo, aitem, "id", "sid"); |
|
|
|
asServicePackageAitemService.insert(aitem); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void delOtherInfo(String[] sids) { |
|
|
|
for (String sid : sids) { |
|
|
|
asServicePackageAitemService.delByMainSid(sid); |
|
|
|
asServicePackageSitemService.delByMainSid(sid); |
|
|
|
asServicePackageGoodsService.delByMainSid(sid); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public List<PackageItemVo> selItemInfo(String orgPath) { |
|
|
|
List<PackageItemVo> list = new ArrayList<>(); |
|
|
|
ResultBean<String> orgSidByPath = sysStaffOrgFeign.getOrgSidByPath(orgPath); |
|
|
|
if (orgSidByPath.getSuccess()) { |
|
|
|
String useOrgSid = orgSidByPath.getData(); |
|
|
|
list = baseMapper.selItemInfo(useOrgSid); |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public List<PackageAttachItemVo> selAttItemInfo(String orgPath) { |
|
|
|
List<PackageAttachItemVo> list = new ArrayList<>(); |
|
|
|
ResultBean<String> orgSidByPath = sysStaffOrgFeign.getOrgSidByPath(orgPath); |
|
|
|
if (orgSidByPath.getSuccess()) { |
|
|
|
String useOrgSid = orgSidByPath.getData(); |
|
|
|
list = baseMapper.selAttItemInfo(useOrgSid); |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
public PagerVo<PackageGoodsVo> selGoodsInfo(PagerQuery<AsServicePackageQuery> pq) { |
|
|
|
PagerQuery<WmsGoodsPackageQuery> query = new PagerQuery<>(); |
|
|
|
BeanUtil.copyProperties(pq, query); |
|
|
|
AsServicePackageQuery params = pq.getParams(); |
|
|
|
ResultBean<String> orgSidByPath = sysStaffOrgFeign.getOrgSidByPath(params.getOrgPath()); |
|
|
|
if (orgSidByPath.getSuccess()) { |
|
|
|
String useOrgSid = orgSidByPath.getData(); |
|
|
|
WmsGoodsPackageQuery queryParams = query.getParams(); |
|
|
|
queryParams.setUseOrgSid(useOrgSid); |
|
|
|
} |
|
|
|
ResultBean<PagerVo<WmsGoodsPackageVo>> voResultBean = wmsGoodsFeign.getPackageGoodsVo(query); |
|
|
|
PagerVo<PackageGoodsVo> vo = new PagerVo<>(); |
|
|
|
if (voResultBean.getSuccess()) { |
|
|
|
PagerVo<WmsGoodsPackageVo> data = voResultBean.getData(); |
|
|
|
BeanUtil.copyProperties(data, vo); |
|
|
|
} |
|
|
|
return vo; |
|
|
|
} |
|
|
|
} |