GoodsServiceImpl.java 109 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134
  1. package com.kmall.admin.service.impl;
  2. import cn.hutool.http.HttpUtil;
  3. import com.alibaba.fastjson.JSON;
  4. import com.google.common.collect.ImmutableBiMap;
  5. import com.google.common.collect.Lists;
  6. import com.google.common.collect.Maps;
  7. import com.kmall.admin.dao.*;
  8. import com.kmall.admin.dto.GoodsDetailsDto;
  9. import com.kmall.admin.dto.GoodsDto;
  10. import com.kmall.admin.dto.GoodsPanoramaDto;
  11. import com.kmall.admin.entity.*;
  12. import com.kmall.admin.entity.kmall2eccs.KtoEccsEntity;
  13. import com.kmall.admin.entity.mk.MkActivitiesEntity;
  14. import com.kmall.admin.entity.shop.ShopErrorPriceRecordEntity;
  15. import com.kmall.admin.haikong.client.HaiKongWarehouseTemplate;
  16. import com.kmall.admin.haikong.config.HaiKongProperties;
  17. import com.kmall.admin.haikong.constant.Constants;
  18. import com.kmall.admin.haikong.dto.Criteria;
  19. import com.kmall.admin.haikong.dto.WareQueryStockParamDTO;
  20. import com.kmall.admin.haikong.dto.WareQueryStockResponseDTO;
  21. import com.kmall.admin.haikong.vo.QueryGoodsVO;
  22. import com.kmall.admin.service.*;
  23. import com.kmall.admin.service.kmall2eccs.KtoEccsService;
  24. import com.kmall.admin.service.mk.MkActivitiesService;
  25. import com.kmall.admin.service.mk.MkActivityFormService;
  26. import com.kmall.admin.service.GoodsService;
  27. import com.kmall.admin.service.shop.ShopErrorPriceRecordService;
  28. import com.kmall.admin.utils.CalculateTax;
  29. import com.kmall.admin.utils.GoodsUtils;
  30. import com.kmall.admin.utils.ShiroUtils;
  31. import com.kmall.admin.utils.jackson.JacksonUtil;
  32. import com.kmall.api.entity.exportpdf.PDFGoodsDto;
  33. import com.kmall.common.constant.Dict;
  34. import com.kmall.admin.fromcomm.entity.SysUserEntity;
  35. import com.kmall.common.utils.*;
  36. import com.kmall.manager.manager.express.sf.ServiceException;
  37. import com.kmall.manager.manager.redis.JedisCacheManager;
  38. import com.kmall.manager.manager.redis.JedisUtil;
  39. import org.slf4j.Logger;
  40. import org.slf4j.LoggerFactory;
  41. import org.springframework.beans.factory.annotation.Autowired;
  42. import org.springframework.core.env.Environment;
  43. import org.springframework.stereotype.Service;
  44. import org.springframework.transaction.annotation.Transactional;
  45. import org.springframework.util.CollectionUtils;
  46. import java.math.BigDecimal;
  47. import java.math.RoundingMode;
  48. import java.text.SimpleDateFormat;
  49. import java.util.*;
  50. import java.util.stream.Collectors;
  51. /**
  52. * Service实现类
  53. *
  54. * @author Scott
  55. * @email
  56. * @date 2017-08-21 21:19:49
  57. */
  58. @Service("goodsService")
  59. public class GoodsServiceImpl implements GoodsService {
  60. private static final Logger log = LoggerFactory.getLogger(GoodsServiceImpl.class);
  61. @Autowired
  62. private MerchDao merchDao;
  63. @Autowired
  64. private GoodsDao goodsDao;
  65. @Autowired
  66. private ProductDao productDao;
  67. @Autowired
  68. private GoodsGalleryDao goodsGalleryDao;
  69. @Autowired
  70. private GoodsSpecificationDao goodsSpecificationDao;
  71. @Autowired
  72. private ProductStoreRelaDao productStoreRelaDao;
  73. @Autowired
  74. private StoreDao storeDao;
  75. @Autowired
  76. private GoodsGroupDao goodsGroupDao;
  77. @Autowired
  78. private CategoryDao categoryDao;
  79. @Autowired
  80. private SupplierDao supplierDao;
  81. @Autowired
  82. private SysCusNationCodeDao sysCusNationCodeDao;
  83. @Autowired
  84. private SysCusUnitCodeDao sysCusUnitCodeDao;
  85. @Autowired
  86. private ExportExceptionDataDao exportExceptionDataDao;
  87. @Autowired
  88. private CartDao cartDao;
  89. @Autowired
  90. private ThirdMerchantBizDao thirdMerchantBizDao;
  91. @Autowired
  92. private MngChangeDao mngChangeDao;
  93. @Autowired
  94. private MerchUserDao merchUserDao;
  95. @Autowired
  96. private StoreMngChangeDao storeMngChangeDao;
  97. @Autowired
  98. private GoodsUtils goodsUtils;
  99. @Autowired
  100. private TaxErrorRecordDao taxErrorRecordDao;
  101. @Autowired
  102. private MkActivityFormService mkActivityFormService; // 活动表
  103. @Autowired
  104. private MkActivitiesService mkActivitiesService; // 营销方式表
  105. @Autowired
  106. private MkDailyActivitiesService dailyActivitiesService; // 日常活动
  107. @Autowired
  108. private MkActivitiesCouponService couponService; // 优惠券
  109. @Autowired
  110. private MkActivitiesCombinationPriceService combinationPriceService; // 组合价
  111. @Autowired
  112. private MkActivitiesDiscountService discountService; // 折扣
  113. @Autowired
  114. private MkActivitiesFullGiftService fullGiftService; // 满赠
  115. @Autowired
  116. private MkActivitiesFullReductionService fullReductionService; // 满减
  117. @Autowired
  118. private MkActivitiesGetOneFreeGoodsService getOneFreeGoodsService; // 买一送一
  119. @Autowired
  120. private MkActivitiesPromotionService promotionService; // 临时促销
  121. @Autowired
  122. private MkActivitiesHalfPriceService halfPriceService; // 第二份半价
  123. @Autowired
  124. private BrandService brandService;
  125. @Autowired
  126. private ShopErrorPriceRecordService shopErrorPriceRecordService;
  127. @Autowired
  128. private KtoEccsService ktoEccsService;
  129. @Autowired
  130. private HaiKongWarehouseTemplate haiKongWarehouseTemplate;
  131. @Autowired
  132. private HaiKongProperties haiKongProperties;
  133. @Autowired
  134. private Environment environment;
  135. @Override
  136. public GoodsEntity queryObject(Integer id) {
  137. Map<String, Object> map = new HashMap<String, Object>();
  138. map.put("goodsId", id);
  139. // List<GoodsAttributeEntity> attributeEntities = goodsAttributeDao.queryList(map);
  140. List<ProductEntity> productEntityList = productDao.queryList(map);
  141. GoodsEntity entity = goodsDao.queryObject(id);
  142. // entity.setAttributeEntityList(attributeEntities);
  143. entity.setProductEntityList(productEntityList);
  144. return entity;
  145. }
  146. @Override
  147. public GoodsEntity queryObjectByProdBarcodeAndBizType(String prodBarcode, Integer storeId){
  148. Map<String, Object> map = new HashMap<String, Object>();
  149. map.put("prodBarcode", prodBarcode);
  150. GoodsEntity entity = goodsDao.queryObjectByProdBarcodeAndBizType(prodBarcode, storeId);
  151. return entity;
  152. }
  153. @Override
  154. public List<GoodsEntity> queryList(Map<String, Object> map) {
  155. return goodsDao.queryList(map);
  156. }
  157. @Override
  158. public List<GoodsEntity> querySame(Map<String, Object> map) {
  159. return goodsDao.querySame(map);
  160. }
  161. @Override
  162. public int queryTotal(Map<String, Object> map) {
  163. return goodsDao.queryTotal(map);
  164. }
  165. @Override
  166. @Transactional
  167. public int save(GoodsEntity goods) {
  168. Map<String, Object> valideDate = MapBeanUtil.fromObject(goods);
  169. ImmutableBiMap.Builder builder = new ImmutableBiMap.Builder();
  170. builder.put("merchSn", "商户编号");
  171. builder.put("thirdPartyMerchCode", "第三方商户编号");
  172. // builder.put("attributeCategory", "商品分类");
  173. // builder.put("categoryId", "商品二级分类");
  174. builder.put("goodsSn", "商品编码");
  175. builder.put("name", "商品名称");
  176. builder.put("goodsUnit", "商品单位");
  177. builder.put("prodBarcode", "产品条码");
  178. builder.put("goodsBizType", "货品业务类型");
  179. // builder.put("brandId", "品牌");
  180. builder.put("supplierId", "供应商");
  181. // builder.put("freightId", "运费模版");
  182. builder.put("goodsNumber", "商品总库存");
  183. builder.put("primaryPicUrl", "商品主图");
  184. builder.put("listPicUrl", "商品列表图");
  185. builder.put("goodsDesc", "商品描述");
  186. builder.put("isOnSale", "上架");
  187. builder.put("isHot", "热销");
  188. //builder.put("englishName", "商品英文名称");
  189. // builder.put("plu", "PLU");
  190. R r = ValidatorUtil.isEmpty(builder.build(), valideDate);
  191. if (Integer.valueOf(r.get("code").toString()) != 0) {
  192. throw new RRException(r.get("msg").toString());
  193. } else {
  194. if (!Dict.orderBizType.item_11.getItem().equals(goods.getGoodsBizType())) {
  195. // 海关信息,普通货物可不添加
  196. builder.put("sku", "SKU");
  197. builder.put("goodsRate", "商品税率");
  198. // builder.put("retailPrice", "零售价");
  199. // builder.put("brand", "产品品牌");
  200. builder.put("unitCode", "计量单位代码");
  201. //builder.put("cusGoodsCode", "海关商品编码");
  202. // builder.put("ciqProdModel", "国检规格型号");
  203. builder.put("oriCntCode", "原产国代码");
  204. // builder.put("cusDeclEle", "海关申报要素");
  205. //builder.put("cusRecCode", "海关备案编号");
  206. }
  207. r = ValidatorUtil.isEmpty(builder.build(), valideDate);
  208. if (Integer.valueOf(r.get("code").toString()) != 0) {
  209. throw new RRException(r.get("msg").toString());
  210. }
  211. }
  212. /*ThirdMerchantBizEntity thirdMerchantBizEntity = thirdMerchantBizDao.getThirdMerchangByCode(goods.getThirdPartyMerchCode());
  213. if(thirdMerchantBizEntity == null){
  214. throw new RRException("第三方商户信息不存在");
  215. }
  216. if(Dict.orderBizType.item_00.getItem().equalsIgnoreCase(goods.getGoodsBizType())){
  217. if(Dict.isStockShare.item_1.getItem().equalsIgnoreCase(thirdMerchantBizEntity.getIsStockShare())){
  218. builder.put("goodsNumber", "商品库存");
  219. }
  220. }*/
  221. r = ValidatorUtil.isEmpty(builder.build(), valideDate);
  222. if (Integer.valueOf(r.get("code").toString()) != 0) {
  223. throw new RRException(r.get("msg").toString());
  224. }
  225. // 商品轮播图
  226. // List<GoodsGalleryEntity> galleryEntityList = goods.getGoodsImgList();
  227. // if (galleryEntityList == null || galleryEntityList.size() <= 0) {
  228. // throw new RRException("至少添加一张商品轮播图!");
  229. // }
  230. // List<GoodsEntity> prodbarGoodsList = goodsDao.queryObjectByProdBarcode(goods.getProdBarcode(),goods.getMerchSn(),null);
  231. // if(prodbarGoodsList != null && prodbarGoodsList.size() > 0){
  232. // throw new RRException("不能有重复的产品条码信息!");
  233. // }
  234. SysUserEntity user = ShiroUtils.getUserEntity();
  235. Map<String, Object> map = new HashMap<>();
  236. map.put("isSame", "true");
  237. map.put("sku", goods.getSku());
  238. map.put("goodsSn", goods.getGoodsSn());
  239. map.put("goodsBizType", goods.getGoodsBizType());
  240. List<GoodsEntity> list = querySame(map);
  241. if (list != null && list.size() != 0) {
  242. throw new RRException("已存在该商品编码,或该货品业务类型下已存在此SKU!");
  243. }
  244. // 添加商品
  245. if (Dict.orderBizType.item_02.getItem().equals(goods.getGoodsBizType())
  246. || Dict.orderBizType.item_10.getItem().equals(goods.getGoodsBizType())) {
  247. goods.setIsHot(0);
  248. }
  249. // goods.setAttributeCategory(categoryDao.queryObject(goods.getCategoryId()).getParentId());
  250. goods.setAddTime(new Date());
  251. goods.setIsDelete(Integer.parseInt(Dict.isDelete.item_0.getItem()));
  252. goods.setIsNew(0);
  253. goods.setCreateUserId(user.getUserId());
  254. goods.setUpdateUserId(user.getUserId());
  255. goods.setUpdateTime(new Date());
  256. goods.setModTime(new Date());
  257. goods.setCreateTime(new Date());
  258. // 新增商品
  259. goodsDao.save(goods);
  260. Long id = goods.getId();
  261. // 添加商品轮播图
  262. // for (int i=0;i<galleryEntityList.size();i++) {
  263. // GoodsGalleryEntity galleryEntity =galleryEntityList.get(i);
  264. // galleryEntity.setMerchSn(goods.getMerchSn());
  265. // galleryEntity.setGoodsId(id);
  266. // galleryEntity.setSortOrder((i+1));
  267. // galleryEntity.setFileType("0");//图片
  268. // goodsGalleryDao.save(galleryEntity);
  269. // }
  270. if(org.apache.commons.lang.StringUtils.isNotEmpty(goods.getVideoUrl())){
  271. GoodsGalleryEntity galleryEntity = new GoodsGalleryEntity();
  272. galleryEntity.setMerchSn(goods.getMerchSn());
  273. galleryEntity.setGoodsId(id);
  274. galleryEntity.setSortOrder(0);
  275. galleryEntity.setFileType("1");//视频
  276. goodsGalleryDao.save(galleryEntity);
  277. }
  278. /*
  279. // 添加商品参数
  280. List<GoodsAttributeEntity> attributeEntityList = goods.getAttributeEntityList();
  281. if (attributeEntityList != null && attributeEntityList.size() > 0) {
  282. for (GoodsAttributeEntity item : attributeEntityList) {
  283. if (item.getIsDelete() == 0) {
  284. if (item.getId() == null && item.getAttributeId() != null && StringUtils.isNotEmpty(item.getValue())) {
  285. item.setGoodsId(id);
  286. item.setMerchSn(goods.getMerchSn());
  287. goodsAttributeDao.save(item);
  288. } else if (item.getId() == null && item.getAttributeId() != null && StringUtils.isNullOrEmpty(item.getValue())) {
  289. throw new RRException("商品属性【" + attributeDao.queryObject(item.getAttributeId()).getName() + "】值不能为空!");
  290. } else if (item.getId() == null && item.getAttributeId() == null) {
  291. continue;
  292. }
  293. }
  294. }
  295. }*/
  296. if (goods.getGoodsNumber() != null){
  297. MngChangeEntity mngChangeEntity = new MngChangeEntity();
  298. mngChangeEntity.setGoodsId(Integer.parseInt(String.valueOf(id)));
  299. mngChangeEntity.setThirdPartyMerchCode(goods.getThirdPartyMerchCode());
  300. mngChangeEntity.setChangeReason("新增商户商品总库存");
  301. mngChangeEntity.setChangeType(Dict.changeType.item_0.getItem());
  302. mngChangeEntity.setChangeNum(goods.getGoodsNumber());//变化数
  303. mngChangeEntity.setOriginalNum(0);//原库存数
  304. mngChangeEntity.setValidNum(goods.getGoodsNumber());//可用数
  305. mngChangeEntity.setCreateTime(new Date());
  306. mngChangeEntity.setModTime(new Date());
  307. mngChangeEntity.setCreaterSn(user.getUsername());
  308. mngChangeEntity.setModerSn(user.getUsername());
  309. mngChangeEntity.setIsValid(0);
  310. mngChangeEntity.setMerchSn(goods.getMerchSn());
  311. mngChangeDao.save(mngChangeEntity);
  312. }
  313. // 添加产品
  314. ProductEntity product = new ProductEntity();
  315. product.setGoodsId(id);
  316. product.setGoodsSn(goods.getGoodsSn());
  317. // 保税商品,普通货物暂不添加商品规格
  318. if (!Dict.orderBizType.item_11.getItem().equals(goods.getGoodsBizType())) {
  319. // 添加商品规格
  320. GoodsSpecificationEntity goodsSpecification = new GoodsSpecificationEntity();
  321. goodsSpecification.setGoodsId(id);
  322. goodsSpecification.setValue(goods.getCiqProdModel());
  323. goodsSpecification.setSpecificationId(1);
  324. goodsSpecificationDao.save(goodsSpecification);
  325. product.setGoodsSpecificationIds(goodsSpecification.getId().toString());
  326. product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
  327. }
  328. return productDao.save(product);
  329. }
  330. @Override
  331. @Transactional
  332. public int update(GoodsEntity goods) {
  333. Map<String, Object> valideDate = MapBeanUtil.fromObject(goods);
  334. ImmutableBiMap.Builder builder = new ImmutableBiMap.Builder();
  335. builder.put("merchSn", "商户编号");
  336. builder.put("thirdPartyMerchCode", "第三方商户编号");
  337. // builder.put("attributeCategory", "商品分类");
  338. // builder.put("categoryId", "商品二级分类");
  339. builder.put("goodsSn", "商品编码");
  340. builder.put("name", "商品名称");
  341. builder.put("goodsUnit", "商品单位");
  342. builder.put("prodBarcode", "产品条码");
  343. builder.put("goodsBizType", "货品业务类型");
  344. // builder.put("brandId", "品牌");
  345. builder.put("supplierId", "供应商");
  346. builder.put("goodsNumber", "商品总库存");
  347. // builder.put("freightId", "运费模版");
  348. builder.put("primaryPicUrl", "商品主图");
  349. builder.put("listPicUrl", "商品列表图");
  350. // builder.put("goodsDesc", "商品描述");
  351. builder.put("isOnSale", "上架");
  352. builder.put("isHot", "热销");
  353. R r = ValidatorUtil.isEmpty(builder.build(), valideDate);
  354. if (Integer.valueOf(r.get("code").toString()) != 0) {
  355. throw new RRException(r.get("msg").toString());
  356. } else {
  357. if (!Dict.orderBizType.item_11.getItem().equals(goods.getGoodsBizType())) {
  358. // 海关信息,普通货物可不添加
  359. builder.put("sku", "SKU");
  360. builder.put("goodsRate", "商品税率");
  361. // builder.put("retailPrice", "零售价");
  362. // builder.put("brand", "产品品牌");
  363. builder.put("unitCode", "计量单位代码");
  364. //builder.put("cusGoodsCode", "海关商品编码");
  365. //builder.put("ciqProdModel", "国检规格型号");
  366. builder.put("oriCntCode", "原产国代码");
  367. //builder.put("cusRecCode", "海关备案编号");
  368. //builder.put("cusDeclEle", "海关申报要素");
  369. }
  370. r = ValidatorUtil.isEmpty(builder.build(), valideDate);
  371. if (Integer.valueOf(r.get("code").toString()) != 0) {
  372. throw new RRException(r.get("msg").toString());
  373. }
  374. }
  375. /*ThirdMerchantBizEntity thirdMerchantBizEntity = thirdMerchantBizDao.getThirdMerchangByCode(goods.getThirdPartyMerchCode());
  376. if(thirdMerchantBizEntity == null){
  377. throw new RRException("所属第三方商户不存在");
  378. }*/
  379. GoodsEntity goodsEntity = goodsDao.queryObject(goods.getId());
  380. if(goodsEntity != null){
  381. /*if(Dict.orderBizType.item_00.getItem().equalsIgnoreCase(goods.getGoodsBizType())){
  382. if(Dict.isStockShare.item_1.getItem().equalsIgnoreCase(thirdMerchantBizEntity.getIsStockShare())){
  383. builder.put("goodsNumber", "商品库存");
  384. }
  385. }
  386. r = ValidatorUtil.isEmpty(builder.build(), valideDate);
  387. if (Integer.valueOf(r.get("code").toString()) != 0) {
  388. throw new RRException(r.get("msg").toString());
  389. }*/
  390. }else{
  391. throw new RRException("商品不存在");
  392. }
  393. // 商品轮播图
  394. List<GoodsGalleryEntity> galleryEntityList = goods.getGoodsImgList();
  395. if (galleryEntityList == null || galleryEntityList.size() <= 0) {
  396. // throw new RRException("至少保留一张商品轮播图!");
  397. }
  398. // List<GoodsEntity> prodbarGoodsList = goodsDao.queryObjectByProdBarcode(goods.getProdBarcode(),goods.getMerchSn(),goods.getId());
  399. // if(prodbarGoodsList != null && prodbarGoodsList.size() > 0){
  400. // throw new RRException("不能有重复的产品条码信息!");
  401. // }
  402. SysUserEntity user = ShiroUtils.getUserEntity();
  403. Map<String, Object> map = new HashMap<>();
  404. map.put("isSame", "true");
  405. map.put("sku", goods.getSku());
  406. map.put("goodsSn", goods.getGoodsSn());
  407. map.put("goodsBizType", goods.getGoodsBizType());
  408. map.put("id", goods.getId());
  409. List<GoodsEntity> list = querySame(map);
  410. if (list != null && list.size() != 0) {
  411. throw new RRException("已存在该商品编码,或该货品业务类型下已存在此SKU!");
  412. }
  413. // 修改商品
  414. if (Dict.orderBizType.item_02.getItem().equals(goods.getGoodsBizType())
  415. || Dict.orderBizType.item_10.getItem().equals(goods.getGoodsBizType())) {
  416. goods.setIsHot(0);
  417. }
  418. // goods.setAttributeCategory(categoryDao.queryObject(goods.getCategoryId()).getParentId());
  419. goods.setIsDelete(Integer.parseInt(Dict.isDelete.item_0.getItem()));
  420. goods.setIsNew(0);
  421. goods.setUpdateUserId(user.getUserId());
  422. goods.setUpdateTime(new Date());
  423. goods.setModTime(new Date());
  424. if(goods.getGoodsNumber()==null){
  425. goods.setGoodsNumber(0);
  426. }else{
  427. if(goodsEntity.getGoodsNumber() == null){
  428. goodsEntity.setGoodsNumber(0);
  429. }
  430. MngChangeEntity mngChangeEntity = new MngChangeEntity();
  431. mngChangeEntity.setGoodsId(Integer.parseInt(String.valueOf(goods.getId())));
  432. mngChangeEntity.setThirdPartyMerchCode(goods.getThirdPartyMerchCode());
  433. mngChangeEntity.setChangeReason("更新商户商品总库存");
  434. mngChangeEntity.setCreateTime(new Date());
  435. mngChangeEntity.setModTime(new Date());
  436. mngChangeEntity.setCreaterSn(user.getUsername());
  437. mngChangeEntity.setModerSn(user.getUsername());
  438. mngChangeEntity.setIsValid(0);
  439. mngChangeEntity.setMerchSn(goods.getMerchSn());
  440. if(goodsEntity.getGoodsNumber() != goods.getGoodsNumber()) {
  441. if (goodsEntity.getGoodsNumber() > goods.getGoodsNumber()) {
  442. mngChangeEntity.setChangeNum(goodsEntity.getGoodsNumber() - goods.getGoodsNumber());//变化数
  443. mngChangeEntity.setChangeType(Dict.changeType.item_4.getItem());
  444. } else {
  445. mngChangeEntity.setChangeNum(goods.getGoodsNumber() - goodsEntity.getGoodsNumber());//变化数
  446. mngChangeEntity.setChangeType(Dict.changeType.item_3.getItem());
  447. }
  448. mngChangeEntity.setOriginalNum(goodsEntity.getGoodsNumber());//原库存数
  449. mngChangeEntity.setValidNum(goods.getGoodsNumber());//可用数
  450. mngChangeDao.save(mngChangeEntity);
  451. }
  452. }
  453. // 修改商品
  454. goodsDao.update(goods);
  455. // 保税商品修改各个门店商品价格
  456. List<ProductStoreRelaEntity> productStoreRelaEntityList = productStoreRelaDao.queryByGoodsId(goodsEntity.getId());
  457. Long[] storeIds = new Long[productStoreRelaEntityList.size()];
  458. Integer goodsNumber = goods.getGoodsNumber();//商品总库存
  459. Integer storeTotalGoodsNumber = 0;//商品分配库存
  460. if (productStoreRelaEntityList != null && productStoreRelaEntityList.size() > 0) {
  461. for (int i = 0; i < productStoreRelaEntityList.size(); i++) {
  462. //修改该商品的所属商户信息,如在该商户门店中有该上架的商品信息,则提示该商品不能修改
  463. ProductStoreRelaEntity relaEntity = productStoreRelaEntityList.get(i);
  464. if(org.apache.commons.lang3.StringUtils.isNotEmpty(relaEntity.getMerchSn()) && relaEntity.getMerchSn().equalsIgnoreCase(goods.getMerchSn())
  465. && goods.getIsOnSale() == Integer.parseInt(Dict.isOnSale.item_1.getItem())) {
  466. }else {
  467. if (goods.getIsOnSale() != Integer.parseInt(Dict.isOnSale.item_0.getItem())) {
  468. throw new RRException("商品编码为【" + goods.getGoodsSn() + "】的商品已上架在商户编号为【" + relaEntity.getMerchSn() + "】的门店中,可先将该商品下架后再进行修改!");
  469. }
  470. }
  471. storeTotalGoodsNumber = storeTotalGoodsNumber + relaEntity.getStockNum();
  472. storeIds[i] = relaEntity.getStoreId();
  473. }
  474. }
  475. if(goodsEntity.getIsStockShare().equalsIgnoreCase(Dict.isStockShare.item_0.getItem())) {
  476. if (goodsNumber < storeTotalGoodsNumber) {
  477. throw new RRException("该商品已在各门店分配库存" + storeTotalGoodsNumber + ",当前商品总库存不能小于分配库存总额!请先修改门店库存!");
  478. }
  479. }else{
  480. //共享库存商品库存变化,修改该商品的所有库存信息
  481. ProductStoreRelaEntity productStoreRelaEntity = new ProductStoreRelaEntity();
  482. productStoreRelaEntity.setStockNum(goodsNumber);
  483. productStoreRelaEntity.setGoodsId(goods.getId());
  484. productStoreRelaDao.updateStockNumByGoodsId(productStoreRelaEntity);
  485. for (int i = 0; i < productStoreRelaEntityList.size(); i++) {
  486. ProductStoreRelaEntity relaEntity = productStoreRelaEntityList.get(i);
  487. //新增库存操作记录
  488. StoreMngChangeEntity storeMngChangeEntity = new StoreMngChangeEntity();
  489. storeMngChangeEntity.setChangeReason("共享库存变更,更新门店商品库存");
  490. storeMngChangeEntity.setGoodsId(Integer.parseInt(String.valueOf(relaEntity.getGoodsId())));
  491. storeMngChangeEntity.setStoreId(Integer.parseInt(String.valueOf(relaEntity.getStoreId())));
  492. storeMngChangeEntity.setMerchSn(goods.getMerchSn());
  493. storeMngChangeEntity.setCreateTime(new Date());
  494. storeMngChangeEntity.setModTime(new Date());
  495. storeMngChangeEntity.setCreaterSn(user.getUsername());
  496. storeMngChangeEntity.setModerSn(user.getUsername());
  497. storeMngChangeEntity.setIsValid(0);
  498. Integer orginalNum = relaEntity.getStockNum()==null?0:relaEntity.getStockNum();//原有库存
  499. if(goodsNumber != orginalNum) {
  500. if (orginalNum > goodsNumber) {
  501. storeMngChangeEntity.setChangeType(Dict.changeType.item_4.getItem());
  502. storeMngChangeEntity.setStoreChangeNum(orginalNum - goodsNumber);//变化数
  503. } else {
  504. storeMngChangeEntity.setChangeType(Dict.changeType.item_3.getItem());
  505. storeMngChangeEntity.setStoreChangeNum(goodsNumber - orginalNum);//变化数
  506. }
  507. storeMngChangeEntity.setStoreOriginalNum(orginalNum);//原库存数
  508. storeMngChangeEntity.setStoreValidNum(goodsNumber);//可用数
  509. storeMngChangeDao.save(storeMngChangeEntity);
  510. }
  511. }
  512. }
  513. Map cartMap = Maps.newHashMap();
  514. cartMap.put("goodsId",goods.getId());
  515. List<CartEntity> cartList = cartDao.queryList(cartMap);
  516. if (cartList != null && cartList.size() > 0) {
  517. for (CartEntity cartEntity : cartList) {
  518. // cartEntity.setRetailPrice(goods.getRetailPrice());
  519. // cartEntity.setMarketPrice(goods.getMarketPrice());
  520. cartEntity.setSku(goods.getSku());
  521. cartEntity.setGoodsName(goods.getName());
  522. cartEntity.setGoodsSn(goods.getGoodsSn());
  523. cartDao.update(cartEntity);
  524. }
  525. }
  526. // 修改商品轮播图
  527. goodsGalleryDao.deleteByGoodsId(goods.getId());
  528. for (int i=0;i<galleryEntityList.size();i++) {
  529. GoodsGalleryEntity galleryEntity =galleryEntityList.get(i);
  530. galleryEntity.setMerchSn(goods.getMerchSn());
  531. galleryEntity.setGoodsId(goods.getId());
  532. galleryEntity.setSortOrder((i+1));
  533. galleryEntity.setFileType("0");//图片
  534. goodsGalleryDao.save(galleryEntity);
  535. }
  536. if(org.apache.commons.lang.StringUtils.isNotEmpty(goods.getVideoUrl())){
  537. GoodsGalleryEntity galleryEntity = new GoodsGalleryEntity();
  538. galleryEntity.setMerchSn(goods.getMerchSn());
  539. galleryEntity.setGoodsId(goods.getId());
  540. galleryEntity.setSortOrder(0);
  541. galleryEntity.setFileType("1");//视频
  542. galleryEntity.setImgUrl(goods.getVideoUrl());
  543. goodsGalleryDao.save(galleryEntity);
  544. }
  545. /*// 修改商品参数
  546. List<GoodsAttributeEntity> attributeEntityList = goods.getAttributeEntityList();
  547. if (attributeEntityList != null && attributeEntityList.size() > 0) {
  548. for (GoodsAttributeEntity item : attributeEntityList) {
  549. if (item.getIsDelete() == 0) {
  550. if (item.getId() != null) {
  551. item.setMerchSn(goods.getMerchSn());
  552. goodsAttributeDao.update(item);
  553. } else if (item.getId() == null && item.getAttributeId() != null && StringUtils.isNotEmpty(item.getValue())) {
  554. item.setGoodsId(goods.getId());
  555. item.setMerchSn(goods.getMerchSn());
  556. goodsAttributeDao.save(item);
  557. } else if (item.getId() == null && item.getAttributeId() != null && StringUtils.isNullOrEmpty(item.getValue())) {
  558. throw new RRException("商品属性【" + attributeDao.queryObject(item.getAttributeId()).getName() + "】值不能为空!");
  559. } else if (item.getId() == null && item.getAttributeId() == null) {
  560. continue;
  561. }
  562. } else if (item.getIsDelete() == 1) {
  563. goodsAttributeDao.delete(item.getId());
  564. }
  565. }
  566. }*/
  567. // 修改产品
  568. ProductEntity product = productDao.queryObjectByGoodsIdAndStoreId(String.valueOf(goods.getId()),"");
  569. GoodsSpecificationEntity goodsSpecification = null;
  570. // 保税商品,普通货物暂不添加商品规格
  571. if (!Dict.orderBizType.item_11.getItem().equals(goods.getGoodsBizType())) {
  572. // 添加商品规格
  573. goodsSpecification = goodsSpecificationDao.queryByGoodsId(goods.getId());
  574. if(goodsSpecification != null) {
  575. goodsSpecification.setValue(goods.getCiqProdModel());
  576. goodsSpecificationDao.update(goodsSpecification);
  577. }else{
  578. goodsSpecification = new GoodsSpecificationEntity();
  579. goodsSpecification.setGoodsId(goods.getId());
  580. goodsSpecification.setValue(goods.getCiqProdModel());
  581. goodsSpecification.setSpecificationId(1);
  582. goodsSpecificationDao.save(goodsSpecification);
  583. }
  584. //更新门店商品是否有修改字段
  585. if(storeIds.length > 0){
  586. for(int i=0;i<storeIds.length;i++){
  587. updateLoadGoodsByStoreId(storeIds[i], user);
  588. }
  589. }
  590. if(product == null){
  591. product = new ProductEntity();
  592. product.setGoodsSn(goods.getGoodsSn());
  593. product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
  594. product.setGoodsSpecificationIds(goodsSpecification.getId()+"");
  595. product.setGoodsId(goods.getId());
  596. product.setGoodsNumber(goods.getGoodsNumber());
  597. product.setGoodsDefault(0);
  598. return productDao.save(product);
  599. }else{
  600. product.setGoodsSpecificationIds(goodsSpecification.getId().toString());
  601. product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
  602. return productDao.update(product);
  603. }
  604. }
  605. return 1;
  606. }
  607. @Transactional
  608. @Override
  609. public void updateForImgUrl(GoodsEntity goodsEntity){
  610. // 修改商品
  611. goodsDao.update(goodsEntity);
  612. }
  613. @Override
  614. public List<GoodsEntity> queryByName(String storeId, String goodsName) {
  615. return goodsDao.queryByName(storeId, goodsName);
  616. }
  617. /**
  618. * 更新门店商品是否有修改字段
  619. * @param storeId
  620. * @param user
  621. */
  622. private void updateLoadGoodsByStoreId(Long storeId, SysUserEntity user){
  623. List<MerchUserEntity> list = merchUserDao.queryMerchUserByLoadGoods(storeId);
  624. for(MerchUserEntity entity : list) {
  625. entity.setIsLoadGoods("1");
  626. entity.setModerSn(user.getUsername());
  627. entity.setStoreId(Integer.valueOf(String.valueOf(storeId)));
  628. merchUserDao.updateStoreLoadGoodsById(entity);
  629. }
  630. }
  631. @Override
  632. public int delete(Integer id) {
  633. SysUserEntity user = ShiroUtils.getUserEntity();
  634. GoodsEntity goodsEntity = goodsDao.queryObject(id);
  635. goodsEntity.setIsDelete(Integer.parseInt(Dict.isDelete.item_1.getItem()));
  636. goodsEntity.setIsOnSale(Integer.parseInt(Dict.isOnSale.item_0.getItem()));
  637. goodsEntity.setUpdateUserId(user.getUserId());
  638. goodsEntity.setUpdateTime(new Date());
  639. Map params = Maps.newHashMap();
  640. params.put("goodsId", id);
  641. List<GoodsGroupEntity> groupVos = goodsGroupDao.queryList(params);
  642. if (null != groupVos && groupVos.size() > 0) {
  643. for (GoodsGroupEntity groupVo : groupVos) {
  644. groupVo.setOpenStatus(3);
  645. goodsGroupDao.update(groupVo);
  646. }
  647. }
  648. return goodsDao.update(goodsEntity);
  649. }
  650. @Override
  651. @Transactional
  652. public int deleteBatch(Integer[] ids) {
  653. int result = 0;
  654. for (Integer id : ids) {
  655. result += delete(id);
  656. }
  657. return result;
  658. }
  659. @Override
  660. @Transactional
  661. public int back(Integer[] ids) {
  662. SysUserEntity user = ShiroUtils.getUserEntity();
  663. int result = 0;
  664. for (Integer id : ids) {
  665. GoodsEntity goodsEntity = queryObject(id);
  666. goodsEntity.setIsDelete(Integer.parseInt(Dict.isDelete.item_0.getItem()));
  667. goodsEntity.setIsOnSale(Integer.parseInt(Dict.isOnSale.item_1.getItem()));
  668. goodsEntity.setUpdateUserId(user.getUserId());
  669. goodsEntity.setUpdateTime(new Date());
  670. result += goodsDao.update(goodsEntity);
  671. }
  672. return result;
  673. }
  674. @Override
  675. public int enSale(Integer id) {
  676. SysUserEntity user = ShiroUtils.getUserEntity();
  677. GoodsEntity goodsEntity = queryObject(id);
  678. if (1 == goodsEntity.getIsOnSale()) {
  679. throw new RRException("此商品已处于上架状态!");
  680. }
  681. goodsEntity.setIsOnSale(Integer.parseInt(Dict.isOnSale.item_1.getItem()));
  682. goodsEntity.setIsDelete(Integer.parseInt(Dict.isDelete.item_0.getItem()));
  683. goodsEntity.setUpdateUserId(user.getUserId());
  684. goodsEntity.setUpdateTime(new Date());
  685. return goodsDao.update(goodsEntity);
  686. }
  687. @Override
  688. public int unSale(Integer id) {
  689. SysUserEntity user = ShiroUtils.getUserEntity();
  690. GoodsEntity goodsEntity = queryObject(id);
  691. if (0 == goodsEntity.getIsOnSale()) {
  692. throw new RRException("此商品已处于下架状态!");
  693. }
  694. goodsEntity.setIsOnSale(Integer.parseInt(Dict.isOnSale.item_0.getItem()));
  695. goodsEntity.setUpdateUserId(user.getUserId());
  696. goodsEntity.setUpdateTime(new Date());
  697. return goodsDao.update(goodsEntity);
  698. }
  699. @Override
  700. public int enSaleBatch(Integer[] ids) {
  701. int result = 0;
  702. SysUserEntity user = ShiroUtils.getUserEntity();
  703. for (Integer id : ids) {
  704. GoodsEntity goodsEntity = queryObject(id);
  705. goodsEntity.setIsOnSale(Integer.parseInt(Dict.isOnSale.item_1.getItem()));
  706. goodsEntity.setIsDelete(Integer.parseInt(Dict.isDelete.item_0.getItem()));
  707. goodsEntity.setUpdateUserId(user.getUserId());
  708. goodsEntity.setUpdateTime(new Date());
  709. result += goodsDao.update(goodsEntity);
  710. }
  711. return result;
  712. }
  713. @Override
  714. public int unSaleBatch(Integer[] ids) {
  715. int result = 0;
  716. SysUserEntity user = ShiroUtils.getUserEntity();
  717. for (Integer id : ids) {
  718. GoodsEntity goodsEntity = queryObject(id);
  719. goodsEntity.setIsOnSale(Integer.parseInt(Dict.isOnSale.item_0.getItem()));
  720. goodsEntity.setUpdateUserId(user.getUserId());
  721. goodsEntity.setUpdateTime(new Date());
  722. result += goodsDao.update(goodsEntity);
  723. }
  724. return result;
  725. }
  726. @Override
  727. @Transactional
  728. public int uploadExcel(List<GoodsDto> goodsEntityList,int exportDataType) {
  729. SysUserEntity user = ShiroUtils.getUserEntity();
  730. String merchSn = user.getMerchSn();
  731. boolean isFail = false;
  732. List<String> failSameSkuList = new ArrayList<>(),
  733. failUnitGoodsSnList = new ArrayList<>(),
  734. failNationGoodsSnList = new ArrayList<>(),
  735. failTypeGoodsSnList = new ArrayList<>(),
  736. failMerchGoodsSnList = new ArrayList<>(),
  737. failMerchUserGoodsSnList = new ArrayList<>();
  738. List<String> failGoodsSnList = new ArrayList<>();
  739. List<String> failGoodsTypeList = new ArrayList<>();
  740. // 定义需要批量插入的list
  741. List<MngChangeEntity> insertMngChangeList = new LinkedList<>();
  742. List<GoodsEntity> insertGoodsList = new LinkedList<>();
  743. // 定义需要批量修改的list
  744. List<ProductEntity> updateProductList = new LinkedList<>();
  745. List<GoodsSpecificationEntity> updateSpecificationList = new LinkedList<>();
  746. if (goodsEntityList != null && goodsEntityList.size() > 0) {
  747. for (int i = 0; i < goodsEntityList.size(); i++) {
  748. GoodsDto goodsDto = goodsEntityList.get(i);
  749. GoodsEntity goodsEntity = new GoodsEntity();
  750. Map<String, Object> valideDate = MapBeanUtil.fromObject(goodsDto);
  751. ImmutableBiMap.Builder builder = new ImmutableBiMap.Builder();
  752. builder.put("goodsSn", "商品编码");
  753. builder.put("thirdPartyMerchCode", "第三方商户代码");
  754. builder.put("goodsBizType", "货品业务类型");
  755. builder.put("name", "商品名称");
  756. builder.put("prodBarcode", "产品条码");
  757. builder.put("sku", "sku");
  758. builder.put("isOnSaleStr", "上架");
  759. builder.put("goodsUnit", "商品单位");
  760. builder.put("isHotStr", "是否热销");
  761. builder.put("goodsRate", "商品税率");
  762. builder.put("brand", "产品品牌");
  763. builder.put("uniqueIdentifier", "品牌唯一简码");
  764. builder.put("unitName", "计量单位");
  765. builder.put("oriCntName", "原产国");
  766. builder.put("valueAddedTaxRate", "增值税率");
  767. builder.put("goodsNumber", "库存数");
  768. builder.put("firstLevel", "一级分类");
  769. builder.put("secondLevel", "二级分类");
  770. builder.put("warehouseSn", "仓库编码");
  771. builder.put("consignorSn", "货主编码");
  772. builder.put("warehousSysGoodId", "仓储系统商品ID");
  773. builder.put("inventoryType", "库存类型");
  774. builder.put("legalUnit1Qty", "第一法定单位数量");
  775. builder.put("legalUnit2Qty", "第二法定单位数量");
  776. R r = ValidatorUtil.isEmpty(builder.build(), valideDate);
  777. if (Integer.valueOf(r.get("code").toString()) != 0) {
  778. throw new RRException(r.get("msg").toString());
  779. }
  780. //业务类型校验
  781. if(!Dict.orderBizType.item_11.getItem().equalsIgnoreCase(goodsDto.getGoodsBizType())){
  782. if(!(Dict.orderBizType.item_02.getItem().equalsIgnoreCase(goodsDto.getGoodsBizType())
  783. || Dict.orderBizType.item_10.getItem().equalsIgnoreCase(goodsDto.getGoodsBizType())
  784. || Dict.orderBizType.item_00.getItem().equalsIgnoreCase(goodsDto.getGoodsBizType()))){
  785. isFail = true;
  786. failTypeGoodsSnList.add(goodsDto.getSku());
  787. }
  788. }
  789. ThirdMerchantBizEntity thirdMerchantBizEntity = thirdMerchantBizDao.getThirdMerchangByCode(goodsDto.getThirdPartyMerchCode());
  790. if(thirdMerchantBizEntity != null){
  791. goodsEntity.setMerchSn(thirdMerchantBizEntity.getMerchSn());
  792. goodsEntity.setThirdPartyMerchCode(thirdMerchantBizEntity.getThirdPartyMerchCode());
  793. if(!user.getRoleType().equalsIgnoreCase(Dict.roleType.item_1.getItem())) {
  794. if (!merchSn.equalsIgnoreCase(thirdMerchantBizEntity.getMerchSn())) {
  795. isFail = true;
  796. failMerchUserGoodsSnList.add(goodsDto.getGoodsSn().trim());
  797. }
  798. }
  799. }else{//商户不存在
  800. isFail = true;
  801. failMerchGoodsSnList.add(goodsDto.getGoodsSn().trim());
  802. }
  803. //校验商品信息是否已存在
  804. Map<String, Object> map = new HashMap<>();
  805. map.put("isSame", "true");
  806. map.put("sku", goodsDto.getSku().trim());
  807. map.put("goodsSn", goodsDto.getGoodsSn().trim());
  808. map.put("goodsBizType", goodsDto.getGoodsBizType());
  809. List<GoodsEntity> list = querySame(map);
  810. if (list != null && list.size() != 0) {
  811. if(goodsDto.getSku()!=null) {
  812. failSameSkuList.add(goodsDto.getSku());
  813. }
  814. failGoodsSnList.add(goodsDto.getGoodsSn());
  815. failGoodsTypeList.add(goodsDto.getGoodsBizType());
  816. }
  817. goodsEntity.setProdBarcode(goodsDto.getProdBarcode());
  818. if(thirdMerchantBizEntity != null) {
  819. SupplierEntity supplierEntity = supplierDao.queryObjectByName(goodsDto.getSupplierName(), thirdMerchantBizEntity.getMerchSn(),thirdMerchantBizEntity.getThirdPartyMerchCode());
  820. if (supplierEntity == null) {
  821. //导入没有查到供货商,执行新增
  822. MerchEntity merchEntity = merchDao.findByMerchSn(thirdMerchantBizEntity.getMerchSn());
  823. supplierEntity = new SupplierEntity();
  824. supplierEntity.setLevelMerchSn(merchEntity.getMerchSn());
  825. supplierEntity.setLevelMerchFlag(merchEntity.getMerchShortName());
  826. supplierEntity.setThirdPartyMerchCode(thirdMerchantBizEntity.getThirdPartyMerchCode());
  827. supplierEntity.setChildSupplierName(goodsDto.getSupplierName());
  828. supplierEntity.setChildSupplierFlag(goodsDto.getSupplierFlag());
  829. supplierEntity.setIsShow("0");
  830. // TODO 这里改成批量插入 SupplierEntity
  831. //新增商品供货信息
  832. supplierDao.save(supplierEntity);
  833. goodsEntity.setSupplierId(supplierEntity.getId());
  834. } else {
  835. goodsEntity.setSupplierId(supplierEntity.getId());
  836. }
  837. }
  838. GoodsEntity goodsNew = goodsDao.queryObjectBySnNew(goodsDto.getGoodsSn());
  839. if(goodsNew!=null){
  840. throw new RRException("该商品数据已存在,请勿重复导入:"+goodsNew.getGoodsSn());
  841. }
  842. // 获取品牌唯一简码
  843. checkBrand(goodsDto, goodsEntity);
  844. // 获取二级分类id
  845. checkCategory(goodsDto, goodsEntity);
  846. if (!Dict.orderBizType.item_11.getItem().equals(goodsDto.getGoodsBizType())) {
  847. SysCusUnitCodeEntity sysCusUnitCodeEntity = sysCusUnitCodeDao.queryObjectByName(goodsDto.getUnitName());
  848. if (sysCusUnitCodeEntity == null) {
  849. isFail = true;
  850. failUnitGoodsSnList.add(goodsDto.getGoodsSn().trim());
  851. } else {
  852. goodsEntity.setUnitCode(sysCusUnitCodeEntity.getCode());
  853. }
  854. //原产国
  855. SysCusNationCodeEntity sysCusNationCodeEntity = sysCusNationCodeDao.queryObjectByName(goodsDto.getOriCntName());
  856. if (sysCusNationCodeEntity == null) {
  857. isFail = true;
  858. failNationGoodsSnList.add(goodsDto.getGoodsSn().trim());
  859. } else {
  860. goodsEntity.setOriCntCode(sysCusNationCodeEntity.getCode());
  861. }
  862. if(goodsDto.getGoodsRate().indexOf("%") != -1){
  863. goodsDto.setGoodsRate(goodsDto.getGoodsRate().substring(0, goodsDto.getGoodsRate().indexOf("%")));
  864. goodsEntity.setGoodsRate(BigDecimal.valueOf(Double.valueOf(goodsDto.getGoodsRate())).divide(new BigDecimal(100), 4, BigDecimal.ROUND_HALF_UP));
  865. }else{
  866. goodsEntity.setGoodsRate(BigDecimal.valueOf(Double.valueOf(goodsDto.getGoodsRate())));
  867. }
  868. }
  869. goodsEntity.setIsOnSale(Integer.parseInt(goodsDto.getIsOnSaleStr()));
  870. goodsEntity.setIsHot(Integer.parseInt(goodsDto.getIsHotStr()));
  871. goodsEntity.setGoodsSn(goodsDto.getGoodsSn().trim());
  872. goodsEntity.setSku(goodsDto.getSku().trim());
  873. goodsEntity.setName(goodsDto.getName());
  874. goodsEntity.setGoodsUnit(goodsDto.getGoodsUnit());
  875. goodsEntity.setGoodsBizType(goodsDto.getGoodsBizType());
  876. goodsEntity.setBrand(goodsDto.getBrand());
  877. goodsEntity.setCusDeclEle(goodsDto.getCusDeclEle());
  878. goodsEntity.setCusGoodsCode(goodsDto.getCusGoodsCode());
  879. goodsEntity.setCusRecCode(goodsDto.getCusRecCode());
  880. goodsEntity.setCiqProdModel(goodsDto.getCiqProdModel());
  881. goodsEntity.setIsDelete(Integer.parseInt(Dict.isDelete.item_0.getItem()));
  882. goodsEntity.setIsNew(0);
  883. goodsEntity.setUpdateUserId(user.getUserId());
  884. goodsEntity.setAddTime(new Date());
  885. goodsEntity.setCreateTime(new Date());
  886. goodsEntity.setUpdateTime(new Date());
  887. goodsEntity.setModTime(new Date());
  888. goodsEntity.setGoodsNumber(Integer.parseInt(goodsDto.getGoodsNumber()));
  889. //新加字段1208
  890. goodsEntity.setWarehouseSn(goodsDto.getWarehouseSn());
  891. goodsEntity.setConsignorSn(goodsDto.getConsignorSn());
  892. goodsEntity.setWarehousSysGoodId(goodsDto.getWarehousSysGoodId());
  893. goodsEntity.setConsignorSn(goodsDto.getConsignorSn());
  894. goodsEntity.setInventoryType(goodsDto.getInventoryType());
  895. goodsEntity.setDefectiveProductsGrade(goodsDto.getDefectiveProductsGrade());
  896. //goodsEntity.setNetWeight(new BigDecimal(goodsDto.getNetWeight()));
  897. goodsEntity.setLegalUnit1Qty(new BigDecimal(goodsDto.getLegalUnit1Qty()));
  898. goodsEntity.setLegalUnit2Qty(new BigDecimal(goodsDto.getLegalUnit2Qty()));
  899. if(null!=goodsDto.getImpConsumTaxRate()){
  900. goodsEntity.setImpConsumTaxRate(new BigDecimal(goodsDto.getImpConsumTaxRate()));
  901. }
  902. goodsEntity.setValueAddedTaxRate(new BigDecimal(goodsDto.getValueAddedTaxRate()));
  903. if(!isFail){
  904. GoodsEntity goods = goodsDao.queryObjectBySnNew(goodsDto.getGoodsSn());
  905. MngChangeEntity mngChangeEntity = new MngChangeEntity();
  906. mngChangeEntity.setThirdPartyMerchCode(goodsEntity.getThirdPartyMerchCode());
  907. mngChangeEntity.setChangeReason("更新商户商品总库存");
  908. mngChangeEntity.setCreateTime(new Date());
  909. mngChangeEntity.setModTime(new Date());
  910. mngChangeEntity.setCreaterSn(user.getUsername());
  911. mngChangeEntity.setModerSn(user.getUsername());
  912. mngChangeEntity.setIsValid(0);
  913. mngChangeEntity.setMerchSn(goodsEntity.getMerchSn());
  914. //新增、修改商品表
  915. if(goods!=null) {// 修改商品
  916. mngChangeEntity.setOriginalNum(goods.getGoodsNumber());//原库存数
  917. mngChangeEntity.setValidNum(Integer.parseInt(goodsDto.getGoodsNumber()));//可用数
  918. mngChangeEntity.setChangeNum(Integer.parseInt(goodsDto.getGoodsNumber()));//变化数
  919. mngChangeEntity.setChangeType(Dict.changeType.item_3.getItem());
  920. mngChangeEntity.setGoodsId(goods.getId().intValue());
  921. goodsEntity.setId(goods.getId());
  922. goodsEntity.setGoodsNumber(goods.getGoodsNumber()+Integer.parseInt(goodsDto.getGoodsNumber()));
  923. // TODO 这里改成批量修改 GoodsEntity
  924. goodsDao.update(goodsEntity);
  925. }else{
  926. mngChangeEntity.setOriginalNum(0);//原库存数
  927. mngChangeEntity.setValidNum(Integer.parseInt(goodsDto.getGoodsNumber()));//可用数
  928. mngChangeEntity.setChangeNum(Integer.parseInt(goodsDto.getGoodsNumber()));//变化数
  929. mngChangeEntity.setChangeType(Dict.changeType.item_2.getItem());
  930. goodsDao.save(goodsEntity);
  931. insertGoodsList.add(goodsEntity);
  932. mngChangeEntity.setGoodsId(goodsEntity.getId().intValue());
  933. }
  934. // TODO 这里改成批量插入 MngChangeEntity
  935. insertMngChangeList.add(mngChangeEntity);
  936. // 修改产品
  937. ProductEntity product = productDao.queryObjectByGoodsIdAndStoreId(String.valueOf(goodsEntity.getId()), "");
  938. GoodsSpecificationEntity goodsSpecification = new GoodsSpecificationEntity();
  939. // 普通货物暂不添加商品规格
  940. if (!Dict.orderBizType.item_11.getItem().equals(goodsDto.getGoodsBizType())) {
  941. // 添加商品规格
  942. GoodsSpecificationEntity specificationEntity = goodsSpecificationDao.queryByGoodsId(goodsEntity.getId());
  943. if(specificationEntity == null) {
  944. goodsSpecification.setGoodsId(goodsEntity.getId());
  945. goodsSpecification.setValue(goodsEntity.getCiqProdModel());
  946. goodsSpecification.setSpecificationId(1);
  947. // TODO 这里改成批量插入 GoodsSpecificationEntity
  948. goodsSpecificationDao.save(goodsSpecification);
  949. }else{
  950. // {
  951. // goodsSpecification.setValue(goodsDto.getCiqProdModel());
  952. goodsSpecification.setId(specificationEntity.getId());
  953. //
  954. // // TODO 这里改成批量更新 GoodsSpecificationEntity
  955. // updateSpecificationList.add(goodsSpecification);
  956. // }
  957. }
  958. if(product == null){
  959. product = new ProductEntity();
  960. product.setGoodsSn(goodsDto.getGoodsSn());
  961. product.setGoodsId(goodsEntity.getId());
  962. product.setGoodsDefault(0);
  963. product.setGoodsNumber(goodsEntity.getGoodsNumber());
  964. product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
  965. product.setGoodsSpecificationIds(goodsSpecification.getId().toString());
  966. // TODO 这里改成批量插入 ProductEntity
  967. productDao.save(product);
  968. }else{
  969. product.setGoodsSpecificationIds(goodsSpecification.getId().toString());
  970. product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
  971. // TODO 这里改成批量更新 ProductEntity
  972. updateProductList.add(product);
  973. }
  974. }
  975. }
  976. }
  977. if(insertMngChangeList != null && insertMngChangeList.size() > 0 ){
  978. if(insertMngChangeList.size() > 50){
  979. List<List<MngChangeEntity>> partition = Lists.partition(insertMngChangeList, 50);
  980. for (List<MngChangeEntity> mngChangeEntities : partition) {
  981. mngChangeDao.saveBatch(mngChangeEntities);
  982. }
  983. }else{
  984. mngChangeDao.saveBatch(insertMngChangeList);
  985. }
  986. }
  987. // 批量更新数据mall_product
  988. if(updateProductList != null && updateProductList.size() > 0 ){
  989. if(updateProductList.size() > 50){
  990. List<List<ProductEntity>> partition = Lists.partition(updateProductList, 50);
  991. for (List<ProductEntity> productEntities : partition) {
  992. productDao.updateBatch(productEntities);
  993. }
  994. }else{
  995. productDao.updateBatch(updateProductList);
  996. }
  997. }
  998. // 批量更新数据mall_goods_specification 商品对应规格表值表
  999. if(updateSpecificationList != null && updateSpecificationList.size() > 0 ){
  1000. if(updateSpecificationList.size() > 50){
  1001. List<List<GoodsSpecificationEntity>> partition = Lists.partition(updateSpecificationList, 50);
  1002. for (List<GoodsSpecificationEntity> goodsSpecificationEntities : partition) {
  1003. goodsSpecificationDao.updateBatch(goodsSpecificationEntities);
  1004. }
  1005. }
  1006. }
  1007. ExportExceptionDataEntity exportExceptionDataEntity = new ExportExceptionDataEntity();
  1008. exportExceptionDataEntity.setCreaterSn(user.getUserId().toString());
  1009. exportExceptionDataEntity.setUserId(user.getUserId().intValue());
  1010. exportExceptionDataEntity.setCreateTime(new Date());
  1011. exportExceptionDataEntity.setModTime(new Date());
  1012. exportExceptionDataEntity.setMerchSn(merchSn);
  1013. exportExceptionDataEntity.setStoreId(user.getStoreId());
  1014. if(exportDataType == 1) {
  1015. exportExceptionDataEntity.setExportDataType(Dict.exportDataType.item_1.getItem());
  1016. }else{
  1017. exportExceptionDataEntity.setExportDataType(Dict.exportDataType.item_2.getItem());
  1018. }
  1019. if(failMerchUserGoodsSnList != null && failMerchUserGoodsSnList.size() > 0){
  1020. exportExceptionDataEntity.setExportExceptionData("不能操作除了登录用户以外商户的商品,当前商户编号为【"+merchSn+"】,请检查商品编码【"+failMerchUserGoodsSnList+"】的商品信息");
  1021. goodsUtils.save(exportExceptionDataEntity);
  1022. throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
  1023. }
  1024. if(failMerchGoodsSnList != null && failMerchGoodsSnList.size() > 0){
  1025. exportExceptionDataEntity.setExportExceptionData("第三方商户代码不存在,请在商城配置》第三方商户管理中维护,请检查商品编码【"+failMerchGoodsSnList+"】的商品信息,请先维护再继续操作!");
  1026. goodsUtils.save(exportExceptionDataEntity);
  1027. throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
  1028. }
  1029. if(failTypeGoodsSnList != null && failTypeGoodsSnList.size() > 0){
  1030. exportExceptionDataEntity.setExportExceptionData("货品业务类型只能是【00保税备货、02保税补货、10保税展示】!请检查商品编码【"+failTypeGoodsSnList+"】的商品信息");
  1031. goodsUtils.save(exportExceptionDataEntity);
  1032. throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
  1033. }
  1034. // if(failHotGoodsSnList != null && failHotGoodsSnList.size() > 0){
  1035. // exportExceptionDataEntity.setExportExceptionData("请检查业务类型为【保税补货或保税展示】的商品,商品编码【"+failHotGoodsSnList+"】的商品不能设置为热销!");
  1036. // goodsUtils.save(exportExceptionDataEntity);
  1037. // throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
  1038. // }
  1039. if(failUnitGoodsSnList != null && failUnitGoodsSnList.size() > 0){
  1040. exportExceptionDataEntity.setExportExceptionData("计算单位信息请在商城配置》计算单位中维护,不存在的商品编码【" + failUnitGoodsSnList + "】");
  1041. goodsUtils.save(exportExceptionDataEntity);
  1042. throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
  1043. }
  1044. if(failNationGoodsSnList != null && failNationGoodsSnList.size() > 0){
  1045. exportExceptionDataEntity.setExportExceptionData("原产国信息请在商城配置》原产国中维护,不存在的商品编码【" + failNationGoodsSnList + "】");
  1046. goodsUtils.save(exportExceptionDataEntity);
  1047. throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
  1048. }
  1049. }else{
  1050. throw new RRException("导入数据为出错,请检查数据是否按要求填写");
  1051. }
  1052. return 1;
  1053. }
  1054. private void checkCategory(GoodsDto goodsDto, GoodsEntity goodsEntity) {
  1055. // 二级分类名称
  1056. String secondLevel = goodsDto.getSecondLevel().trim();
  1057. String firstLevelName = goodsDto.getFirstLevel().trim();
  1058. CategoryEntity categoryNew = categoryDao.queryByName(secondLevel);
  1059. if(categoryNew != null){
  1060. String categoryId = categoryNew.getId().toString();
  1061. String level = categoryNew.getLevel();
  1062. if(categoryId == null){
  1063. throw new RuntimeException("该分类不是二级分类,请检查,对应sku是:"+ goodsDto.getSku()+",分类名称为:"+ goodsDto.getSecondLevel());
  1064. }else if(Dict.Level.item_L2.getItem().equals(level)){
  1065. CategoryEntity firstCategory = categoryDao.queryByName(firstLevelName);
  1066. if(firstCategory==null) {
  1067. throw new RuntimeException("该分类不是一级分类,请检查,对应sku是:" + goodsDto.getSku() + ",分类名称为:" + firstLevelName);
  1068. }
  1069. goodsEntity.setAttributeCategory(firstCategory.getId());
  1070. // 二级分类id在缓存中有,直接存入商品
  1071. goodsEntity.setCategoryId(Integer.parseInt(categoryId));
  1072. }
  1073. }else {
  1074. throw new RuntimeException("该分类不是二级分类,请检查,对应sku是:"+ goodsDto.getSku()+",分类名称为:"+ goodsDto.getSecondLevel());
  1075. }
  1076. }
  1077. private void checkBrand(GoodsDto goodsDto, GoodsEntity goodsEntity) {
  1078. String uniqueIdentifier = goodsDto.getUniqueIdentifier();
  1079. String brandName = goodsDto.getBrand();
  1080. Map<String, String> brandCache = JedisUtil.getMap(uniqueIdentifier);
  1081. if(brandCache != null) {
  1082. String brandId = brandCache.get("brandId");
  1083. if (brandId == null) {
  1084. Map<String, String> brandCacheData = new HashMap<>();
  1085. // 数据库里面查询
  1086. BrandEntity queryBrand = brandService.queryByUniqueIdentifier(uniqueIdentifier.trim());
  1087. if (queryBrand == null) {
  1088. throw new RuntimeException("该品牌不存在,请检查品牌唯一标识符是否正确:"+uniqueIdentifier);
  1089. } else {
  1090. brandCacheData.put("brandId", queryBrand.getId() + "");
  1091. brandCacheData.put("brandName", queryBrand.getName());
  1092. goodsEntity.setBrandId(queryBrand.getId());
  1093. }
  1094. JedisUtil.setMap(uniqueIdentifier, brandCacheData, 0);
  1095. } else {
  1096. goodsEntity.setBrandId(Integer.parseInt(brandId));
  1097. }
  1098. }else{
  1099. Map<String, String> brandCacheData = new HashMap<>();
  1100. // 数据库里面查询
  1101. BrandEntity queryBrand = brandService.queryByUniqueIdentifier(uniqueIdentifier.trim());
  1102. if (queryBrand == null) {
  1103. throw new RuntimeException("该品牌不存在,请检查品牌唯一标识符是否正确:"+uniqueIdentifier);
  1104. } else {
  1105. brandCacheData.put("brandId", queryBrand.getId() + "");
  1106. brandCacheData.put("brandName", queryBrand.getName());
  1107. goodsEntity.setBrandId(queryBrand.getId());
  1108. }
  1109. JedisUtil.setMap(uniqueIdentifier, brandCacheData, 0);
  1110. }
  1111. }
  1112. private CategoryEntity initCategory(String firstLevel, int parentId, Dict.Level item) {
  1113. CategoryEntity firstCategoryEntity = new CategoryEntity();
  1114. firstCategoryEntity.setName(firstLevel);
  1115. firstCategoryEntity.setParentId(parentId);
  1116. firstCategoryEntity.setIsShow(1);
  1117. firstCategoryEntity.setFrontDesc(firstLevel);
  1118. firstCategoryEntity.setType(0);
  1119. firstCategoryEntity.setLevel(item.getItem());
  1120. return firstCategoryEntity;
  1121. }
  1122. @Override
  1123. @Transactional
  1124. public int uploadExcelByCover(List<GoodsDto> goodsEntityList, int exportDataType) {
  1125. SysUserEntity user = ShiroUtils.getUserEntity();
  1126. String merchSn = user.getMerchSn();
  1127. boolean isFail = false;
  1128. List<String> failSameSkuList = new ArrayList<>(), failHotGoodsSnList = new ArrayList<>(),
  1129. failSuppGoodsSnList = new ArrayList<>(),
  1130. failUnitGoodsSnList = new ArrayList<>(), failNationGoodsSnList = new ArrayList<>(),
  1131. failTypeGoodsSnList = new ArrayList<>(), failMerchGoodsSnList = new ArrayList<>(),
  1132. failMerchUserGoodsSnList = new ArrayList<>();
  1133. // List<String> failGoodsSnList = new ArrayList<>();
  1134. List<String> failGoodsTypeList = new ArrayList<>();
  1135. if (goodsEntityList != null && goodsEntityList.size() > 0) {
  1136. for (int i = 0; i < goodsEntityList.size(); i++) {
  1137. GoodsDto goodsDto = goodsEntityList.get(i);
  1138. GoodsEntity goodsEntity = new GoodsEntity();
  1139. Map<String, Object> valideDate = MapBeanUtil.fromObject(goodsDto);
  1140. ImmutableBiMap.Builder builder = new ImmutableBiMap.Builder();
  1141. builder.put("goodsSn", "商品编码");
  1142. builder.put("thirdPartyMerchCode", "第三方商户代码");
  1143. builder.put("goodsBizType", "货品业务类型");
  1144. builder.put("name", "商品名称");
  1145. builder.put("isOnSaleStr", "上架");
  1146. builder.put("goodsUnit", "商品单位");
  1147. builder.put("isHotStr", "热销");
  1148. builder.put("prodBarcode", "产品条码");
  1149. builder.put("supplierName", "供应商");
  1150. builder.put("goodsNumber", "商品总库存");
  1151. R r = ValidatorUtil.isEmpty(builder.build(), valideDate);
  1152. if (Integer.valueOf(r.get("code").toString()) != 0) {
  1153. throw new RRException(r.get("msg").toString());
  1154. } else {
  1155. if (!Dict.orderBizType.item_11.getItem().equals(goodsDto.getGoodsBizType())) {
  1156. // 海关信息,普通货物可不添加
  1157. builder.put("goodsRate", "商品税率");
  1158. builder.put("sku", "SKU");
  1159. // builder.put("brand", "产品品牌");
  1160. builder.put("unitName", "计量单位");
  1161. builder.put("oriCntName", "原产国");
  1162. builder.put("cusGoodsCode", "海关商品编码");
  1163. //builder.put("ciqProdModel", "国检规格型号");
  1164. // builder.put("cusDeclEle", "海关申报要素");
  1165. //builder.put("cusRecCode", "海关备案编号");
  1166. }
  1167. r = ValidatorUtil.isEmpty(builder.build(), valideDate);
  1168. if (Integer.valueOf(r.get("code").toString()) != 0) {
  1169. throw new RRException(r.get("msg").toString());
  1170. }
  1171. }
  1172. //业务类型校验
  1173. if(!Dict.orderBizType.item_11.getItem().equalsIgnoreCase(goodsDto.getGoodsBizType())){
  1174. if(!(Dict.orderBizType.item_02.getItem().equalsIgnoreCase(goodsDto.getGoodsBizType())
  1175. || Dict.orderBizType.item_10.getItem().equalsIgnoreCase(goodsDto.getGoodsBizType())
  1176. || Dict.orderBizType.item_00.getItem().equalsIgnoreCase(goodsDto.getGoodsBizType()))){
  1177. isFail = true;
  1178. failTypeGoodsSnList.add(goodsDto.getSku());
  1179. }
  1180. }
  1181. ThirdMerchantBizEntity thirdMerchantBizEntity = thirdMerchantBizDao.getThirdMerchangByCode(goodsDto.getThirdPartyMerchCode());
  1182. if(thirdMerchantBizEntity != null){
  1183. goodsEntity.setMerchSn(thirdMerchantBizEntity.getMerchSn());
  1184. goodsEntity.setThirdPartyMerchCode(thirdMerchantBizEntity.getThirdPartyMerchCode());
  1185. if(!user.getRoleType().equalsIgnoreCase(Dict.roleType.item_1.getItem())) {
  1186. if (!merchSn.equalsIgnoreCase(thirdMerchantBizEntity.getMerchSn())) {
  1187. isFail = true;
  1188. failMerchUserGoodsSnList.add(goodsDto.getGoodsSn());
  1189. }
  1190. }
  1191. }else{//商户不存在
  1192. isFail = true;
  1193. failMerchGoodsSnList.add(goodsDto.getGoodsSn());
  1194. }
  1195. //校验商品信息是否已存在
  1196. Map<String, Object> map = new HashMap<>();
  1197. map.put("isSame", "true");
  1198. map.put("sku", goodsDto.getSku());
  1199. map.put("goodsSn", goodsDto.getGoodsSn());
  1200. map.put("goodsBizType", goodsDto.getGoodsBizType());
  1201. // List<GoodsEntity> list = querySame(map);
  1202. // if (list != null && list.size() != 0) {
  1203. // isFail = true;
  1204. // if(goodsDto.getSku()!=null) {
  1205. // failSameSkuList.add(goodsDto.getSku());
  1206. // }
  1207. // failGoodsSnList.add(goodsDto.getGoodsSn());
  1208. // failGoodsTypeList.add(goodsDto.getGoodsBizType());
  1209. // }
  1210. //校验产品条码是否存在
  1211. goodsEntity.setProdBarcode(goodsDto.getProdBarcode());
  1212. //热销商品校验
  1213. if (Dict.orderBizType.item_02.getItem().equals(goodsDto.getGoodsBizType())
  1214. || Dict.orderBizType.item_10.getItem().equals(goodsDto.getGoodsBizType())) {
  1215. if(goodsDto.getIsHotStr().equalsIgnoreCase("1")){
  1216. isFail = true;
  1217. failHotGoodsSnList.add(goodsDto.getGoodsSn());
  1218. }
  1219. }
  1220. if(thirdMerchantBizEntity != null) {
  1221. SupplierEntity supplierEntity = supplierDao.queryObjectByName(goodsDto.getSupplierName(), thirdMerchantBizEntity.getMerchSn(),thirdMerchantBizEntity.getThirdPartyMerchCode());
  1222. if (supplierEntity == null) {
  1223. //导入没有查到供货商,执行新增
  1224. MerchEntity merchEntity = merchDao.findByMerchSn(thirdMerchantBizEntity.getMerchSn());
  1225. if(null == merchEntity || !StringUtils.isNotEmpty(goodsDto.getSupplierFlag())){
  1226. isFail = true;
  1227. failSuppGoodsSnList.add(goodsDto.getGoodsSn());
  1228. }
  1229. supplierEntity = new SupplierEntity();
  1230. supplierEntity.setLevelMerchSn(merchEntity.getMerchSn());
  1231. supplierEntity.setLevelMerchFlag(merchEntity.getMerchShortName());
  1232. supplierEntity.setThirdPartyMerchCode(thirdMerchantBizEntity.getThirdPartyMerchCode());
  1233. supplierEntity.setChildSupplierName(goodsDto.getSupplierName());
  1234. supplierEntity.setChildSupplierFlag(goodsDto.getSupplierFlag());
  1235. supplierEntity.setIsShow("0");
  1236. supplierDao.save(supplierEntity);
  1237. goodsEntity.setSupplierId(supplierEntity.getId());
  1238. } else {
  1239. goodsEntity.setSupplierId(supplierEntity.getId());
  1240. }
  1241. }
  1242. if (!Dict.orderBizType.item_11.getItem().equals(goodsDto.getGoodsBizType())) {
  1243. SysCusUnitCodeEntity sysCusUnitCodeEntity = sysCusUnitCodeDao.queryObjectByName(goodsDto.getUnitName());
  1244. if (sysCusUnitCodeEntity == null) {
  1245. isFail = true;
  1246. failUnitGoodsSnList.add(goodsDto.getGoodsSn());
  1247. } else {
  1248. goodsEntity.setUnitCode(sysCusUnitCodeEntity.getCode());
  1249. }
  1250. //原产国
  1251. SysCusNationCodeEntity sysCusNationCodeEntity = sysCusNationCodeDao.queryObjectByName(goodsDto.getOriCntName());
  1252. if (sysCusNationCodeEntity == null) {
  1253. isFail = true;
  1254. failNationGoodsSnList.add(goodsDto.getGoodsSn());
  1255. } else {
  1256. goodsEntity.setOriCntCode(sysCusNationCodeEntity.getCode());
  1257. }
  1258. if(goodsDto.getGoodsRate().indexOf("%") != -1){
  1259. goodsDto.setGoodsRate(goodsDto.getGoodsRate().substring(0, goodsDto.getGoodsRate().indexOf("%")));
  1260. }
  1261. goodsEntity.setGoodsRate(BigDecimal.valueOf(Double.valueOf(goodsDto.getGoodsRate())).divide(new BigDecimal(100), 4, BigDecimal.ROUND_HALF_UP));
  1262. }
  1263. goodsEntity.setIsOnSale(Integer.parseInt(goodsDto.getIsOnSaleStr()));
  1264. goodsEntity.setIsHot(Integer.parseInt(goodsDto.getIsHotStr()));
  1265. goodsEntity.setGoodsSn(goodsDto.getGoodsSn());
  1266. goodsEntity.setSku(goodsDto.getSku());
  1267. goodsEntity.setName(goodsDto.getName());
  1268. goodsEntity.setGoodsUnit(goodsDto.getGoodsUnit());
  1269. goodsEntity.setGoodsBizType(goodsDto.getGoodsBizType());
  1270. goodsEntity.setBrand(goodsDto.getBrand());
  1271. goodsEntity.setCusDeclEle(goodsDto.getCusDeclEle());
  1272. goodsEntity.setCusGoodsCode(goodsDto.getCusGoodsCode());
  1273. goodsEntity.setCusRecCode(goodsDto.getCusRecCode());
  1274. goodsEntity.setCiqProdModel(goodsDto.getCiqProdModel());
  1275. goodsEntity.setIsDelete(Integer.parseInt(Dict.isDelete.item_0.getItem()));
  1276. goodsEntity.setIsNew(0);
  1277. goodsEntity.setUpdateUserId(user.getUserId());
  1278. goodsEntity.setAddTime(new Date());
  1279. goodsEntity.setCreateTime(new Date());
  1280. goodsEntity.setUpdateTime(new Date());
  1281. goodsEntity.setModTime(new Date());
  1282. goodsEntity.setGoodsNumber(Integer.parseInt(goodsDto.getGoodsNumber()));
  1283. if(!isFail){
  1284. GoodsEntity goods = goodsDao.queryObjectBySnNew(goodsDto.getGoodsSn());
  1285. MngChangeEntity mngChangeEntity = new MngChangeEntity();
  1286. mngChangeEntity.setThirdPartyMerchCode(goodsEntity.getThirdPartyMerchCode());
  1287. mngChangeEntity.setChangeReason("更新商户商品总库存");
  1288. mngChangeEntity.setCreateTime(new Date());
  1289. mngChangeEntity.setModTime(new Date());
  1290. mngChangeEntity.setCreaterSn(user.getUsername());
  1291. mngChangeEntity.setModerSn(user.getUsername());
  1292. mngChangeEntity.setIsValid(0);
  1293. mngChangeEntity.setMerchSn(goodsEntity.getMerchSn());
  1294. if(goods!=null) {// 修改商品
  1295. mngChangeEntity.setOriginalNum(goods.getGoodsNumber());//原库存数
  1296. mngChangeEntity.setValidNum(goods.getGoodsNumber() + Integer.parseInt(goodsDto.getGoodsNumber()));//可用数
  1297. mngChangeEntity.setChangeNum(Integer.parseInt(goodsDto.getGoodsNumber()));//变化数
  1298. mngChangeEntity.setChangeType(Dict.changeType.item_3.getItem());
  1299. mngChangeEntity.setGoodsId(Integer.parseInt(String.valueOf(goods.getId())));
  1300. goodsEntity.setId(goods.getId());
  1301. goodsEntity.setGoodsNumber(goods.getGoodsNumber()+Integer.parseInt(goodsDto.getGoodsNumber()));
  1302. goodsDao.update(goodsEntity);
  1303. }else{
  1304. mngChangeEntity.setOriginalNum(0);//原库存数
  1305. mngChangeEntity.setValidNum(Integer.parseInt(goodsDto.getGoodsNumber()));//可用数
  1306. mngChangeEntity.setChangeNum(Integer.parseInt(goodsDto.getGoodsNumber()));//变化数
  1307. mngChangeEntity.setChangeType(Dict.changeType.item_2.getItem());
  1308. goodsDao.save(goodsEntity);
  1309. mngChangeEntity.setGoodsId(goodsEntity.getId().intValue());
  1310. }
  1311. mngChangeDao.save(mngChangeEntity);
  1312. // 修改产品
  1313. ProductEntity product = productDao.queryObjectByGoodsIdAndStoreId(String.valueOf(goodsEntity.getId()), "");
  1314. GoodsSpecificationEntity goodsSpecification = new GoodsSpecificationEntity();
  1315. // 普通货物暂不添加商品规格
  1316. if (!Dict.orderBizType.item_11.getItem().equals(goodsDto.getGoodsBizType())) {
  1317. // 添加商品规格
  1318. GoodsSpecificationEntity specificationEntity = goodsSpecificationDao.queryByGoodsId(goodsEntity.getId());
  1319. if(specificationEntity == null) {
  1320. goodsSpecification.setGoodsId(goodsEntity.getId());
  1321. goodsSpecification.setValue(goodsEntity.getCiqProdModel());
  1322. goodsSpecification.setSpecificationId(1);
  1323. goodsSpecificationDao.save(goodsSpecification);
  1324. }else {
  1325. goodsSpecification.setValue(goodsDto.getCiqProdModel());
  1326. goodsSpecification.setId(specificationEntity.getId());
  1327. goodsSpecificationDao.update(goodsSpecification);
  1328. }
  1329. if(product == null){
  1330. product = new ProductEntity();
  1331. product.setGoodsSn(goodsDto.getGoodsSn());
  1332. product.setGoodsId(goodsEntity.getId());
  1333. product.setGoodsDefault(0);
  1334. product.setGoodsNumber(goodsEntity.getGoodsNumber());
  1335. product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
  1336. product.setGoodsSpecificationIds(goodsSpecification.getId().toString());
  1337. productDao.save(product);
  1338. }else{
  1339. product.setGoodsSpecificationIds(goodsSpecification.getId().toString());
  1340. product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
  1341. productDao.update(product);
  1342. }
  1343. }
  1344. }
  1345. }
  1346. ExportExceptionDataEntity exportExceptionDataEntity = new ExportExceptionDataEntity();
  1347. exportExceptionDataEntity.setCreaterSn(user.getUserId().toString());
  1348. exportExceptionDataEntity.setUserId(user.getUserId().intValue());
  1349. exportExceptionDataEntity.setCreateTime(new Date());
  1350. exportExceptionDataEntity.setModTime(new Date());
  1351. exportExceptionDataEntity.setMerchSn(merchSn);
  1352. exportExceptionDataEntity.setStoreId(user.getStoreId());
  1353. if(exportDataType == 1) {
  1354. exportExceptionDataEntity.setExportDataType(Dict.exportDataType.item_1.getItem());
  1355. }else{
  1356. exportExceptionDataEntity.setExportDataType(Dict.exportDataType.item_2.getItem());
  1357. }
  1358. if(failMerchUserGoodsSnList != null && failMerchUserGoodsSnList.size() > 0){
  1359. exportExceptionDataEntity.setExportExceptionData("不能操作除了登录用户以外商户的商品,当前商户编号为【"+merchSn+"】,请检查商品编码【"+failMerchUserGoodsSnList+"】的商品信息");
  1360. goodsUtils.save(exportExceptionDataEntity);
  1361. throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
  1362. }
  1363. if(failMerchGoodsSnList != null && failMerchGoodsSnList.size() > 0){
  1364. exportExceptionDataEntity.setExportExceptionData("第三方商户代码不存在,请在商城配置》第三方商户管理中维护,请检查商品编码【"+failMerchGoodsSnList+"】的商品信息,请先维护再继续操作!");
  1365. goodsUtils.save(exportExceptionDataEntity);
  1366. throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
  1367. }
  1368. // if(failGoodsSnList != null && failGoodsSnList.size() > 0){
  1369. // if(failSameSkuList.size()>0) {
  1370. // exportExceptionDataEntity.setExportExceptionData("不能有重复的商品编码、sku信息!请检查商品编码【" + failGoodsSnList + "】,业务类型【" +
  1371. // failGoodsTypeList + "】,SKU【" + failSameSkuList + "】的商品信息");
  1372. // goodsUtils.save(exportExceptionDataEntity);
  1373. // throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
  1374. // }else{
  1375. // exportExceptionDataEntity.setExportExceptionData("不能有重复的商品编码、sku信息!请检查商品编码【" + failGoodsSnList + "】,业务类型【" +
  1376. // failGoodsTypeList + "】的商品信息");
  1377. // goodsUtils.save(exportExceptionDataEntity);
  1378. // throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
  1379. // }
  1380. // }
  1381. if(failTypeGoodsSnList != null && failTypeGoodsSnList.size() > 0){
  1382. exportExceptionDataEntity.setExportExceptionData("货品业务类型只能是【00保税备货、02保税补货、10保税展示】!请检查商品编码【"+failTypeGoodsSnList+"】的商品信息");
  1383. goodsUtils.save(exportExceptionDataEntity);
  1384. throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
  1385. }
  1386. if(failHotGoodsSnList != null && failHotGoodsSnList.size() > 0){
  1387. exportExceptionDataEntity.setExportExceptionData("请检查业务类型为【保税补货或保税展示】的商品,商品编码【"+failHotGoodsSnList+"】的商品不能设置为热销!");
  1388. goodsUtils.save(exportExceptionDataEntity);
  1389. throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
  1390. }
  1391. if(failSuppGoodsSnList != null && failSuppGoodsSnList.size() > 0){
  1392. exportExceptionDataEntity.setExportExceptionData("供应商信息请在商城配置》商品供应商中维护,供应商与商户信息对应,请检查该商品商户信息下的供应商是否维护,不存在的商品编码【" + failSuppGoodsSnList + "】");
  1393. goodsUtils.save(exportExceptionDataEntity);
  1394. throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
  1395. }
  1396. if(failUnitGoodsSnList != null && failUnitGoodsSnList.size() > 0){
  1397. exportExceptionDataEntity.setExportExceptionData("计算单位信息请在商城配置》计算单位中维护,不存在的商品编码【" + failUnitGoodsSnList + "】");
  1398. goodsUtils.save(exportExceptionDataEntity);
  1399. throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
  1400. }
  1401. if(failNationGoodsSnList != null && failNationGoodsSnList.size() > 0){
  1402. exportExceptionDataEntity.setExportExceptionData("原产国信息请在商城配置》原产国中维护,不存在的商品编码【" + failNationGoodsSnList + "】");
  1403. goodsUtils.save(exportExceptionDataEntity);
  1404. throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
  1405. }
  1406. }else{
  1407. throw new RRException("导入数据为空,或者检查商品编码数据是否为空");
  1408. }
  1409. return 1;
  1410. }
  1411. @Override
  1412. public GoodsDetailsDto queryGoodsDetailsByProdBarcode(String prodBarcode, String storeId,String sku) {
  1413. return goodsDao.queryGoodsDetailsByProdBarcode(prodBarcode,storeId,sku);
  1414. }
  1415. @Override
  1416. public GoodsPanoramaDto searchGoodsPanoramaDtoByKeyword(String keyword) {
  1417. return goodsDao.searchGoodsPanoramaDtoByKeyword(keyword);
  1418. }
  1419. @Override
  1420. public List<GoodsEntity> queryExportList(Map<String, Object> params) {
  1421. return goodsDao.queryExportList(params);
  1422. }
  1423. /**
  1424. * 查出pdf需要的需要
  1425. *
  1426. * @param sku 商品sku
  1427. * @param storeId
  1428. * @param prodBarcode
  1429. * @return
  1430. */
  1431. @Override
  1432. public PDFGoodsDto queryForPDFData(String sku, String storeId, String prodBarcode) {
  1433. return goodsDao.queryForPDFData(sku,storeId,prodBarcode);
  1434. }
  1435. /**
  1436. * 查询产品价格
  1437. * 改进后的逻辑:
  1438. * @param prodBarcode
  1439. * @param storeId
  1440. * @return
  1441. */
  1442. @Override
  1443. @Transactional
  1444. public synchronized Map<String,Object> calculateGoodsDetail(String prodBarcode, String storeId, String sku) {
  1445. /**
  1446. * 1.首先根据商品条码跟门店id查询是否有库存,没库存直接返回
  1447. */
  1448. GoodsDetailsDto goods = queryGoodsDetailsByProdBarcode(prodBarcode,storeId,sku);
  1449. if(goods == null) {
  1450. return null;
  1451. }
  1452. String env = environment.getProperty("haikong.env");
  1453. /*
  1454. * 2. 查询海仓仓库系统,判断库存是否足够
  1455. * */
  1456. sku = org.springframework.util.StringUtils.isEmpty(sku) ? goods.getSku() : sku;
  1457. String wareStockNumberKey = storeId + sku + prodBarcode;
  1458. String warehouseStockMapKey = Constants.WAREHOUSE_STOCK_MAP_KEY + "_" + storeId;
  1459. String redisCacheWareQuantity = JedisUtil.hget(warehouseStockMapKey, wareStockNumberKey);
  1460. Integer wareQuantity = 0;
  1461. Integer exitRegionNumber = goods.getExitRegionNumber();
  1462. String stockNum = goods.getStockNum();
  1463. Integer sellVolume = Objects.isNull(goods.getSellVolume()) ? 1 : goods.getSellVolume();
  1464. if (org.springframework.util.StringUtils.isEmpty(redisCacheWareQuantity)) {
  1465. WareQueryStockResponseDTO wareQueryStockResponseDTO = null;
  1466. String queryWarehouseStockResponse = null;
  1467. // 环境配置
  1468. if (!org.springframework.util.StringUtils.isEmpty(env) && Constants.PROD.equals(env)) {
  1469. WareQueryStockParamDTO wareQueryStockParamDTO = new WareQueryStockParamDTO();
  1470. List<Criteria> criteriaList = new ArrayList<>();
  1471. Criteria criteria = new Criteria();
  1472. criteria.setItemId(goods.getWarehouseSysGoodId());
  1473. criteria.setItemCode(goods.getSku());
  1474. criteria.setOwnerCode(haiKongProperties.getWareCompanyCode());
  1475. criteria.setInventoryType(Constants.InventoryType.ZP.getType());
  1476. criteria.setWarehouseCode(goods.getWarehouseSn());
  1477. criteriaList.add(criteria);
  1478. wareQueryStockParamDTO.setCriteriaList(criteriaList);
  1479. try {
  1480. queryWarehouseStockResponse = haiKongWarehouseTemplate.queryWarehouseStock(wareQueryStockParamDTO);
  1481. } catch (Exception e) {
  1482. log.error("sku:【{}】,调用海控仓库系统查询库存出现异常!", sku, e);
  1483. throw new ServiceException(String.format("sku:【%s】,调用海控仓库系统查询库存出现异常!", sku));
  1484. }
  1485. log.info("调用海控仓库系统,请求参数,门店:{}、商品条码:{}、商品编码:{},响应数据:{}", storeId, prodBarcode, sku, queryWarehouseStockResponse);
  1486. if (org.springframework.util.StringUtils.isEmpty(queryWarehouseStockResponse)) {
  1487. log.error("调用库存系统接口出现错误!返回结果为空!");
  1488. throw new ServiceException("调用库存系统接口出现错误!");
  1489. }
  1490. wareQueryStockResponseDTO = (WareQueryStockResponseDTO) XmlUtil.xmlStrToBean(queryWarehouseStockResponse, WareQueryStockResponseDTO.class);
  1491. if (Objects.isNull(wareQueryStockResponseDTO)) {
  1492. log.error("解析一步达库存系统响应数据出现错误!请求响应结果:{}", queryWarehouseStockResponse);
  1493. throw new ServiceException("解析一步达库存系统响应数据出现错误!");
  1494. }
  1495. if ("failure".equals(wareQueryStockResponseDTO.getFlag())) {
  1496. log.error("请求一步达库存系统返回错误响应!响应数据:{}", queryWarehouseStockResponse);
  1497. throw new ServiceException(String.format("请求一步达库存系统查询库存错误!响应数据:%s", wareQueryStockResponseDTO.getMessage()));
  1498. }
  1499. } else {
  1500. wareQueryStockResponseDTO = new WareQueryStockResponseDTO();
  1501. wareQueryStockResponseDTO.setCode("0");
  1502. wareQueryStockResponseDTO.setFlag("success");
  1503. wareQueryStockResponseDTO.setMessage("");
  1504. WareQueryStockResponseDTO.WareQueryStockResponseItemDTO wareQueryStockResponseItemDTO = new WareQueryStockResponseDTO.WareQueryStockResponseItemDTO();
  1505. wareQueryStockResponseItemDTO.setQuantity(3);
  1506. wareQueryStockResponseItemDTO.setItemCode(sku);
  1507. wareQueryStockResponseItemDTO.setProduceCode(prodBarcode);
  1508. List<WareQueryStockResponseDTO.WareQueryStockResponseItemDTO> wareQueryStockResponseItemDTOS = new ArrayList<>();
  1509. wareQueryStockResponseItemDTOS.add(wareQueryStockResponseItemDTO);
  1510. wareQueryStockResponseDTO.setItems(wareQueryStockResponseItemDTOS);
  1511. }
  1512. // 校验库存
  1513. List<WareQueryStockResponseDTO.WareQueryStockResponseItemDTO> items = wareQueryStockResponseDTO.getItems();
  1514. if (CollectionUtils.isEmpty(items)) {
  1515. log.error("查询商品时:【{}】,仓库不存在该商品!", prodBarcode);
  1516. throw new ServiceException(String.format("查询商品时:【%s】,仓库不存在该商品!", prodBarcode));
  1517. }
  1518. WareQueryStockResponseDTO.WareQueryStockResponseItemDTO itemDTO = items.get(0);
  1519. // 仓库可用库存
  1520. wareQuantity = itemDTO.getQuantity();
  1521. JedisUtil.hset(warehouseStockMapKey, wareStockNumberKey, String.valueOf(wareQuantity));
  1522. } else {
  1523. wareQuantity = Integer.parseInt(redisCacheWareQuantity);
  1524. }
  1525. // 保税仓库存 + 展销店库存 - 出区数 >= 购买数
  1526. if (!((wareQuantity + Integer.parseInt(stockNum) - exitRegionNumber) > sellVolume)) {
  1527. // 库存不足
  1528. log.error("商品条码:【{}】,sku:【{}】,门店库存:【{}】,保税仓库存:【{}】,出区数:【{}】,该商品仓库库存不足!", prodBarcode, sku, stockNum, wareQuantity, exitRegionNumber);
  1529. throw new ServiceException(String.format("商品条码:【%s】,sku:【%s】,门店库存:【%s】,保税仓库存:【%s】,出区数:【%s】,该商品仓库库存不足!", prodBarcode, sku, stockNum, wareQuantity, exitRegionNumber));
  1530. } else {
  1531. JedisUtil.hset(warehouseStockMapKey, wareStockNumberKey, String.valueOf(wareQuantity - sellVolume));
  1532. }
  1533. goods.setDiscountedPrice(new BigDecimal(0));
  1534. BigDecimal retailPrice = goods.getRetailPrice();
  1535. goods.setActualPaymentAmount(retailPrice.setScale(2,RoundingMode.HALF_UP));
  1536. Map<String,Object> skuActivitiesMap = new HashMap<>();
  1537. // 计算税费
  1538. GoodsEntity goodsEntity = goodsDao.queryByBarcodeAndSku(prodBarcode, goods.getGoodsSn());
  1539. BigDecimal tax = CalculateTax.calculateFinalTax(goodsEntity, goods.getActualPaymentAmount(),this).setScale(3,RoundingMode.HALF_UP);
  1540. goods.setGoodstaxes(tax.toString());
  1541. goods.setSellVolume(1);
  1542. skuActivitiesMap.put("goods",goods);
  1543. return skuActivitiesMap;
  1544. }
  1545. @Override
  1546. public List<Map<String,Object>> selectSkuDetails(String prodBarcode, String storeId) {
  1547. /**
  1548. * 1.首先根据商品条码跟门店id查询是否有库存,没库存直接返回
  1549. */
  1550. List<GoodsDetailsDto> goodsList = goodsDao.queryGoodsSkuList(prodBarcode,storeId);
  1551. List<Map<String,Object>> mapList = new ArrayList<>();
  1552. if (goodsList == null) {
  1553. return null;
  1554. }
  1555. for(GoodsDetailsDto goods : goodsList){
  1556. mapList.add(selectGetSkuDetails(goods,prodBarcode,storeId));
  1557. }
  1558. return mapList;
  1559. }
  1560. public Map<String,Object> selectGetSkuDetails(GoodsDetailsDto goods,String prodBarcode, String storeId) {
  1561. /**
  1562. * 1.首先根据商品条码跟门店id查询是否有库存,没库存直接返回
  1563. */
  1564. goods.setDiscountedPrice(new BigDecimal(0));
  1565. BigDecimal retailPrice = goods.getRetailPrice();
  1566. goods.setActualPaymentAmount(retailPrice.setScale(2,RoundingMode.HALF_UP));
  1567. Map<String,Object> skuActivitiesMap = new HashMap<>();
  1568. // 计算税费
  1569. GoodsEntity goodsEntity = goodsDao.queryByBarcodeAndSku(prodBarcode, goods.getGoodsSn());
  1570. BigDecimal tax = CalculateTax.calculateFinalTax(goodsEntity,goods.getActualPaymentAmount(),this).setScale(3,RoundingMode.HALF_UP);
  1571. goods.setGoodstaxes(tax.toString());
  1572. skuActivitiesMap.put("goods",goods);
  1573. return skuActivitiesMap;
  1574. }
  1575. /**
  1576. * 根据条形码查询商品
  1577. *
  1578. * @param barCode
  1579. * @return
  1580. */
  1581. @Override
  1582. public GoodsEntity queryByBarcode(String barCode) {
  1583. return goodsDao.queryByBarcode(barCode);
  1584. }
  1585. /**
  1586. * 根据sku查询商品
  1587. *
  1588. * @param sku
  1589. * @return
  1590. */
  1591. @Override
  1592. public GoodsEntity queryBySku(String sku) {
  1593. return goodsDao.queryBySku(sku);
  1594. }
  1595. /* @Override
  1596. @Transactional
  1597. public int uploadExcel(MultipartFile file) {
  1598. SysUserEntity user = ShiroUtils.getUserEntity();
  1599. List<String[]> list = ExcelImport.getExcelData(file);
  1600. // 取门店名称
  1601. StoreEntity storeEntity = storeDao.queryObjectByName(list.get(0)[3]);
  1602. if (null == storeEntity) {
  1603. return 0;
  1604. }
  1605. //去除表头两行、底部合计
  1606. if (list != null && list.size() > 3) {
  1607. ProductStoreRelaEntity storeRelaEntity;
  1608. ProductEntity productEntity;
  1609. for (int i = 2; i < list.size() - 1; i++) {
  1610. String[] item = list.get(i);
  1611. String goodsSn = item[0];
  1612. productEntity = productDao.queryObjectBySn(goodsSn);
  1613. if (StringUtils.isNullOrEmpty(goodsSn)) {
  1614. continue;
  1615. }
  1616. if (null == productEntity || null == productEntity.getId()) {
  1617. continue;
  1618. }
  1619. storeRelaEntity = productStoreRelaDao.queryByStoreIdProductId(storeEntity.getId(), productEntity.getId());
  1620. if (null != storeRelaEntity && null != storeRelaEntity.getId()) {
  1621. storeRelaEntity.setRetailPrice(new BigDecimal(item[6]));
  1622. storeRelaEntity.setStockNum(Integer.valueOf(item[3].replace(".00", "")));
  1623. storeRelaEntity.setStockPrice(new BigDecimal(item[4]));
  1624. productStoreRelaDao.update(storeRelaEntity);
  1625. } else {
  1626. storeRelaEntity = new ProductStoreRelaEntity();
  1627. storeRelaEntity.setGoodsId(productEntity.getGoodsId());
  1628. storeRelaEntity.setProductId(productEntity.getId());
  1629. storeRelaEntity.setRetailPrice(new BigDecimal(item[6]));
  1630. storeRelaEntity.setMarketPrice(new BigDecimal(item[6]));
  1631. storeRelaEntity.setStockNum(Integer.valueOf(item[3]));
  1632. storeRelaEntity.setStockPrice(new BigDecimal(item[4]));
  1633. storeRelaEntity.setStoreId(storeEntity.getId());
  1634. productStoreRelaDao.save(storeRelaEntity);
  1635. }
  1636. }
  1637. }
  1638. return 1;
  1639. }*/
  1640. /**
  1641. * 全量拉取
  1642. */
  1643. @Override
  1644. public void syncOmsHsCodeTask() {
  1645. syncOmsHsCodeSegment(goodsDao.queryNonSyncOmsHsCodeSkuList());
  1646. }
  1647. /**
  1648. * 全量计算
  1649. */
  1650. @Override
  1651. public void syncGoodsRateTask() {
  1652. // 查询出所有商品
  1653. List<GoodsEntity> allGoodsList = goodsDao.queryAllList(null,null);
  1654. syncGoodsRate(allGoodsList);
  1655. }
  1656. /**
  1657. * 还原园区库存
  1658. *
  1659. * @param goodsEntities 数据
  1660. */
  1661. @Override
  1662. public int restoreBatch(List<GoodsEntity> goodsEntities) {
  1663. return goodsDao.restoreBatch(goodsEntities);
  1664. }
  1665. /**
  1666. * 查询库存及sku的信息,查询出来的库存是门店的库存
  1667. *
  1668. * @param prodBarcode 条码
  1669. * @param storeId 门店id
  1670. * @param sku sku
  1671. * @return 商品信息
  1672. */
  1673. @Override
  1674. public GoodsEntity queryGoodsStockByBarcodeAndStoreIdAndSku(String prodBarcode, Integer storeId, String sku) {
  1675. return goodsDao.queryGoodsStockByBarcodeAndStoreIdAndSku(prodBarcode, storeId, sku);
  1676. }
  1677. /**
  1678. * 查询库存及sku的信息,查询出来的库存是门店的库存
  1679. *
  1680. * @param queryGoodsVOList 查询条件,包含商品条码、sku、门店id
  1681. * @return 商品信息
  1682. */
  1683. @Override
  1684. public List<GoodsEntity> queryGoodsStockByQueryGoodsVoList(List<QueryGoodsVO> queryGoodsVOList) {
  1685. return goodsDao.queryGoodsStockByQueryGoodsVoList(queryGoodsVOList);
  1686. }
  1687. /**
  1688. * 选择拉取
  1689. * @param ids
  1690. */
  1691. @Override
  1692. public void syncOmsHsCodeGoode(List<Integer> ids) {
  1693. syncOmsHsCodeSegment(goodsDao.syncOmsHsCodeGoode(ids));
  1694. }
  1695. /**
  1696. * 选择计算
  1697. * @param ids
  1698. */
  1699. @Override
  1700. public void syncGoodsRateGoode(List<Integer> ids) {
  1701. syncGoodsRate(goodsDao.syncGoodsRateGoode(ids));
  1702. }
  1703. public void syncOmsHsCodeSegment(List<String> skuList) {
  1704. int segmentLimitSize = 300;
  1705. if (skuList.size() < segmentLimitSize) {
  1706. this.syncOmsHsCode(skuList);
  1707. } else {
  1708. int segmentSize = skuList.size() % segmentLimitSize == 0 ? skuList.size() / segmentLimitSize : (skuList.size() / segmentLimitSize) + 1;
  1709. List<List<String>> segment = new ArrayList<>();
  1710. for (int i = 0; i < segmentSize; i++) {
  1711. int end = (i == segmentSize - 1) ? skuList.size() : i * segmentLimitSize + segmentLimitSize;
  1712. segment.add(new ArrayList<>(skuList.subList(i * segmentLimitSize, end)));
  1713. }
  1714. for (List<String> tmp : segment) {
  1715. this.syncOmsHsCode(tmp);
  1716. }
  1717. }
  1718. }
  1719. @Transactional
  1720. public void syncOmsHsCode(List<String> skuList) {
  1721. if (Objects.nonNull(skuList) && skuList.size()>0){
  1722. String result = HttpUtil.get("https://oms.ds-bay.com/oms-controller-mgt/pdProductRecord/hsCodeMapBySkuList?skuList=" + skuList);
  1723. //String result = HttpUtil.get("http://183.3.221.143:8080/oms-controller-mgt/pdProductRecord/hsCodeMapBySkuList?skuList=" + skuList);
  1724. //String result = HttpUtil.get("http://127.0.0.1:8080/oms-controller-mgt/pdProductRecord/hsCodeMapBySkuList?skuList=" + skuList);
  1725. Map<String,Map> map = JSON.parseObject(result, Map.class);
  1726. for (String sku : skuList) {
  1727. Map skuInfoMap = map.get(sku);
  1728. if (Objects.nonNull(skuInfoMap)){
  1729. String hsCodeName = (String) skuInfoMap.get("cusGoodsName");
  1730. String hsCode = (String) skuInfoMap.get("cusGoodsCode");
  1731. String prodName = (String) skuInfoMap.get("prodName");
  1732. String prodRecordName = (String) skuInfoMap.get("prodRecordName");
  1733. BigDecimal impConsumTaxRate = (BigDecimal) skuInfoMap.get("impConsumTaxRate");
  1734. BigDecimal valueAddedTaxRate = (BigDecimal) skuInfoMap.get("valueAddedTaxRate");
  1735. BigDecimal legalUnit1Qty = (BigDecimal) skuInfoMap.get("legalUnit1Qty");
  1736. BigDecimal legalUnit2Qty = (BigDecimal) skuInfoMap.get("legalUnit2Qty");
  1737. BigDecimal cosmThresholdValue = (BigDecimal) skuInfoMap.get("cosmThresholdValue");
  1738. if (StringUtils.isNotEmpty(hsCodeName) && StringUtils.isNotEmpty(hsCode)){
  1739. List<GoodsEntity> goodsEntityList = goodsDao.queryListBySku(sku);
  1740. if (Objects.nonNull(goodsEntityList) && goodsEntityList.size()>0){
  1741. for (GoodsEntity goodsEntity : goodsEntityList) {
  1742. goodsEntity.setHsCode(hsCode);
  1743. goodsEntity.setHsCodeName(hsCodeName);
  1744. goodsEntity.setImpConsumTaxRate(impConsumTaxRate);
  1745. goodsEntity.setValueAddedTaxRate(valueAddedTaxRate);
  1746. goodsEntity.setIsSyncHsCode("1");
  1747. goodsEntity.setLegalUnit1Qty(legalUnit1Qty);
  1748. goodsEntity.setProdName(prodName);
  1749. goodsEntity.setProdRecordName(prodRecordName);
  1750. goodsEntity.setLegalUnit2Qty(legalUnit2Qty);
  1751. goodsEntity.setCosmThresholdValue(cosmThresholdValue);
  1752. goodsDao.update(goodsEntity);
  1753. }
  1754. }
  1755. }
  1756. }
  1757. }
  1758. }
  1759. }
  1760. @Transactional
  1761. public void syncGoodsRate(List<GoodsEntity> allGoodsList) {
  1762. String storeId = "163"; // 市场部说所有门店价格一致,并且活动一致,可直接取其中一个门店价格进行计算税率
  1763. for (GoodsEntity goodsEntity : allGoodsList) {
  1764. // 同步过海关商品编码才可以算税率
  1765. if ("1".equals(goodsEntity.getIsSyncHsCode())) {
  1766. // Map<String, Object> goodsDetailMap = calculateGoodsDetail(goodsEntity.getProdBarcode(), storeId);
  1767. // if (Objects.nonNull(goodsDetailMap)) {
  1768. // GoodsDetailsDto goods = (GoodsDetailsDto) goodsDetailMap.get("goods");
  1769. // 顾客给的钱 就是税后价
  1770. // BigDecimal actualPaymentAmount = goods.getActualPaymentAmount(); //随便拿一个门店的当前时间的价格,如果有活动价会使用活动价
  1771. // BigDecimal calculateTax = CalculateTax.calculateTax(goodsEntity, actualPaymentAmount);// 税费
  1772. // BigDecimal goodsRate = calculateTax.divide(actualPaymentAmount, 4, BigDecimal.ROUND_HALF_UP);
  1773. BigDecimal goodsRate =CalculateTax.calculateGoodsRate(goodsEntity);
  1774. goodsEntity.setGoodsRate(goodsRate);
  1775. goodsEntity.setIsSyncHsCode("0");
  1776. goodsDao.update(goodsEntity);
  1777. // }
  1778. }
  1779. }
  1780. }
  1781. @Override
  1782. public void updateTaxErrorRecord(TaxErrorRecordEntity taxErrorRecordEntity) {
  1783. taxErrorRecordDao.update(taxErrorRecordEntity);
  1784. }
  1785. @Override
  1786. public void insertTaxErrorRecord(TaxErrorRecordEntity taxErrorRecordEntity) {
  1787. taxErrorRecordDao.save(taxErrorRecordEntity);
  1788. }
  1789. @Override
  1790. public void updateByEntity(GoodsEntity updateGoods) {
  1791. goodsDao.update(updateGoods);
  1792. }
  1793. @Override
  1794. public void checkGoodsPrice(SysUserEntity user) {
  1795. Map<String, BigDecimal> hsCodeMap = CalculateTax.hsCodeMap;
  1796. Set<String> hdCodeSet = hsCodeMap.keySet();
  1797. List<Map<String,String>> errorPriceSkuList = new LinkedList<>();
  1798. // 保存各种异常价格对象集合
  1799. List<ShopErrorPriceRecordEntity> shopErrorPriceRecordEntities = new LinkedList<>();
  1800. // 查询所有特殊化妆品的商品
  1801. List<GoodsEntity> queryGoodsDetails = goodsDao.querySpecialCosmetics(hdCodeSet);
  1802. for (GoodsEntity goodsEntity : queryGoodsDetails) {
  1803. calculateShopPrice(user,goodsEntity,errorPriceSkuList,shopErrorPriceRecordEntities);
  1804. calculateDailyPrice(user,goodsEntity,errorPriceSkuList,shopErrorPriceRecordEntities);
  1805. calculeatePromotion(user,goodsEntity,errorPriceSkuList,shopErrorPriceRecordEntities);
  1806. }
  1807. if(shopErrorPriceRecordEntities.size() != 0){
  1808. shopErrorPriceRecordService.saveBatch(shopErrorPriceRecordEntities);
  1809. }
  1810. }
  1811. @Override
  1812. public List<GoodsEntity> queryAllList(Integer page,Integer pageSize) {
  1813. return goodsDao.queryAllList(page,pageSize);
  1814. }
  1815. private void calculeatePromotion(SysUserEntity user, GoodsEntity goods, List<Map<String, String>> errorPriceSkuList, List<ShopErrorPriceRecordEntity> shopErrorPriceRecordEntities) {
  1816. String prodBarcode = goods.getProdBarcode();
  1817. String storeId = goods.getStoreId()+"";
  1818. SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1819. /**
  1820. * 2.查询当前时间,该门店是否有活动,如果有活动,查询开启了哪些营销方式
  1821. * 参数: 当前时间 门店id
  1822. */
  1823. MkActivitiesPromotionEntity promotionEntity = promotionService.queryByDateAndBarcode(storeId,format.format(new Date()),"lscx",prodBarcode);
  1824. // 如果该商品存在临时促销,直接替换活动价格
  1825. if(promotionEntity == null){
  1826. return ;
  1827. }
  1828. goods.setActualPaymentAmount(promotionEntity.getActivityPrice());
  1829. goods.setRetailPrice(promotionEntity.getActivityPrice());
  1830. goods.setActivity("临时促销");
  1831. try {
  1832. CalculateTax.calculateFinalTax(goods,goods.getActualPaymentAmount(),this).setScale(3,RoundingMode.HALF_UP);
  1833. } catch (Exception e) {
  1834. ShopErrorPriceRecordEntity shopErrorPriceRecordEntity = new ShopErrorPriceRecordEntity();
  1835. shopErrorPriceRecordEntity.setMerchSn(goods.getMerchSn());
  1836. shopErrorPriceRecordEntity.setThirdMerchSn(goods.getThirdPartyMerchCode());
  1837. shopErrorPriceRecordEntity.setShopSn(goods.getStoreId()+"");
  1838. shopErrorPriceRecordEntity.setPriceType(3); // 3 是临时促销
  1839. shopErrorPriceRecordEntity.setSku(goods.getSku());
  1840. shopErrorPriceRecordEntity.setBarcode(goods.getProdBarcode());
  1841. shopErrorPriceRecordEntity.setVerifier(user.getUserId()+"");
  1842. shopErrorPriceRecordEntity.setCheckTime(new Date());
  1843. shopErrorPriceRecordEntity.setCreaterSn(user.getUserId()+"");
  1844. shopErrorPriceRecordEntity.setCreateTime(new Date());
  1845. shopErrorPriceRecordEntity.setCurrentPrice(goods.getActualPaymentAmount().toString());
  1846. if(e.getMessage().contains("-")){
  1847. String suggestPrice = e.getMessage().split("-")[0];
  1848. String highestPrice = e.getMessage().split("-")[1];
  1849. String lowestPrice = e.getMessage().split("-")[2];
  1850. shopErrorPriceRecordEntity.setSuggestedPrice(suggestPrice);
  1851. shopErrorPriceRecordEntity.setLowestPrice(lowestPrice);
  1852. shopErrorPriceRecordEntity.setHighestPrice(highestPrice);
  1853. }
  1854. shopErrorPriceRecordEntity.setMkaId(promotionEntity.getMkaId());
  1855. shopErrorPriceRecordEntities.add(shopErrorPriceRecordEntity);
  1856. }
  1857. }
  1858. private void calculateDailyPrice(SysUserEntity user, GoodsEntity goods, List<Map<String, String>> errorPriceSkuList, List<ShopErrorPriceRecordEntity> shopErrorPriceRecordEntities) {
  1859. String prodBarcode = goods.getProdBarcode();
  1860. String storeId = goods.getStoreId()+"";
  1861. /**
  1862. * 2.查询当前时间,该门店是否有活动,如果有活动,查询开启了哪些营销方式
  1863. * 参数: 当前时间 门店id
  1864. */
  1865. SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1866. /**
  1867. * 日常活动跟着条形码走,优先级比临时促销低,但是高于正常价格
  1868. */
  1869. MkDailyActivitiesEntity dailyActivitiesEntity = dailyActivitiesService.queryByDateAndBarcode(storeId,format.format(new Date()),"rchd",prodBarcode);
  1870. if(dailyActivitiesEntity == null){
  1871. return ;
  1872. }
  1873. goods.setActualPaymentAmount(dailyActivitiesEntity.getActivityPrice());
  1874. goods.setRetailPrice(dailyActivitiesEntity.getActivityPrice());
  1875. goods.setActivity("日常活动");
  1876. // 计算税费
  1877. try {
  1878. CalculateTax.calculateFinalTax(goods,goods.getActualPaymentAmount(),this).setScale(3,RoundingMode.HALF_UP);
  1879. } catch (Exception e) {
  1880. // 记录有异常的sku
  1881. ShopErrorPriceRecordEntity shopErrorPriceRecordEntity = new ShopErrorPriceRecordEntity();
  1882. shopErrorPriceRecordEntity.setMerchSn(goods.getMerchSn());
  1883. shopErrorPriceRecordEntity.setThirdMerchSn(goods.getThirdPartyMerchCode());
  1884. shopErrorPriceRecordEntity.setShopSn(goods.getStoreId()+"");
  1885. shopErrorPriceRecordEntity.setPriceType(2); // 2 是日常活动
  1886. shopErrorPriceRecordEntity.setSku(goods.getSku());
  1887. shopErrorPriceRecordEntity.setBarcode(goods.getProdBarcode());
  1888. shopErrorPriceRecordEntity.setVerifier(user.getUserId()+"");
  1889. shopErrorPriceRecordEntity.setCheckTime(new Date());
  1890. shopErrorPriceRecordEntity.setCreaterSn(user.getUserId()+"");
  1891. shopErrorPriceRecordEntity.setCreateTime(new Date());
  1892. shopErrorPriceRecordEntity.setCurrentPrice(goods.getActualPaymentAmount().toString());
  1893. if(e.getMessage().contains("-")){
  1894. String suggestPrice = e.getMessage().split("-")[0];
  1895. String highestPrice = e.getMessage().split("-")[1];
  1896. String lowestPrice = e.getMessage().split("-")[2];
  1897. shopErrorPriceRecordEntity.setSuggestedPrice(suggestPrice);
  1898. shopErrorPriceRecordEntity.setLowestPrice(lowestPrice);
  1899. shopErrorPriceRecordEntity.setHighestPrice(highestPrice);
  1900. }
  1901. shopErrorPriceRecordEntity.setMkaId(dailyActivitiesEntity.getMkaId());
  1902. shopErrorPriceRecordEntities.add(shopErrorPriceRecordEntity);
  1903. }
  1904. }
  1905. private void calculateShopPrice(SysUserEntity user, GoodsEntity goods, List<Map<String, String>> errorPriceSkuList, List<ShopErrorPriceRecordEntity> shopErrorPriceRecordEntities) {
  1906. goods.setDiscountedPrice(new BigDecimal(0));
  1907. BigDecimal retailPrice = goods.getRetailPrice();
  1908. goods.setActualPaymentAmount(retailPrice.setScale(2,RoundingMode.HALF_UP));
  1909. // 计算税费
  1910. try {
  1911. CalculateTax.calculateFinalTax(goods,goods.getActualPaymentAmount(),this).setScale(3,RoundingMode.HALF_UP);
  1912. } catch (Exception e) {
  1913. // 记录有异常的sku
  1914. ShopErrorPriceRecordEntity shopErrorPriceRecordEntity = new ShopErrorPriceRecordEntity();
  1915. shopErrorPriceRecordEntity.setMerchSn(goods.getMerchSn());
  1916. shopErrorPriceRecordEntity.setThirdMerchSn(goods.getThirdPartyMerchCode());
  1917. shopErrorPriceRecordEntity.setShopSn(goods.getStoreId()+"");
  1918. shopErrorPriceRecordEntity.setPriceType(1); // 1 门店商品价格
  1919. shopErrorPriceRecordEntity.setSku(goods.getSku());
  1920. shopErrorPriceRecordEntity.setBarcode(goods.getProdBarcode());
  1921. shopErrorPriceRecordEntity.setVerifier(user.getUserId()+"");
  1922. shopErrorPriceRecordEntity.setCheckTime(new Date());
  1923. shopErrorPriceRecordEntity.setCreaterSn(user.getUserId()+"");
  1924. shopErrorPriceRecordEntity.setCreateTime(new Date());
  1925. shopErrorPriceRecordEntity.setCurrentPrice(goods.getActualPaymentAmount().toString());
  1926. if(e.getMessage().contains("-")){
  1927. String suggestPrice = e.getMessage().split("-")[0];
  1928. String highestPrice = e.getMessage().split("-")[1];
  1929. String lowestPrice = e.getMessage().split("-")[2];
  1930. shopErrorPriceRecordEntity.setSuggestedPrice(suggestPrice);
  1931. shopErrorPriceRecordEntity.setLowestPrice(lowestPrice);
  1932. shopErrorPriceRecordEntity.setHighestPrice(highestPrice);
  1933. }
  1934. shopErrorPriceRecordEntities.add(shopErrorPriceRecordEntity);
  1935. }
  1936. }
  1937. /**
  1938. * 根据产品条码和sku查询保税展示补货的商品
  1939. *
  1940. * @param prodBarcode 商品条码
  1941. * @param sku sku
  1942. * @return 商品信息
  1943. */
  1944. @Override
  1945. public GoodsEntity queryGoodsInfoByProductBarcodeAndSku(String prodBarcode, String sku) {
  1946. return goodsDao.queryGoodsInfoByProductBarcodeAndSku(prodBarcode, sku);
  1947. }
  1948. @Override
  1949. public int updateStockNumberByProductCodeAndSku(GoodsEntity goodsEntity) {
  1950. return goodsDao.updateStockNumberByProductCodeAndSku(goodsEntity);
  1951. }
  1952. }