12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076 |
- package com.kmall.admin.service.impl;
- import com.google.common.collect.ImmutableBiMap;
- import com.google.common.collect.Maps;
- import com.kmall.admin.dao.*;
- import com.kmall.admin.dto.GoodsDetailsDto;
- import com.kmall.admin.dto.GoodsDto;
- import com.kmall.admin.entity.*;
- import com.kmall.admin.service.GoodsService;
- import com.kmall.admin.utils.ShiroUtils;
- import com.kmall.common.constant.Dict;
- import com.kmall.admin.fromcomm.entity.SysUserEntity;
- import com.kmall.common.utils.*;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import java.math.BigDecimal;
- import java.util.*;
- /**
- * Service实现类
- *
- * @author Scott
- * @email
- * @date 2017-08-21 21:19:49
- */
- @Service("goodsService")
- public class GoodsServiceImpl implements GoodsService {
- @Autowired
- private GoodsDao goodsDao;
- @Autowired
- private ProductDao productDao;
- @Autowired
- private GoodsGalleryDao goodsGalleryDao;
- @Autowired
- private GoodsSpecificationDao goodsSpecificationDao;
- @Autowired
- private ProductStoreRelaDao productStoreRelaDao;
- @Autowired
- private StoreDao storeDao;
- @Autowired
- private GoodsGroupDao goodsGroupDao;
- @Autowired
- private CategoryDao categoryDao;
- @Autowired
- private SupplierDao supplierDao;
- @Autowired
- private SysCusNationCodeDao sysCusNationCodeDao;
- @Autowired
- private SysCusUnitCodeDao sysCusUnitCodeDao;
- @Autowired
- private ExportExceptionDataDao exportExceptionDataDao;
- @Autowired
- private CartDao cartDao;
- @Autowired
- private ThirdMerchantBizDao thirdMerchantBizDao;
- @Autowired
- private MngChangeDao mngChangeDao;
- @Autowired
- private MerchUserDao merchUserDao;
- @Autowired
- private StoreMngChangeDao storeMngChangeDao;
- @Override
- public GoodsEntity queryObject(Integer id) {
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("goodsId", id);
- // List<GoodsAttributeEntity> attributeEntities = goodsAttributeDao.queryList(map);
- List<ProductEntity> productEntityList = productDao.queryList(map);
- GoodsEntity entity = goodsDao.queryObject(id);
- // entity.setAttributeEntityList(attributeEntities);
- entity.setProductEntityList(productEntityList);
- return entity;
- }
- @Override
- public GoodsEntity queryObjectByProdBarcodeAndBizType(String prodBarcode, Integer storeId){
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("prodBarcode", prodBarcode);
- GoodsEntity entity = goodsDao.queryObjectByProdBarcodeAndBizType(prodBarcode, storeId);
- return entity;
- }
- @Override
- public List<GoodsEntity> queryList(Map<String, Object> map) {
- return goodsDao.queryList(map);
- }
- @Override
- public List<GoodsEntity> querySame(Map<String, Object> map) {
- return goodsDao.querySame(map);
- }
- @Override
- public int queryTotal(Map<String, Object> map) {
- return goodsDao.queryTotal(map);
- }
- @Override
- @Transactional
- public int save(GoodsEntity goods) {
- Map<String, Object> valideDate = MapBeanUtil.fromObject(goods);
- ImmutableBiMap.Builder builder = new ImmutableBiMap.Builder();
- builder.put("merchSn", "商户编号");
- builder.put("thirdPartyMerchCode", "第三方商户编号");
- // builder.put("attributeCategory", "商品分类");
- // builder.put("categoryId", "商品二级分类");
- builder.put("goodsSn", "商品编码");
- builder.put("name", "商品名称");
- builder.put("goodsUnit", "商品单位");
- builder.put("prodBarcode", "产品条码");
- builder.put("goodsBizType", "货品业务类型");
- // builder.put("brandId", "品牌");
- builder.put("supplierId", "供应商");
- // builder.put("freightId", "运费模版");
- builder.put("goodsNumber", "商品总库存");
- builder.put("primaryPicUrl", "商品主图");
- builder.put("listPicUrl", "商品列表图");
- builder.put("goodsDesc", "商品描述");
- builder.put("isOnSale", "上架");
- builder.put("isHot", "热销");
- R r = ValidatorUtil.isEmpty(builder.build(), valideDate);
- if (Integer.valueOf(r.get("code").toString()) != 0) {
- throw new RRException(r.get("msg").toString());
- } else {
- if (!Dict.orderBizType.item_11.getItem().equals(goods.getGoodsBizType())) {
- // 海关信息,普通货物可不添加
- builder.put("sku", "SKU");
- builder.put("goodsRate", "商品税率");
- // builder.put("retailPrice", "零售价");
- builder.put("brand", "产品品牌");
- builder.put("unitCode", "计量单位代码");
- builder.put("cusGoodsCode", "海关商品编码");
- builder.put("ciqProdModel", "国检规格型号");
- builder.put("oriCntCode", "原产国代码");
- builder.put("cusDeclEle", "海关申报要素");
- builder.put("cusRecCode", "海关备案编号");
- }
- r = ValidatorUtil.isEmpty(builder.build(), valideDate);
- if (Integer.valueOf(r.get("code").toString()) != 0) {
- throw new RRException(r.get("msg").toString());
- }
- }
- /*ThirdMerchantBizEntity thirdMerchantBizEntity = thirdMerchantBizDao.getThirdMerchangByCode(goods.getThirdPartyMerchCode());
- if(thirdMerchantBizEntity == null){
- throw new RRException("第三方商户信息不存在");
- }
- if(Dict.orderBizType.item_00.getItem().equalsIgnoreCase(goods.getGoodsBizType())){
- if(Dict.isStockShare.item_1.getItem().equalsIgnoreCase(thirdMerchantBizEntity.getIsStockShare())){
- builder.put("goodsNumber", "商品库存");
- }
- }*/
- r = ValidatorUtil.isEmpty(builder.build(), valideDate);
- if (Integer.valueOf(r.get("code").toString()) != 0) {
- throw new RRException(r.get("msg").toString());
- }
- // 商品轮播图
- List<GoodsGalleryEntity> galleryEntityList = goods.getGoodsImgList();
- if (galleryEntityList == null || galleryEntityList.size() <= 0) {
- throw new RRException("至少添加一张商品轮播图!");
- }
- List<GoodsEntity> prodbarGoodsList = goodsDao.queryObjectByProdBarcode(goods.getProdBarcode(),goods.getMerchSn(),null);
- if(prodbarGoodsList != null && prodbarGoodsList.size() > 0){
- throw new RRException("不能有重复的产品条码信息!");
- }
- SysUserEntity user = ShiroUtils.getUserEntity();
- Map<String, Object> map = new HashMap<>();
- map.put("isSame", "true");
- map.put("sku", goods.getSku());
- map.put("goodsSn", goods.getGoodsSn());
- map.put("goodsBizType", goods.getGoodsBizType());
- List<GoodsEntity> list = querySame(map);
- if (list != null && list.size() != 0) {
- throw new RRException("已存在该商品编码,或该货品业务类型下已存在此SKU!");
- }
- // 添加商品
- if (Dict.orderBizType.item_02.getItem().equals(goods.getGoodsBizType())
- || Dict.orderBizType.item_10.getItem().equals(goods.getGoodsBizType())) {
- goods.setIsHot(0);
- }
- // goods.setAttributeCategory(categoryDao.queryObject(goods.getCategoryId()).getParentId());
- goods.setAddTime(new Date());
- goods.setIsDelete(Integer.parseInt(Dict.isDelete.item_0.getItem()));
- goods.setIsNew(0);
- goods.setCreateUserId(user.getUserId());
- goods.setUpdateUserId(user.getUserId());
- goods.setUpdateTime(new Date());
- goods.setModTime(new Date());
- goods.setCreateTime(new Date());
- // 新增商品
- goodsDao.save(goods);
- Long id = goods.getId();
- // 添加商品轮播图
- for (int i=0;i<galleryEntityList.size();i++) {
- GoodsGalleryEntity galleryEntity =galleryEntityList.get(i);
- galleryEntity.setMerchSn(goods.getMerchSn());
- galleryEntity.setGoodsId(id);
- galleryEntity.setSortOrder((i+1));
- galleryEntity.setFileType("0");//图片
- goodsGalleryDao.save(galleryEntity);
- }
- if(org.apache.commons.lang.StringUtils.isNotEmpty(goods.getVideoUrl())){
- GoodsGalleryEntity galleryEntity = new GoodsGalleryEntity();
- galleryEntity.setMerchSn(goods.getMerchSn());
- galleryEntity.setGoodsId(id);
- galleryEntity.setSortOrder(0);
- galleryEntity.setFileType("1");//视频
- goodsGalleryDao.save(galleryEntity);
- }
- /*
- // 添加商品参数
- List<GoodsAttributeEntity> attributeEntityList = goods.getAttributeEntityList();
- if (attributeEntityList != null && attributeEntityList.size() > 0) {
- for (GoodsAttributeEntity item : attributeEntityList) {
- if (item.getIsDelete() == 0) {
- if (item.getId() == null && item.getAttributeId() != null && StringUtils.isNotEmpty(item.getValue())) {
- item.setGoodsId(id);
- item.setMerchSn(goods.getMerchSn());
- goodsAttributeDao.save(item);
- } else if (item.getId() == null && item.getAttributeId() != null && StringUtils.isNullOrEmpty(item.getValue())) {
- throw new RRException("商品属性【" + attributeDao.queryObject(item.getAttributeId()).getName() + "】值不能为空!");
- } else if (item.getId() == null && item.getAttributeId() == null) {
- continue;
- }
- }
- }
- }*/
- if (goods.getGoodsNumber() != null){
- MngChangeEntity mngChangeEntity = new MngChangeEntity();
- mngChangeEntity.setGoodsId(Integer.parseInt(String.valueOf(id)));
- mngChangeEntity.setThirdPartyMerchCode(goods.getThirdPartyMerchCode());
- mngChangeEntity.setChangeReason("新增商户商品总库存");
- mngChangeEntity.setChangeType(Dict.changeType.item_0.getItem());
- mngChangeEntity.setChangeNum(goods.getGoodsNumber());//变化数
- mngChangeEntity.setOriginalNum(0);//原库存数
- mngChangeEntity.setValidNum(goods.getGoodsNumber());//可用数
- mngChangeEntity.setCreateTime(new Date());
- mngChangeEntity.setModTime(new Date());
- mngChangeEntity.setCreaterSn(user.getUsername());
- mngChangeEntity.setModerSn(user.getUsername());
- mngChangeEntity.setIsValid(0);
- mngChangeEntity.setMerchSn(goods.getMerchSn());
- mngChangeDao.save(mngChangeEntity);
- }
- // 添加产品
- ProductEntity product = new ProductEntity();
- product.setGoodsId(id);
- product.setGoodsSn(goods.getGoodsSn());
- // 保税商品,普通货物暂不添加商品规格
- if (!Dict.orderBizType.item_11.getItem().equals(goods.getGoodsBizType())) {
- // 添加商品规格
- GoodsSpecificationEntity goodsSpecification = new GoodsSpecificationEntity();
- goodsSpecification.setGoodsId(id);
- goodsSpecification.setValue(goods.getCiqProdModel());
- goodsSpecification.setSpecificationId(1);
- goodsSpecificationDao.save(goodsSpecification);
- product.setGoodsSpecificationIds(goodsSpecification.getId().toString());
- product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
- }
- return productDao.save(product);
- }
- @Override
- @Transactional
- public int update(GoodsEntity goods) {
- Map<String, Object> valideDate = MapBeanUtil.fromObject(goods);
- ImmutableBiMap.Builder builder = new ImmutableBiMap.Builder();
- builder.put("merchSn", "商户编号");
- builder.put("thirdPartyMerchCode", "第三方商户编号");
- // builder.put("attributeCategory", "商品分类");
- // builder.put("categoryId", "商品二级分类");
- builder.put("goodsSn", "商品编码");
- builder.put("name", "商品名称");
- builder.put("goodsUnit", "商品单位");
- builder.put("prodBarcode", "产品条码");
- builder.put("goodsBizType", "货品业务类型");
- // builder.put("brandId", "品牌");
- builder.put("supplierId", "供应商");
- builder.put("goodsNumber", "商品总库存");
- // builder.put("freightId", "运费模版");
- builder.put("primaryPicUrl", "商品主图");
- builder.put("listPicUrl", "商品列表图");
- builder.put("goodsDesc", "商品描述");
- builder.put("isOnSale", "上架");
- builder.put("isHot", "热销");
- R r = ValidatorUtil.isEmpty(builder.build(), valideDate);
- if (Integer.valueOf(r.get("code").toString()) != 0) {
- throw new RRException(r.get("msg").toString());
- } else {
- if (!Dict.orderBizType.item_11.getItem().equals(goods.getGoodsBizType())) {
- // 海关信息,普通货物可不添加
- builder.put("sku", "SKU");
- builder.put("goodsRate", "商品税率");
- // builder.put("retailPrice", "零售价");
- builder.put("brand", "产品品牌");
- builder.put("unitCode", "计量单位代码");
- builder.put("cusGoodsCode", "海关商品编码");
- builder.put("ciqProdModel", "国检规格型号");
- builder.put("oriCntCode", "原产国代码");
- builder.put("cusRecCode", "海关备案编号");
- builder.put("cusDeclEle", "海关申报要素");
- }
- r = ValidatorUtil.isEmpty(builder.build(), valideDate);
- if (Integer.valueOf(r.get("code").toString()) != 0) {
- throw new RRException(r.get("msg").toString());
- }
- }
- /*ThirdMerchantBizEntity thirdMerchantBizEntity = thirdMerchantBizDao.getThirdMerchangByCode(goods.getThirdPartyMerchCode());
- if(thirdMerchantBizEntity == null){
- throw new RRException("所属第三方商户不存在");
- }*/
- GoodsEntity goodsEntity = goodsDao.queryObject(goods.getId());
- if(goodsEntity != null){
- /*if(Dict.orderBizType.item_00.getItem().equalsIgnoreCase(goods.getGoodsBizType())){
- if(Dict.isStockShare.item_1.getItem().equalsIgnoreCase(thirdMerchantBizEntity.getIsStockShare())){
- builder.put("goodsNumber", "商品库存");
- }
- }
- r = ValidatorUtil.isEmpty(builder.build(), valideDate);
- if (Integer.valueOf(r.get("code").toString()) != 0) {
- throw new RRException(r.get("msg").toString());
- }*/
- }else{
- throw new RRException("商品不存在");
- }
- // 商品轮播图
- List<GoodsGalleryEntity> galleryEntityList = goods.getGoodsImgList();
- if (galleryEntityList == null || galleryEntityList.size() <= 0) {
- throw new RRException("至少保留一张商品轮播图!");
- }
- List<GoodsEntity> prodbarGoodsList = goodsDao.queryObjectByProdBarcode(goods.getProdBarcode(),goods.getMerchSn(),goods.getId());
- if(prodbarGoodsList != null && prodbarGoodsList.size() > 0){
- throw new RRException("不能有重复的产品条码信息!");
- }
- SysUserEntity user = ShiroUtils.getUserEntity();
- Map<String, Object> map = new HashMap<>();
- map.put("isSame", "true");
- map.put("sku", goods.getSku());
- map.put("goodsSn", goods.getGoodsSn());
- map.put("goodsBizType", goods.getGoodsBizType());
- map.put("id", goods.getId());
- List<GoodsEntity> list = querySame(map);
- if (list != null && list.size() != 0) {
- throw new RRException("已存在该商品编码,或该货品业务类型下已存在此SKU!");
- }
- // 修改商品
- if (Dict.orderBizType.item_02.getItem().equals(goods.getGoodsBizType())
- || Dict.orderBizType.item_10.getItem().equals(goods.getGoodsBizType())) {
- goods.setIsHot(0);
- }
- // goods.setAttributeCategory(categoryDao.queryObject(goods.getCategoryId()).getParentId());
- goods.setIsDelete(Integer.parseInt(Dict.isDelete.item_0.getItem()));
- goods.setIsNew(0);
- goods.setUpdateUserId(user.getUserId());
- goods.setUpdateTime(new Date());
- goods.setModTime(new Date());
- if(goods.getGoodsNumber()==null){
- goods.setGoodsNumber(0);
- }else{
- if(goodsEntity.getGoodsNumber() == null){
- goodsEntity.setGoodsNumber(0);
- }
- MngChangeEntity mngChangeEntity = new MngChangeEntity();
- mngChangeEntity.setGoodsId(Integer.parseInt(String.valueOf(goods.getId())));
- mngChangeEntity.setThirdPartyMerchCode(goods.getThirdPartyMerchCode());
- mngChangeEntity.setChangeReason("更新商户商品总库存");
- mngChangeEntity.setCreateTime(new Date());
- mngChangeEntity.setModTime(new Date());
- mngChangeEntity.setCreaterSn(user.getUsername());
- mngChangeEntity.setModerSn(user.getUsername());
- mngChangeEntity.setIsValid(0);
- mngChangeEntity.setMerchSn(goods.getMerchSn());
- if(goodsEntity.getGoodsNumber() != goods.getGoodsNumber()) {
- if (goodsEntity.getGoodsNumber() > goods.getGoodsNumber()) {
- mngChangeEntity.setChangeNum(goodsEntity.getGoodsNumber() - goods.getGoodsNumber());//变化数
- mngChangeEntity.setChangeType(Dict.changeType.item_4.getItem());
- } else {
- mngChangeEntity.setChangeNum(goods.getGoodsNumber() - goodsEntity.getGoodsNumber());//变化数
- mngChangeEntity.setChangeType(Dict.changeType.item_3.getItem());
- }
- mngChangeEntity.setOriginalNum(goodsEntity.getGoodsNumber());//原库存数
- mngChangeEntity.setValidNum(goods.getGoodsNumber());//可用数
- mngChangeDao.save(mngChangeEntity);
- }
- }
- // 修改商品
- goodsDao.update(goods);
- // 保税商品修改各个门店商品价格
- List<ProductStoreRelaEntity> productStoreRelaEntityList = productStoreRelaDao.queryByGoodsId(goodsEntity.getId());
- Long[] storeIds = new Long[productStoreRelaEntityList.size()];
- Integer goodsNumber = goods.getGoodsNumber();//商品总库存
- Integer storeTotalGoodsNumber = 0;//商品分配库存
- if (productStoreRelaEntityList != null && productStoreRelaEntityList.size() > 0) {
- for (int i = 0; i < productStoreRelaEntityList.size(); i++) {
- //修改该商品的所属商户信息,如在该商户门店中有该上架的商品信息,则提示该商品不能修改
- ProductStoreRelaEntity relaEntity = productStoreRelaEntityList.get(i);
- if(org.apache.commons.lang3.StringUtils.isNotEmpty(relaEntity.getMerchSn()) && relaEntity.getMerchSn().equalsIgnoreCase(goods.getMerchSn())
- && goods.getIsOnSale() == Integer.parseInt(Dict.isOnSale.item_1.getItem())) {
- }else {
- if (goods.getIsOnSale() != Integer.parseInt(Dict.isOnSale.item_0.getItem())) {
- throw new RRException("商品编码为【" + goods.getGoodsSn() + "】的商品已上架在商户编号为【" + relaEntity.getMerchSn() + "】的门店中,可先将该商品下架后再进行修改!");
- }
- }
- storeTotalGoodsNumber = storeTotalGoodsNumber + relaEntity.getStockNum();
- storeIds[i] = relaEntity.getStoreId();
- }
- }
- if(goodsEntity.getIsStockShare().equalsIgnoreCase(Dict.isStockShare.item_0.getItem())) {
- if (goodsNumber < storeTotalGoodsNumber) {
- throw new RRException("该商品已在各门店分配库存" + storeTotalGoodsNumber + ",当前商品总库存不能小于分配库存总额!请先修改门店库存!");
- }
- }else{
- //共享库存商品库存变化,修改该商品的所有库存信息
- ProductStoreRelaEntity productStoreRelaEntity = new ProductStoreRelaEntity();
- productStoreRelaEntity.setStockNum(goodsNumber);
- productStoreRelaEntity.setGoodsId(goods.getId());
- productStoreRelaDao.updateStockNumByGoodsId(productStoreRelaEntity);
- for (int i = 0; i < productStoreRelaEntityList.size(); i++) {
- ProductStoreRelaEntity relaEntity = productStoreRelaEntityList.get(i);
- //新增库存操作记录
- StoreMngChangeEntity storeMngChangeEntity = new StoreMngChangeEntity();
- storeMngChangeEntity.setChangeReason("共享库存变更,更新门店商品库存");
- storeMngChangeEntity.setGoodsId(Integer.parseInt(String.valueOf(relaEntity.getGoodsId())));
- storeMngChangeEntity.setStoreId(Integer.parseInt(String.valueOf(relaEntity.getStoreId())));
- storeMngChangeEntity.setMerchSn(goods.getMerchSn());
- storeMngChangeEntity.setCreateTime(new Date());
- storeMngChangeEntity.setModTime(new Date());
- storeMngChangeEntity.setCreaterSn(user.getUsername());
- storeMngChangeEntity.setModerSn(user.getUsername());
- storeMngChangeEntity.setIsValid(0);
- Integer orginalNum = relaEntity.getStockNum()==null?0:relaEntity.getStockNum();//原有库存
- if(goodsNumber != orginalNum) {
- if (orginalNum > goodsNumber) {
- storeMngChangeEntity.setChangeType(Dict.changeType.item_4.getItem());
- storeMngChangeEntity.setStoreChangeNum(orginalNum - goodsNumber);//变化数
- } else {
- storeMngChangeEntity.setChangeType(Dict.changeType.item_3.getItem());
- storeMngChangeEntity.setStoreChangeNum(goodsNumber - orginalNum);//变化数
- }
- storeMngChangeEntity.setStoreOriginalNum(orginalNum);//原库存数
- storeMngChangeEntity.setStoreValidNum(goodsNumber);//可用数
- storeMngChangeDao.save(storeMngChangeEntity);
- }
- }
- }
- Map cartMap = Maps.newHashMap();
- cartMap.put("goodsId",goods.getId());
- List<CartEntity> cartList = cartDao.queryList(cartMap);
- if (cartList != null && cartList.size() > 0) {
- for (CartEntity cartEntity : cartList) {
- // cartEntity.setRetailPrice(goods.getRetailPrice());
- // cartEntity.setMarketPrice(goods.getMarketPrice());
- cartEntity.setSku(goods.getSku());
- cartEntity.setGoodsName(goods.getName());
- cartEntity.setGoodsSn(goods.getGoodsSn());
- cartDao.update(cartEntity);
- }
- }
- // 修改商品轮播图
- goodsGalleryDao.deleteByGoodsId(goods.getId());
- for (int i=0;i<galleryEntityList.size();i++) {
- GoodsGalleryEntity galleryEntity =galleryEntityList.get(i);
- galleryEntity.setMerchSn(goods.getMerchSn());
- galleryEntity.setGoodsId(goods.getId());
- galleryEntity.setSortOrder((i+1));
- galleryEntity.setFileType("0");//图片
- goodsGalleryDao.save(galleryEntity);
- }
- if(org.apache.commons.lang.StringUtils.isNotEmpty(goods.getVideoUrl())){
- GoodsGalleryEntity galleryEntity = new GoodsGalleryEntity();
- galleryEntity.setMerchSn(goods.getMerchSn());
- galleryEntity.setGoodsId(goods.getId());
- galleryEntity.setSortOrder(0);
- galleryEntity.setFileType("1");//视频
- galleryEntity.setImgUrl(goods.getVideoUrl());
- goodsGalleryDao.save(galleryEntity);
- }
- /*// 修改商品参数
- List<GoodsAttributeEntity> attributeEntityList = goods.getAttributeEntityList();
- if (attributeEntityList != null && attributeEntityList.size() > 0) {
- for (GoodsAttributeEntity item : attributeEntityList) {
- if (item.getIsDelete() == 0) {
- if (item.getId() != null) {
- item.setMerchSn(goods.getMerchSn());
- goodsAttributeDao.update(item);
- } else if (item.getId() == null && item.getAttributeId() != null && StringUtils.isNotEmpty(item.getValue())) {
- item.setGoodsId(goods.getId());
- item.setMerchSn(goods.getMerchSn());
- goodsAttributeDao.save(item);
- } else if (item.getId() == null && item.getAttributeId() != null && StringUtils.isNullOrEmpty(item.getValue())) {
- throw new RRException("商品属性【" + attributeDao.queryObject(item.getAttributeId()).getName() + "】值不能为空!");
- } else if (item.getId() == null && item.getAttributeId() == null) {
- continue;
- }
- } else if (item.getIsDelete() == 1) {
- goodsAttributeDao.delete(item.getId());
- }
- }
- }*/
- // 修改产品
- ProductEntity product = productDao.queryObjectByGoodsIdAndStoreId(String.valueOf(goods.getId()),"");
- GoodsSpecificationEntity goodsSpecification = null;
- // 保税商品,普通货物暂不添加商品规格
- if (!Dict.orderBizType.item_11.getItem().equals(goods.getGoodsBizType())) {
- // 添加商品规格
- goodsSpecification = goodsSpecificationDao.queryByGoodsId(goods.getId());
- if(goodsSpecification != null) {
- goodsSpecification.setValue(goods.getCiqProdModel());
- goodsSpecificationDao.update(goodsSpecification);
- }else{
- goodsSpecification = new GoodsSpecificationEntity();
- goodsSpecification.setGoodsId(goods.getId());
- goodsSpecification.setValue(goods.getCiqProdModel());
- goodsSpecification.setSpecificationId(1);
- goodsSpecificationDao.save(goodsSpecification);
- }
- //更新门店商品是否有修改字段
- if(storeIds.length > 0){
- for(int i=0;i<storeIds.length;i++){
- updateLoadGoodsByStoreId(storeIds[i], user);
- }
- }
- if(product == null){
- product = new ProductEntity();
- product.setGoodsSn(goods.getGoodsSn());
- product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
- product.setGoodsSpecificationIds(goodsSpecification.getId()+"");
- product.setGoodsId(goods.getId());
- product.setGoodsNumber(goods.getGoodsNumber());
- product.setGoodsDefault(0);
- return productDao.save(product);
- }else{
- product.setGoodsSpecificationIds(goodsSpecification.getId().toString());
- product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
- return productDao.update(product);
- }
- }
- return 1;
- }
- /**
- * 更新门店商品是否有修改字段
- * @param storeId
- * @param user
- */
- private void updateLoadGoodsByStoreId(Long storeId, SysUserEntity user){
- List<MerchUserEntity> list = merchUserDao.queryMerchUserByLoadGoods(storeId);
- for(MerchUserEntity entity : list) {
- entity.setIsLoadGoods("1");
- entity.setModerSn(user.getUsername());
- entity.setStoreId(Integer.valueOf(String.valueOf(storeId)));
- merchUserDao.updateStoreLoadGoodsById(entity);
- }
- }
- @Override
- public int delete(Integer id) {
- SysUserEntity user = ShiroUtils.getUserEntity();
- GoodsEntity goodsEntity = goodsDao.queryObject(id);
- goodsEntity.setIsDelete(Integer.parseInt(Dict.isDelete.item_1.getItem()));
- goodsEntity.setIsOnSale(Integer.parseInt(Dict.isOnSale.item_0.getItem()));
- goodsEntity.setUpdateUserId(user.getUserId());
- goodsEntity.setUpdateTime(new Date());
- Map params = Maps.newHashMap();
- params.put("goodsId", id);
- List<GoodsGroupEntity> groupVos = goodsGroupDao.queryList(params);
- if (null != groupVos && groupVos.size() > 0) {
- for (GoodsGroupEntity groupVo : groupVos) {
- groupVo.setOpenStatus(3);
- goodsGroupDao.update(groupVo);
- }
- }
- return goodsDao.update(goodsEntity);
- }
- @Override
- @Transactional
- public int deleteBatch(Integer[] ids) {
- int result = 0;
- for (Integer id : ids) {
- result += delete(id);
- }
- return result;
- }
- @Override
- @Transactional
- public int back(Integer[] ids) {
- SysUserEntity user = ShiroUtils.getUserEntity();
- int result = 0;
- for (Integer id : ids) {
- GoodsEntity goodsEntity = queryObject(id);
- goodsEntity.setIsDelete(Integer.parseInt(Dict.isDelete.item_0.getItem()));
- goodsEntity.setIsOnSale(Integer.parseInt(Dict.isOnSale.item_1.getItem()));
- goodsEntity.setUpdateUserId(user.getUserId());
- goodsEntity.setUpdateTime(new Date());
- result += goodsDao.update(goodsEntity);
- }
- return result;
- }
- @Override
- public int enSale(Integer id) {
- SysUserEntity user = ShiroUtils.getUserEntity();
- GoodsEntity goodsEntity = queryObject(id);
- if (1 == goodsEntity.getIsOnSale()) {
- throw new RRException("此商品已处于上架状态!");
- }
- goodsEntity.setIsOnSale(Integer.parseInt(Dict.isOnSale.item_1.getItem()));
- goodsEntity.setIsDelete(Integer.parseInt(Dict.isDelete.item_0.getItem()));
- goodsEntity.setUpdateUserId(user.getUserId());
- goodsEntity.setUpdateTime(new Date());
- return goodsDao.update(goodsEntity);
- }
- @Override
- public int unSale(Integer id) {
- SysUserEntity user = ShiroUtils.getUserEntity();
- GoodsEntity goodsEntity = queryObject(id);
- if (0 == goodsEntity.getIsOnSale()) {
- throw new RRException("此商品已处于下架状态!");
- }
- goodsEntity.setIsOnSale(Integer.parseInt(Dict.isOnSale.item_0.getItem()));
- goodsEntity.setUpdateUserId(user.getUserId());
- goodsEntity.setUpdateTime(new Date());
- return goodsDao.update(goodsEntity);
- }
- @Override
- public int enSaleBatch(Integer[] ids) {
- int result = 0;
- SysUserEntity user = ShiroUtils.getUserEntity();
- for (Integer id : ids) {
- GoodsEntity goodsEntity = queryObject(id);
- goodsEntity.setIsOnSale(Integer.parseInt(Dict.isOnSale.item_1.getItem()));
- goodsEntity.setIsDelete(Integer.parseInt(Dict.isDelete.item_0.getItem()));
- goodsEntity.setUpdateUserId(user.getUserId());
- goodsEntity.setUpdateTime(new Date());
- result += goodsDao.update(goodsEntity);
- }
- return result;
- }
- @Override
- public int unSaleBatch(Integer[] ids) {
- int result = 0;
- SysUserEntity user = ShiroUtils.getUserEntity();
- for (Integer id : ids) {
- GoodsEntity goodsEntity = queryObject(id);
- goodsEntity.setIsOnSale(Integer.parseInt(Dict.isOnSale.item_0.getItem()));
- goodsEntity.setUpdateUserId(user.getUserId());
- goodsEntity.setUpdateTime(new Date());
- result += goodsDao.update(goodsEntity);
- }
- return result;
- }
- @Override
- public int uploadExcel(List<GoodsDto> goodsEntityList,int exportDataType) {
- SysUserEntity user = ShiroUtils.getUserEntity();
- String merchSn = user.getMerchSn();
- boolean isFail = false;
- List<String> failSameSkuList = new ArrayList<>(), failHotGoodsSnList = new ArrayList<>(),
- failSuppGoodsSnList = new ArrayList<>(),
- failUnitGoodsSnList = new ArrayList<>(), failNationGoodsSnList = new ArrayList<>(),failProdbarGoodsSnList = new ArrayList<>(),
- failTypeGoodsSnList = new ArrayList<>(), failMerchGoodsSnList = new ArrayList<>(),
- // failCateL2GoodsSnList = new ArrayList<>(),
- // failCateGoodsSnList = new ArrayList<>(),
- // failBrandGoodsSnList = new ArrayList<>(),
- // failFreightGoodsSnList = new ArrayList<>(),
- failMerchUserGoodsSnList = new ArrayList<>();
- List<String> failGoodsSnList = new ArrayList<>();
- List<String> failGoodsTypeList = new ArrayList<>();
- // List<String> failFreightList = new ArrayList<>();
- if (goodsEntityList != null && goodsEntityList.size() > 0) {
- for (int i = 0; i < goodsEntityList.size(); i++) {
- GoodsDto goodsDto = goodsEntityList.get(i);
- GoodsEntity goodsEntity = new GoodsEntity();
- Map<String, Object> valideDate = MapBeanUtil.fromObject(goodsDto);
- ImmutableBiMap.Builder builder = new ImmutableBiMap.Builder();
- builder.put("goodsSn", "商品编码");
- builder.put("thirdPartyMerchCode", "第三方商户代码");
- // builder.put("categoryName", "商品分类");
- builder.put("goodsBizType", "货品业务类型");
- builder.put("name", "商品名称");
- // builder.put("brandName", "商品品牌名称");
- // builder.put("defaultFreight", "运费");
- builder.put("isOnSaleStr", "上架");
- builder.put("goodsUnit", "商品单位");
- builder.put("isHotStr", "热销");
- builder.put("prodBarcode", "产品条码");
- // builder.put("marketPrice", "市场价");
- // builder.put("retailPrice", "零售价");
- builder.put("supplierName", "供应商");
- builder.put("goodsNumber", "商品总库存");
- R r = ValidatorUtil.isEmpty(builder.build(), valideDate);
- if (Integer.valueOf(r.get("code").toString()) != 0) {
- throw new RRException(r.get("msg").toString());
- } else {
- if (!Dict.orderBizType.item_11.getItem().equals(goodsDto.getGoodsBizType())) {
- // 海关信息,普通货物可不添加
- builder.put("goodsRate", "商品税率");
- builder.put("sku", "SKU");
- builder.put("brand", "产品品牌");
- builder.put("unitName", "计量单位");
- builder.put("oriCntName", "原产国");
- builder.put("cusGoodsCode", "海关商品编码");
- builder.put("ciqProdModel", "国检规格型号");
- builder.put("cusDeclEle", "海关申报要素");
- builder.put("cusRecCode", "海关备案编号");
- }
- r = ValidatorUtil.isEmpty(builder.build(), valideDate);
- if (Integer.valueOf(r.get("code").toString()) != 0) {
- throw new RRException(r.get("msg").toString());
- }
- }
- //业务类型校验
- if(!Dict.orderBizType.item_11.getItem().equalsIgnoreCase(goodsDto.getGoodsBizType())){
- if(!(Dict.orderBizType.item_02.getItem().equalsIgnoreCase(goodsDto.getGoodsBizType())
- || Dict.orderBizType.item_10.getItem().equalsIgnoreCase(goodsDto.getGoodsBizType())
- || Dict.orderBizType.item_00.getItem().equalsIgnoreCase(goodsDto.getGoodsBizType()))){
- isFail = true;
- failTypeGoodsSnList.add(goodsDto.getSku());
- }
- }
- ThirdMerchantBizEntity thirdMerchantBizEntity = thirdMerchantBizDao.getThirdMerchangByCode(goodsDto.getThirdPartyMerchCode());
- if(thirdMerchantBizEntity != null){
- goodsEntity.setMerchSn(thirdMerchantBizEntity.getMerchSn());
- goodsEntity.setThirdPartyMerchCode(thirdMerchantBizEntity.getThirdPartyMerchCode());
- if(!user.getRoleType().equalsIgnoreCase(Dict.roleType.item_1.getItem())) {
- if (!merchSn.equalsIgnoreCase(thirdMerchantBizEntity.getMerchSn())) {
- isFail = true;
- failMerchUserGoodsSnList.add(goodsDto.getGoodsSn());
- }
- }
- }else{//商户不存在
- isFail = true;
- failMerchGoodsSnList.add(goodsDto.getGoodsSn());
- }
- //校验商品信息是否已存在
- Map<String, Object> map = new HashMap<>();
- map.put("isSame", "true");
- map.put("sku", goodsDto.getSku());
- map.put("goodsSn", goodsDto.getGoodsSn());
- map.put("goodsBizType", goodsDto.getGoodsBizType());
- List<GoodsEntity> list = querySame(map);
- if (list != null && list.size() != 0) {
- isFail = true;
- if(goodsDto.getSku()!=null) {
- failSameSkuList.add(goodsDto.getSku());
- }
- failGoodsSnList.add(goodsDto.getGoodsSn());
- failGoodsTypeList.add(goodsDto.getGoodsBizType());
- }
- //校验产品条码是否存在
- List<GoodsEntity> prodbarGoods = goodsDao.queryObjectByProdBarcode(goodsDto.getProdBarcode(),merchSn,null);
- if(prodbarGoods != null && prodbarGoods.size() > 0){
- isFail = true;
- failProdbarGoodsSnList.add(goodsDto.getGoodsSn());
- }else{
- goodsEntity.setProdBarcode(goodsDto.getProdBarcode());
- }
- //热销商品校验
- if (Dict.orderBizType.item_02.getItem().equals(goodsDto.getGoodsBizType())
- || Dict.orderBizType.item_10.getItem().equals(goodsDto.getGoodsBizType())) {
- if(goodsDto.getIsHotStr().equalsIgnoreCase("1")){
- isFail = true;
- failHotGoodsSnList.add(goodsDto.getGoodsSn());
- }
- }
- if(thirdMerchantBizEntity != null) {
- SupplierEntity supplierEntity = supplierDao.queryObjectByName(goodsDto.getSupplierName(), thirdMerchantBizEntity.getMerchSn(),thirdMerchantBizEntity.getThirdPartyMerchCode());
- if (supplierEntity == null) {
- isFail = true;
- failSuppGoodsSnList.add(goodsDto.getGoodsSn());
- } else {
- goodsEntity.setSupplierId(supplierEntity.getId());
- }
- }
- //商品配置校验
- /*CategoryEntity categoryEntity = categoryDao.queryObjectByName(goodsDto.getCategoryName(),goodsDto.getMerchSn());
- if(categoryEntity==null){
- isFail = true;
- failCateGoodsSnList.add(goodsDto.getGoodsSn());
- }else{
- if(categoryEntity.getLevel().equalsIgnoreCase("L2")) {
- goodsEntity.setCategoryId(categoryEntity.getId());
- goodsEntity.setAttributeCategory(categoryEntity.getParentId());
- }else{
- isFail = true;
- failCateL2GoodsSnList.add(goodsDto.getGoodsSn());
- }
- }
- BrandEntity brandEntity = brandDao.queryObjectByName(goodsDto.getBrandName(),goodsDto.getMerchSn());
- if (brandEntity == null) {
- isFail = true;
- failBrandGoodsSnList.add(goodsDto.getGoodsSn());
- } else {
- goodsEntity.setBrandId(brandEntity.getId());
- }
- //运费
- FreightEntity freightEntity = freightDao.queryObjectByName(goodsDto.getDefaultFreight(),goodsDto.getMerchSn());
- if(freightEntity==null){
- isFail = true;
- failFreightGoodsSnList.add(goodsDto.getGoodsSn());
- failFreightList.add(goodsDto.getDefaultFreight());
- }else {
- goodsEntity.setFreightId(freightEntity.getId());
- }*/
- if (!Dict.orderBizType.item_11.getItem().equals(goodsDto.getGoodsBizType())) {
- SysCusUnitCodeEntity sysCusUnitCodeEntity = sysCusUnitCodeDao.queryObjectByName(goodsDto.getUnitName());
- if (sysCusUnitCodeEntity == null) {
- isFail = true;
- failUnitGoodsSnList.add(goodsDto.getGoodsSn());
- } else {
- goodsEntity.setUnitCode(sysCusUnitCodeEntity.getCode());
- }
- //原产国
- SysCusNationCodeEntity sysCusNationCodeEntity = sysCusNationCodeDao.queryObjectByName(goodsDto.getOriCntName());
- if (sysCusNationCodeEntity == null) {
- isFail = true;
- failNationGoodsSnList.add(goodsDto.getGoodsSn());
- } else {
- goodsEntity.setOriCntCode(sysCusNationCodeEntity.getCode());
- }
- goodsEntity.setGoodsRate(BigDecimal.valueOf(Double.valueOf(goodsDto.getGoodsRate())));
- }
- goodsEntity.setIsOnSale(Integer.parseInt(goodsDto.getIsOnSaleStr()));
- goodsEntity.setIsHot(Integer.parseInt(goodsDto.getIsHotStr()));
- // goodsEntity.setRetailPrice(BigDecimal.valueOf(Integer.valueOf(goodsDto.getRetailPrice())));
- // goodsEntity.setMarketPrice(BigDecimal.valueOf(Integer.valueOf(goodsDto.getMarketPrice())));
- goodsEntity.setGoodsSn(goodsDto.getGoodsSn());
- goodsEntity.setSku(goodsDto.getSku());
- goodsEntity.setName(goodsDto.getName());
- goodsEntity.setGoodsUnit(goodsDto.getGoodsUnit());
- goodsEntity.setGoodsBizType(goodsDto.getGoodsBizType());
- goodsEntity.setBrand(goodsDto.getBrand());
- goodsEntity.setCusDeclEle(goodsDto.getCusDeclEle());
- goodsEntity.setCusGoodsCode(goodsDto.getCusGoodsCode());
- goodsEntity.setCusRecCode(goodsDto.getCusRecCode());
- goodsEntity.setCiqProdModel(goodsDto.getCiqProdModel());
- goodsEntity.setIsDelete(Integer.parseInt(Dict.isDelete.item_0.getItem()));
- goodsEntity.setIsNew(0);
- goodsEntity.setUpdateUserId(user.getUserId());
- goodsEntity.setAddTime(new Date());
- goodsEntity.setCreateTime(new Date());
- goodsEntity.setUpdateTime(new Date());
- goodsEntity.setModTime(new Date());
- goodsEntity.setGoodsNumber(Integer.parseInt(goodsDto.getGoodsNumber()));
- if(!isFail){
- GoodsEntity goods = goodsDao.queryObjectBySn(goodsDto.getGoodsSn());
- if(goods!=null) {// 修改商品
- goodsEntity.setId(goods.getId());
- goodsDao.update(goodsEntity);
- }else{
- goodsDao.save(goodsEntity);
- }
- // // 保税商品修改各个门店商品价格
- // if (!Dict.orderBizType.item_11.getItem().equals(goodsDto.getGoodsBizType())) {
- // List<ProductStoreRelaEntity> productStoreRelaEntityList = productStoreRelaDao.queryByGoodsId(goodsDto.getId());
- // if (productStoreRelaEntityList != null && productStoreRelaEntityList.size() > 0) {
- // for (ProductStoreRelaEntity productStoreRela : productStoreRelaEntityList) {
- // productStoreRela.setMarketPrice(goodsEntity.getMarketPrice());
- // productStoreRela.setRetailPrice(goodsEntity.getRetailPrice());
- // productStoreRelaDao.update(productStoreRela);
- // }
- // }
- // }
- // 修改产品
- ProductEntity product = productDao.queryObjectByGoodsIdAndStoreId(String.valueOf(goodsEntity.getId()), "");
- GoodsSpecificationEntity goodsSpecification = new GoodsSpecificationEntity();
- // 普通货物暂不添加商品规格
- if (!Dict.orderBizType.item_11.getItem().equals(goodsDto.getGoodsBizType())) {
- // 添加商品规格
- GoodsSpecificationEntity specificationEntity = goodsSpecificationDao.queryByGoodsId(goodsEntity.getId());
- if(specificationEntity == null) {
- goodsSpecification.setGoodsId(goodsEntity.getId());
- goodsSpecification.setValue(goodsEntity.getCiqProdModel());
- goodsSpecification.setSpecificationId(1);
- goodsSpecificationDao.save(goodsSpecification);
- }else {
- goodsSpecification.setValue(goodsDto.getCiqProdModel());
- goodsSpecification.setId(specificationEntity.getId());
- goodsSpecificationDao.update(goodsSpecification);
- }
- if(product == null){
- product = new ProductEntity();
- product.setGoodsSn(goodsDto.getGoodsSn());
- product.setGoodsId(goodsEntity.getId());
- product.setGoodsDefault(0);
- product.setGoodsNumber(goodsEntity.getGoodsNumber());
- product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
- product.setGoodsSpecificationIds(goodsSpecification.getId().toString());
- productDao.save(product);
- }else{
- product.setGoodsSpecificationIds(goodsSpecification.getId().toString());
- product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
- productDao.update(product);
- }
- }
- }
- }
- ExportExceptionDataEntity exportExceptionDataEntity = new ExportExceptionDataEntity();
- exportExceptionDataEntity.setCreaterSn(user.getUserId().toString());
- exportExceptionDataEntity.setUserId(user.getUserId().intValue());
- exportExceptionDataEntity.setCreateTime(new Date());
- exportExceptionDataEntity.setModTime(new Date());
- exportExceptionDataEntity.setMerchSn(merchSn);
- exportExceptionDataEntity.setStoreId(user.getStoreId());
- if(exportDataType == 1) {
- exportExceptionDataEntity.setExportDataType(Dict.exportDataType.item_1.getItem());
- }else{
- exportExceptionDataEntity.setExportDataType(Dict.exportDataType.item_2.getItem());
- }
- if(failMerchUserGoodsSnList != null && failMerchUserGoodsSnList.size() > 0){
- exportExceptionDataEntity.setExportExceptionData("不能操作除了登录用户以外商户的商品,当前商户编号为【"+merchSn+"】,请检查商品编码【"+failMerchUserGoodsSnList+"】的商品信息");
- exportExceptionDataDao.save(exportExceptionDataEntity);
- throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
- }
- if(failMerchGoodsSnList != null && failMerchGoodsSnList.size() > 0){
- exportExceptionDataEntity.setExportExceptionData("第三方商户代码不存在,请在商城配置》第三方商户管理中维护,请检查商品编码【"+failMerchGoodsSnList+"】的商品信息,请先维护再继续操作!");
- exportExceptionDataDao.save(exportExceptionDataEntity);
- throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
- }
- if(failGoodsSnList != null && failGoodsSnList.size() > 0){
- if(failSameSkuList.size()>0) {
- exportExceptionDataEntity.setExportExceptionData("不能有重复的商品编码、sku信息!请检查商品编码【" + failGoodsSnList + "】,业务类型【" +
- failGoodsTypeList + "】,SKU【" + failSameSkuList + "】的商品信息");
- exportExceptionDataDao.save(exportExceptionDataEntity);
- throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
- }else{
- exportExceptionDataEntity.setExportExceptionData("不能有重复的商品编码、sku信息!请检查商品编码【" + failGoodsSnList + "】,业务类型【" +
- failGoodsTypeList + "】的商品信息");
- exportExceptionDataDao.save(exportExceptionDataEntity);
- throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
- }
- }
- if(failTypeGoodsSnList != null && failTypeGoodsSnList.size() > 0){
- exportExceptionDataEntity.setExportExceptionData("货品业务类型只能是【00保税备货、02保税补货、10保税展示】!请检查商品编码【"+failTypeGoodsSnList+"】的商品信息");
- exportExceptionDataDao.save(exportExceptionDataEntity);
- throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
- }
- if(failProdbarGoodsSnList != null && failProdbarGoodsSnList.size() > 0){
- exportExceptionDataEntity.setExportExceptionData("不能有重复的产品条码信息!请检查商品编码【"+failProdbarGoodsSnList+"】的商品产品条码信息");
- exportExceptionDataDao.save(exportExceptionDataEntity);
- throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
- }
- if(failHotGoodsSnList != null && failHotGoodsSnList.size() > 0){
- exportExceptionDataEntity.setExportExceptionData("请检查业务类型为【保税补货或保税展示】的商品,商品编码【"+failHotGoodsSnList+"】的商品不能设置为热销!");
- exportExceptionDataDao.save(exportExceptionDataEntity);
- throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
- }
- // if(failCateGoodsSnList != null && failCateGoodsSnList.size() > 0){
- // exportExceptionDataEntity.setExportExceptionData("分类信息请在商城配置》商品分类中维护,商品分类与商户信息对应,请检查该商品商户信息下的分类是否维护,不存在的商品编码【"+failCateGoodsSnList+"】");
- // exportExceptionDataDao.save(exportExceptionDataEntity);
- // throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
- // }
- // if(failCateL2GoodsSnList != null && failCateL2GoodsSnList.size() > 0){
- // exportExceptionDataEntity.setExportExceptionData("分类信息请在商城配置》商品分类中查看,商品分类必须为二级分类,不存在的商品编码【"+failCateL2GoodsSnList+"】");
- // exportExceptionDataDao.save(exportExceptionDataEntity);
- // throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
- // }
- // if(failBrandGoodsSnList != null && failBrandGoodsSnList.size() > 0){
- // exportExceptionDataEntity.setExportExceptionData("品牌信息请在商城配置》品牌制造商中维护,品牌与商户信息对应,请检查该商品商户信息下的品牌是否维护,不存在的商品编码【" + failBrandGoodsSnList + "】");
- // exportExceptionDataDao.save(exportExceptionDataEntity);
- // throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
- // }
- // if(failFreightGoodsSnList != null && failFreightGoodsSnList.size() > 0){
- // exportExceptionDataEntity.setExportExceptionData("运费信息请在商城配置》运费模板中维护,运费与商户信息对应,请检查该商品商户信息下的运费是否维护,不存在的商品编码【"+failFreightGoodsSnList+"】,运费【"+failFreightList+"】");
- // exportExceptionDataDao.save(exportExceptionDataEntity);
- // throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
- // }
- if(failSuppGoodsSnList != null && failSuppGoodsSnList.size() > 0){
- exportExceptionDataEntity.setExportExceptionData("供应商信息请在商城配置》商品供应商中维护,供应商与商户信息对应,请检查该商品商户信息下的供应商是否维护,不存在的商品编码【" + failSuppGoodsSnList + "】");
- exportExceptionDataDao.save(exportExceptionDataEntity);
- throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
- }
- if(failUnitGoodsSnList != null && failUnitGoodsSnList.size() > 0){
- exportExceptionDataEntity.setExportExceptionData("计算单位信息请在商城配置》计算单位中维护,不存在的商品编码【" + failUnitGoodsSnList + "】");
- exportExceptionDataDao.save(exportExceptionDataEntity);
- throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
- }
- if(failNationGoodsSnList != null && failNationGoodsSnList.size() > 0){
- exportExceptionDataEntity.setExportExceptionData("原产国信息请在商城配置》原产国中维护,不存在的商品编码【" + failNationGoodsSnList + "】");
- exportExceptionDataDao.save(exportExceptionDataEntity);
- throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
- }
- }else{
- throw new RRException("导入数据为空,或者检查商品编码数据是否为空");
- }
- return 1;
- }
- @Override
- public GoodsDetailsDto queryGoodsDetailsByProdBarcode(String prodBarcode) {
- return goodsDao.queryGoodsDetailsByProdBarcode(prodBarcode);
- }
- /* @Override
- @Transactional
- public int uploadExcel(MultipartFile file) {
- SysUserEntity user = ShiroUtils.getUserEntity();
- List<String[]> list = ExcelImport.getExcelData(file);
- // 取门店名称
- StoreEntity storeEntity = storeDao.queryObjectByName(list.get(0)[3]);
- if (null == storeEntity) {
- return 0;
- }
- //去除表头两行、底部合计
- if (list != null && list.size() > 3) {
- ProductStoreRelaEntity storeRelaEntity;
- ProductEntity productEntity;
- for (int i = 2; i < list.size() - 1; i++) {
- String[] item = list.get(i);
- String goodsSn = item[0];
- productEntity = productDao.queryObjectBySn(goodsSn);
- if (StringUtils.isNullOrEmpty(goodsSn)) {
- continue;
- }
- if (null == productEntity || null == productEntity.getId()) {
- continue;
- }
- storeRelaEntity = productStoreRelaDao.queryByStoreIdProductId(storeEntity.getId(), productEntity.getId());
- if (null != storeRelaEntity && null != storeRelaEntity.getId()) {
- storeRelaEntity.setRetailPrice(new BigDecimal(item[6]));
- storeRelaEntity.setStockNum(Integer.valueOf(item[3].replace(".00", "")));
- storeRelaEntity.setStockPrice(new BigDecimal(item[4]));
- productStoreRelaDao.update(storeRelaEntity);
- } else {
- storeRelaEntity = new ProductStoreRelaEntity();
- storeRelaEntity.setGoodsId(productEntity.getGoodsId());
- storeRelaEntity.setProductId(productEntity.getId());
- storeRelaEntity.setRetailPrice(new BigDecimal(item[6]));
- storeRelaEntity.setMarketPrice(new BigDecimal(item[6]));
- storeRelaEntity.setStockNum(Integer.valueOf(item[3]));
- storeRelaEntity.setStockPrice(new BigDecimal(item[4]));
- storeRelaEntity.setStoreId(storeEntity.getId());
- productStoreRelaDao.save(storeRelaEntity);
- }
- }
- }
- return 1;
- }*/
- public GoodsEntity queryObjectBySn(String goodsSn) {
- return goodsDao.queryObjectBySn(goodsSn);
- }
- }
|