|
|
@ -4,13 +4,18 @@ import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.date.DateTime; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.yxt.base.biz.base.basegoodssku.BaseGoodsSku; |
|
|
|
import com.yxt.base.biz.base.basegoodssku.BaseGoodsSkuVo; |
|
|
|
import com.yxt.base.biz.base.basegoodsskuextend.BaseGoodsSkuExtend; |
|
|
|
import com.yxt.base.biz.base.basegoodsskuextend.BaseGoodsSkuExtendService; |
|
|
|
import com.yxt.base.biz.base.basegoodsskuextend.BaseGoodsSkuExtendVo; |
|
|
|
import com.yxt.base.biz.base.basegoodsskuextend.UrlsVo; |
|
|
|
import com.yxt.base.biz.base.basegoodsspudetail.BaseGoodsSpuDetailVo; |
|
|
|
import com.yxt.base.biz.base.basegoodsunit.BaseGoodsUnit; |
|
|
|
import com.yxt.base.biz.base.basegoodsunit.BaseGoodsUnitService; |
|
|
|
import com.yxt.base.feign.portal.sysorganization.SysOrganizationFeign; |
|
|
|
import com.yxt.base.feign.portal.sysorganization.SysOrganizationVo; |
|
|
|
import com.yxt.base.feign.portal.sysstafforg.SysStaffOrgFeign; |
|
|
|
import com.yxt.base.utils.PinYinUtils; |
|
|
|
import com.yxt.common.base.config.component.FileUploadComponent; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
@ -32,10 +37,7 @@ import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
/** |
|
|
|
* @author wangpengfei |
|
|
@ -53,14 +55,23 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
BaseGoodsUnitService baseGoodsUnitService; |
|
|
|
@Autowired |
|
|
|
BaseGoodsSkuExtendService baseGoodsSkuExtendService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SysStaffOrgFeign sysStaffOrgFeign; |
|
|
|
@Autowired |
|
|
|
private SysOrganizationFeign sysOrganizationFeign; |
|
|
|
@Autowired |
|
|
|
private BaseGoodsTypeService baseGoodsTypeService; |
|
|
|
@Autowired |
|
|
|
private BaseBrandInfoService baseBrandInfoService; |
|
|
|
@Autowired |
|
|
|
private BaseManufacturerService baseManufacturerService; |
|
|
|
|
|
|
|
public ResultBean<PagerVo<BaseGoodsSpuVo>> listPage(PagerQuery<BaseGoodsSpuQuery> pq) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
BaseGoodsSpuQuery query = pq.getParams(); |
|
|
|
QueryWrapper<BaseGoodsSpu> qw = new QueryWrapper<>(); |
|
|
|
if(StringUtils.isNotBlank(query.getName())){ |
|
|
|
qw.like("goodsName",query.getName()); |
|
|
|
if (StringUtils.isNotBlank(query.getName())) { |
|
|
|
qw.like("goodsName", query.getName()); |
|
|
|
} |
|
|
|
IPage<BaseGoodsSpu> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<BaseGoodsSpuVo> pagging = baseMapper.listPage(page, qw); |
|
|
@ -76,18 +87,19 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
// }
|
|
|
|
return rb.success().setData(p); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional |
|
|
|
public ResultBean<String> saveOrUpdate(BaseGoodsSpuDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String sid = ""; |
|
|
|
BaseGoodsSpu spun= baseMapper.selectOne(new QueryWrapper<BaseGoodsSpu>().eq("sid",dto.getSid())); |
|
|
|
BaseGoodsUnit baseGoodsUnit=baseGoodsUnitService.getOne(new QueryWrapper<BaseGoodsUnit>().eq("sid",dto.getGoodsUnitSid())); |
|
|
|
if(null!=baseGoodsUnit){ |
|
|
|
BaseGoodsSpu spun = baseMapper.selectOne(new QueryWrapper<BaseGoodsSpu>().eq("sid", dto.getSid())); |
|
|
|
BaseGoodsUnit baseGoodsUnit = baseGoodsUnitService.getOne(new QueryWrapper<BaseGoodsUnit>().eq("sid", dto.getGoodsUnitSid())); |
|
|
|
if (null != baseGoodsUnit) { |
|
|
|
dto.setGoodsUnitName(baseGoodsUnit.getUnitName()); |
|
|
|
} |
|
|
|
|
|
|
|
if (spun!=null) { |
|
|
|
if(!spun.getSid().equals(dto.getSid())){ |
|
|
|
if (spun != null) { |
|
|
|
if (!spun.getSid().equals(dto.getSid())) { |
|
|
|
return rb.setMsg("商品编码重复"); |
|
|
|
} |
|
|
|
sid = dto.getSid(); |
|
|
@ -95,19 +107,20 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
BeanUtil.copyProperties(dto, wmsGoods); |
|
|
|
wmsGoods.setModifyTime(new Date()); |
|
|
|
// wmsGoods.setGoodsPY(PinYinUtils.getPinYinName(wmsGoods.getGoodsName()));;
|
|
|
|
wmsGoods.setGoodsPY(PinYinUtils.sx(wmsGoods.getGoodsName()));; |
|
|
|
wmsGoods.setGoodsPY(PinYinUtils.sx(wmsGoods.getGoodsName())); |
|
|
|
; |
|
|
|
baseMapper.updateById(wmsGoods); |
|
|
|
//spu详情
|
|
|
|
dto.getBaseGoodsSpuDetail().setGoodSpuSid(wmsGoods.getSid()); |
|
|
|
baseGoodsSpuDetailService.saveOrUpdate(dto.getBaseGoodsSpuDetail()); |
|
|
|
//商品sku
|
|
|
|
dto.getBaseGoodsSkus().forEach(s->{ |
|
|
|
dto.getBaseGoodsSkus().forEach(s -> { |
|
|
|
s.setGoodsSpuSid(wmsGoods.getSid()); |
|
|
|
}); |
|
|
|
baseGoodsSkuService.saveOrUpdate(dto.getBaseGoodsSkus()); |
|
|
|
} else { |
|
|
|
BaseGoodsSpu spu=baseMapper.selectOne(new QueryWrapper<BaseGoodsSpu>().eq("goodsCode",dto.getGoodsCode())); |
|
|
|
if(spu!=null){ |
|
|
|
BaseGoodsSpu spu = baseMapper.selectOne(new QueryWrapper<BaseGoodsSpu>().eq("goodsCode", dto.getGoodsCode())); |
|
|
|
if (spu != null) { |
|
|
|
return rb.setMsg("商品编码重复"); |
|
|
|
} |
|
|
|
BaseGoodsSpu wmsGoods = new BaseGoodsSpu(); |
|
|
@ -120,7 +133,7 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
dto.getBaseGoodsSpuDetail().setGoodSpuSid(wmsGoods.getSid()); |
|
|
|
baseGoodsSpuDetailService.saveOrUpdate(dto.getBaseGoodsSpuDetail()); |
|
|
|
//商品sku
|
|
|
|
dto.getBaseGoodsSkus().forEach(s->{ |
|
|
|
dto.getBaseGoodsSkus().forEach(s -> { |
|
|
|
s.setGoodsSpuSid(wmsGoods.getSid()); |
|
|
|
}); |
|
|
|
baseGoodsSkuService.saveOrUpdate(dto.getBaseGoodsSkus()); |
|
|
@ -132,16 +145,17 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
public ResultBean<BaseGoodsSpuVo> initialization(String sid) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
BaseGoodsSpuVo vo = baseMapper.initialization(sid); |
|
|
|
BaseGoodsSpuDetailVo vo1=baseGoodsSpuDetailService.getSpuDetailsBySpuSid(vo.getSid()).getData(); |
|
|
|
BaseGoodsSpuDetailVo vo1 = baseGoodsSpuDetailService.getSpuDetailsBySpuSid(vo.getSid()).getData(); |
|
|
|
vo.setBaseGoodsSpuDetail(vo1); |
|
|
|
List<BaseGoodsSkuVo> vos=baseGoodsSkuService.getSkusBySpuSid(vo.getSid()).getData(); |
|
|
|
List<BaseGoodsSkuVo> vos = baseGoodsSkuService.getSkusBySpuSid(vo.getSid()).getData(); |
|
|
|
for (BaseGoodsSkuVo baseGoodsSkuVo : vos) { |
|
|
|
List<UrlsVo> ur=new ArrayList<>(); |
|
|
|
BaseGoodsSkuExtendVo vo2=baseGoodsSkuExtendService.getExtendBySkuSid(baseGoodsSkuVo.getSid()).getData(); |
|
|
|
if(StringUtils.isNotBlank(vo2.getPicUrl())){ |
|
|
|
List<UrlsVo> ur = new ArrayList<>(); |
|
|
|
BaseGoodsSkuExtendVo vo2 = baseGoodsSkuExtendService.getExtendBySkuSid(baseGoodsSkuVo.getSid()).getData(); |
|
|
|
if (StringUtils.isNotBlank(vo2.getPicUrl())) { |
|
|
|
for (String url : vo2.getPicUrl().split(",")) { |
|
|
|
url=fileUploadComponent.getUrlPrefix()+url; |
|
|
|
UrlsVo vo3=new UrlsVo();vo3.setUrl(url); |
|
|
|
url = fileUploadComponent.getUrlPrefix() + url; |
|
|
|
UrlsVo vo3 = new UrlsVo(); |
|
|
|
vo3.setUrl(url); |
|
|
|
ur.add(vo3); |
|
|
|
} |
|
|
|
} |
|
|
@ -153,7 +167,6 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ResultBean delete(String sid) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
BaseGoodsSpu wmsGoods = fetchBySid(sid); |
|
|
@ -163,7 +176,7 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean updateIsEnable(String sid,String isEnable) { |
|
|
|
public ResultBean updateIsEnable(String sid, String isEnable) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
BaseGoodsSpu wmsGoods = fetchBySid(sid); |
|
|
|
if (null != wmsGoods) { |
|
|
@ -172,4 +185,303 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
} |
|
|
|
return rb.success().setMsg("成功"); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<PagerVo<BaseGoodsSpuListVo>> goodsListPage(PagerQuery<BaseGoodsSpuListQuery> pq) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
BaseGoodsSpuListQuery query = pq.getParams(); |
|
|
|
QueryWrapper<BaseGoodsSpu> qw = new QueryWrapper<>(); |
|
|
|
if (StringUtils.isNotBlank(query.getOrgPath())) { |
|
|
|
String createOrgSid = sysStaffOrgFeign.getOrgSidByPath(query.getOrgPath()).getData(); |
|
|
|
qw.eq("p.createOrgSid", createOrgSid); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getGoodsPY())) { |
|
|
|
qw.like("p.goodsPY", query.getGoodsPY()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getCreateOrgName())) { |
|
|
|
qw.like("p.createOrgName", query.getCreateOrgName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getUseOrgName())) { |
|
|
|
qw.like("p.useOrgName", query.getUseOrgName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getGoodsName())) { |
|
|
|
qw.like("p.goodsName", query.getGoodsName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getGoodsCode())) { |
|
|
|
qw.like("p.goodsCode", query.getGoodsCode()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getGoodsTypeName())) { |
|
|
|
qw.like("t.goodsTypeName", query.getGoodsTypeName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getBrandName())) { |
|
|
|
qw.like("b.brandName", query.getBrandName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getManufacturerName())) { |
|
|
|
qw.like("m.manufacturerName", query.getManufacturerName()); |
|
|
|
} |
|
|
|
IPage<BaseGoodsSpu> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<BaseGoodsSpuListVo> pagging = baseMapper.goodsListPage(page, qw); |
|
|
|
PagerVo<BaseGoodsSpuListVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
List<BaseGoodsSpuListVo> records = pagging.getRecords(); |
|
|
|
records.removeAll(Collections.singleton(null)); |
|
|
|
if (!records.isEmpty()) { |
|
|
|
String urlPrefix = fileUploadComponent.getUrlPrefix(); |
|
|
|
for (BaseGoodsSpuListVo record : records) { |
|
|
|
if (StringUtils.isNotBlank(record.getPicUrl())) { |
|
|
|
List<String> files = new ArrayList<>(); |
|
|
|
String picUrl = record.getPicUrl(); |
|
|
|
String[] split = picUrl.split(","); |
|
|
|
for (String s : split) { |
|
|
|
files.add(urlPrefix + s); |
|
|
|
} |
|
|
|
record.setPicPath(files); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success().setData(p); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional |
|
|
|
public ResultBean<String> saveOrUpdateGoods(BaseGoodsDetailsDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String sid = ""; |
|
|
|
String orgPath = ""; |
|
|
|
if (StringUtils.isNotBlank(dto.getOrgPath())) { |
|
|
|
orgPath = dto.getOrgPath(); |
|
|
|
} |
|
|
|
BaseGoodsSpu spun = baseMapper.selectOne(new QueryWrapper<BaseGoodsSpu>().eq("sid", dto.getSid())); |
|
|
|
if (spun != null) { |
|
|
|
if (!spun.getSid().equals(dto.getSid())) { |
|
|
|
return rb.setMsg("商品编码重复"); |
|
|
|
} |
|
|
|
sid = dto.getSid(); |
|
|
|
BaseGoodsSpu wmsGoods = fetchBySid(dto.getSid()); |
|
|
|
BeanUtil.copyProperties(dto, wmsGoods, "id", "sid"); |
|
|
|
wmsGoods.setModifyTime(new Date()); |
|
|
|
wmsGoods.setGoodsPY(PinYinUtils.sx(wmsGoods.getGoodsName())); |
|
|
|
baseMapper.updateById(wmsGoods); |
|
|
|
//商品sku
|
|
|
|
BaseGoodsSku skuUpdate = baseGoodsSkuService.getOneBySpuSid(sid); |
|
|
|
if (null != skuUpdate) { |
|
|
|
if (StringUtils.isNotBlank(dto.getGoodsName())) { |
|
|
|
skuUpdate.setTitle(dto.getGoodsName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(dto.getGoodsCode())) { |
|
|
|
skuUpdate.setGoodsSkuCode(dto.getGoodsCode()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(dto.getIndexes())) { |
|
|
|
skuUpdate.setIndexes(dto.getIndexes()); |
|
|
|
} |
|
|
|
skuUpdate.setModifyTime(new Date()); |
|
|
|
baseGoodsSkuService.updateById(skuUpdate); |
|
|
|
BaseGoodsSkuExtend skuExtendUpdate = baseGoodsSkuExtendService.getOneBySKuSid(skuUpdate.getSid()); |
|
|
|
if (null != skuExtendUpdate) { |
|
|
|
BeanUtil.copyProperties(dto, skuExtendUpdate, "id", "sid"); |
|
|
|
if (StringUtils.isNotBlank(dto.getSkuRemarks())) { |
|
|
|
skuExtendUpdate.setRemarks(dto.getSkuRemarks()); |
|
|
|
} |
|
|
|
List<String> picPath = dto.getPicPath(); |
|
|
|
if (!picPath.isEmpty()) { |
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
String urlPrefix = fileUploadComponent.getUrlPrefix(); |
|
|
|
for (String filePath : picPath) { |
|
|
|
String path = filePath.substring(urlPrefix.length()); |
|
|
|
sb.append(path).append(","); |
|
|
|
} |
|
|
|
sb.delete(sb.length() - 1, sb.length()); |
|
|
|
skuExtendUpdate.setPicUrl(sb.toString()); |
|
|
|
} |
|
|
|
baseGoodsSkuExtendService.updateById(skuExtendUpdate); |
|
|
|
} else { |
|
|
|
BaseGoodsSkuExtend skuExtend = new BaseGoodsSkuExtend(); |
|
|
|
BeanUtil.copyProperties(dto, skuExtend, "id", "sid"); |
|
|
|
skuExtend.setGoodsSkuSid(skuUpdate.getSid()); |
|
|
|
if (StringUtils.isNotBlank(dto.getSkuRemarks())) { |
|
|
|
skuExtend.setRemarks(dto.getSkuRemarks()); |
|
|
|
} |
|
|
|
List<String> picPath = dto.getPicPath(); |
|
|
|
if (!picPath.isEmpty()) { |
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
String urlPrefix = fileUploadComponent.getUrlPrefix(); |
|
|
|
for (String filePath : picPath) { |
|
|
|
String path = filePath.substring(urlPrefix.length()); |
|
|
|
sb.append(path).append(","); |
|
|
|
} |
|
|
|
sb.delete(sb.length() - 1, sb.length()); |
|
|
|
skuExtend.setPicUrl(sb.toString()); |
|
|
|
} |
|
|
|
baseGoodsSkuExtendService.insert(skuExtend); |
|
|
|
} |
|
|
|
} else { |
|
|
|
//商品sku
|
|
|
|
BaseGoodsSku sku = new BaseGoodsSku(); |
|
|
|
sku.setGoodsSpuSid(sid); |
|
|
|
if (StringUtils.isNotBlank(dto.getGoodsName())) { |
|
|
|
sku.setTitle(dto.getGoodsName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(dto.getGoodsCode())) { |
|
|
|
sku.setGoodsSkuCode(dto.getGoodsCode()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(dto.getIndexes())) { |
|
|
|
sku.setIndexes(dto.getIndexes()); |
|
|
|
} |
|
|
|
baseGoodsSkuService.insert(sku); |
|
|
|
//商品sku_extend
|
|
|
|
BaseGoodsSkuExtend skuExtend = new BaseGoodsSkuExtend(); |
|
|
|
BeanUtil.copyProperties(dto, skuExtend, "id", "sid"); |
|
|
|
skuExtend.setGoodsSkuSid(sku.getSid()); |
|
|
|
if (StringUtils.isNotBlank(dto.getSkuRemarks())) { |
|
|
|
skuExtend.setRemarks(dto.getSkuRemarks()); |
|
|
|
} |
|
|
|
List<String> picPath = dto.getPicPath(); |
|
|
|
if (!picPath.isEmpty()) { |
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
String urlPrefix = fileUploadComponent.getUrlPrefix(); |
|
|
|
for (String filePath : picPath) { |
|
|
|
String path = filePath.substring(urlPrefix.length()); |
|
|
|
sb.append(path).append(","); |
|
|
|
} |
|
|
|
sb.delete(sb.length() - 1, sb.length()); |
|
|
|
skuExtend.setPicUrl(sb.toString()); |
|
|
|
} |
|
|
|
baseGoodsSkuExtendService.insert(skuExtend); |
|
|
|
} |
|
|
|
} else { |
|
|
|
BaseGoodsSpu spu = baseMapper.selectOne(new QueryWrapper<BaseGoodsSpu>().eq("goodsCode", dto.getGoodsCode())); |
|
|
|
if (spu != null) { |
|
|
|
return rb.setMsg("商品编码重复"); |
|
|
|
} |
|
|
|
BaseGoodsSpu wmsGoods = new BaseGoodsSpu(); |
|
|
|
sid = wmsGoods.getSid(); |
|
|
|
BeanUtil.copyProperties(dto, wmsGoods, "id", "sid"); |
|
|
|
wmsGoods.setCreateBySid(dto.getUserSid()); |
|
|
|
String deptName = ""; |
|
|
|
String deptSid = ""; |
|
|
|
String createOrgSid = ""; |
|
|
|
if (StringUtils.isNotBlank(orgPath)) { |
|
|
|
List<String> split = Arrays.asList(orgPath.split("/")); |
|
|
|
if (split.size() > 1) { |
|
|
|
//获取本级sid获取本级部门信息
|
|
|
|
SysOrganizationVo sysOrganization = sysOrganizationFeign.fetchBySid(split.get(split.size() - 2)).getData(); |
|
|
|
SysOrganizationVo sysOrganization1 = sysOrganizationFeign.fetchBySid(split.get(split.size() - 1)).getData(); |
|
|
|
deptName = sysOrganization.getName() + "/" + sysOrganization1.getName(); |
|
|
|
deptName = sysOrganization1.getName(); |
|
|
|
deptSid = sysOrganization1.getSid(); |
|
|
|
} else { |
|
|
|
SysOrganizationVo sysOrganization = sysOrganizationFeign.fetchBySid(split.get(0)).getData(); |
|
|
|
deptName = sysOrganization.getName(); |
|
|
|
deptName = sysOrganization.getName(); |
|
|
|
deptSid = sysOrganization.getSid(); |
|
|
|
} |
|
|
|
wmsGoods.setUseOrgName(deptName); |
|
|
|
wmsGoods.setUseOrgSid(deptSid); |
|
|
|
createOrgSid = sysStaffOrgFeign.getOrgSidByPath(orgPath).getData(); |
|
|
|
//创建组织使用组织
|
|
|
|
ResultBean<SysOrganizationVo> organizationResultBean = sysOrganizationFeign.fetchBySid(createOrgSid); |
|
|
|
if (organizationResultBean.getData() != null) { |
|
|
|
wmsGoods.setCreateOrgName(organizationResultBean.getData().getName()); |
|
|
|
wmsGoods.setCreateOrgSid(createOrgSid); |
|
|
|
} |
|
|
|
} |
|
|
|
wmsGoods.setGoodsPY(PinYinUtils.sx(wmsGoods.getGoodsName())); |
|
|
|
baseMapper.insert(wmsGoods); |
|
|
|
//商品sku
|
|
|
|
BaseGoodsSku sku = new BaseGoodsSku(); |
|
|
|
sku.setGoodsSpuSid(sid); |
|
|
|
if (StringUtils.isNotBlank(dto.getGoodsName())) { |
|
|
|
sku.setTitle(dto.getGoodsName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(dto.getGoodsCode())) { |
|
|
|
sku.setGoodsSkuCode(dto.getGoodsCode()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(dto.getIndexes())) { |
|
|
|
sku.setIndexes(dto.getIndexes()); |
|
|
|
} |
|
|
|
baseGoodsSkuService.insert(sku); |
|
|
|
//商品sku_extend
|
|
|
|
BaseGoodsSkuExtend skuExtend = new BaseGoodsSkuExtend(); |
|
|
|
BeanUtil.copyProperties(dto, skuExtend, "id", "sid"); |
|
|
|
skuExtend.setGoodsSkuSid(sku.getSid()); |
|
|
|
if (StringUtils.isNotBlank(dto.getSkuRemarks())) { |
|
|
|
skuExtend.setRemarks(dto.getSkuRemarks()); |
|
|
|
} |
|
|
|
List<String> picPath = dto.getPicPath(); |
|
|
|
if (!picPath.isEmpty()) { |
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
String urlPrefix = fileUploadComponent.getUrlPrefix(); |
|
|
|
for (String filePath : picPath) { |
|
|
|
String path = filePath.substring(urlPrefix.length()); |
|
|
|
sb.append(path).append(","); |
|
|
|
} |
|
|
|
sb.delete(sb.length() - 1, sb.length()); |
|
|
|
skuExtend.setPicUrl(sb.toString()); |
|
|
|
} |
|
|
|
baseGoodsSkuExtendService.insert(skuExtend); |
|
|
|
} |
|
|
|
return rb.success().setData(sid); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<BaseGoodsDetailsVo> goodsDetails(String sid) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
BaseGoodsDetailsVo vo = new BaseGoodsDetailsVo(); |
|
|
|
BaseGoodsSpu baseGoodsSpu = fetchBySid(sid); |
|
|
|
if (null != baseGoodsSpu) { |
|
|
|
BeanUtil.copyProperties(baseGoodsSpu, vo); |
|
|
|
if (StringUtils.isNotBlank(baseGoodsSpu.getGoodsTypeSid())) { |
|
|
|
BaseGoodsType baseGoodsType = baseGoodsTypeService.fetchBySid(baseGoodsSpu.getGoodsTypeSid()); |
|
|
|
if (null != baseGoodsType) { |
|
|
|
if (StringUtils.isNotBlank(baseGoodsType.getGoodsTypeName())) { |
|
|
|
vo.setGoodsTypeName(baseGoodsType.getGoodsTypeName()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(baseGoodsSpu.getBrandSid())) { |
|
|
|
BaseBrandInfo baseBrandInfo = baseBrandInfoService.fetchBySid(baseGoodsSpu.getBrandSid()); |
|
|
|
if (null != baseBrandInfo) { |
|
|
|
if (StringUtils.isNotBlank(baseBrandInfo.getBrandName())) { |
|
|
|
vo.setBrandName(baseBrandInfo.getBrandName()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(baseGoodsSpu.getManufacturerSid())) { |
|
|
|
BaseManufacturer manufacturer = baseManufacturerService.fetchBySid(baseGoodsSpu.getManufacturerSid()); |
|
|
|
if (null != manufacturer) { |
|
|
|
if (StringUtils.isNotBlank(manufacturer.getManufacturerName())) { |
|
|
|
vo.setManufacturerName(manufacturer.getManufacturerName()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
BaseGoodsSku sku = baseGoodsSkuService.getOneBySpuSid(sid); |
|
|
|
if (null != sku) { |
|
|
|
if (StringUtils.isNotBlank(sku.getIndexes())) { |
|
|
|
vo.setIndexes(sku.getIndexes()); |
|
|
|
} |
|
|
|
BaseGoodsSkuExtend skuExtend = baseGoodsSkuExtendService.getOneBySKuSid(sku.getSid()); |
|
|
|
if (null != skuExtend) { |
|
|
|
BeanUtil.copyProperties(skuExtend, vo, "sid"); |
|
|
|
if (StringUtils.isNotBlank(skuExtend.getRemarks())) { |
|
|
|
vo.setSkuRemarks(skuExtend.getRemarks()); |
|
|
|
} |
|
|
|
String urlPrefix = fileUploadComponent.getUrlPrefix(); |
|
|
|
if (StringUtils.isNotBlank(skuExtend.getPicUrl())) { |
|
|
|
List<String> files = new ArrayList<>(); |
|
|
|
String picUrl = skuExtend.getPicUrl(); |
|
|
|
String[] split = picUrl.split(","); |
|
|
|
for (String s : split) { |
|
|
|
files.add(urlPrefix + s); |
|
|
|
} |
|
|
|
vo.setPicPath(files); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success().setData(vo); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean deleteBySids(String[] sids) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
for (String sid : sids) { |
|
|
|
baseMapper.delBySpuSid(sid); |
|
|
|
} |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
} |
|
|
|