diff --git a/bweb/src/main/java/com/bweb/controller/TestController.java b/bweb/src/main/java/com/bweb/controller/TestController.java index cb3a1ec..f1c1de6 100644 --- a/bweb/src/main/java/com/bweb/controller/TestController.java +++ b/bweb/src/main/java/com/bweb/controller/TestController.java @@ -143,19 +143,7 @@ public class TestController { } } - @RequestMapping(value="/querySkuByPage",method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "querySkuByPage") - public ResponseData querySkuByPage() { - try { - return ResponseMsgUtil.success(JdPostService.querySkuByPage(jdService.getToken() , "7028" , 0).getOpenRpcResult().getResult().getSkus()); - - } catch (Exception e) { - log.error("error!",e); - return ResponseMsgUtil.exception(e); - } - } @RequestMapping(value="/getSkuDetailInfo",method = RequestMethod.GET) @ResponseBody diff --git a/bweb/src/main/java/com/bweb/controller/goods/GoodsController.java b/bweb/src/main/java/com/bweb/controller/goods/GoodsController.java index 0206c5e..bb6934f 100644 --- a/bweb/src/main/java/com/bweb/controller/goods/GoodsController.java +++ b/bweb/src/main/java/com/bweb/controller/goods/GoodsController.java @@ -1,5 +1,6 @@ package com.bweb.controller.goods; +import com.alibaba.excel.EasyExcel; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.hfkj.common.exception.ErrorCode; @@ -7,15 +8,24 @@ import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; import com.hfkj.common.security.SessionObject; import com.hfkj.common.security.UserCenter; +import com.hfkj.common.utils.DateUtil; import com.hfkj.common.utils.OrderUtil; import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.config.CommonSysConst; import com.hfkj.entity.*; import com.hfkj.model.goods.GoodsModelSpecs; import com.hfkj.model.ResponseData; import com.hfkj.model.SecUserSessionObject; +import com.hfkj.model.goods.JdGoodsModel; +import com.hfkj.model.order.orderExport.OrderGoodsExportModel; import com.hfkj.service.audit.AuditMsgService; +import com.hfkj.service.file.FileRecordsService; import com.hfkj.service.goods.*; import com.hfkj.sysenum.SecUserObjectTypeEnum; +import com.hfkj.sysenum.fileRecords.FileRecordsEnum; +import com.hfkj.sysenum.order.OrderChildStatusEnum; +import com.hfkj.sysenum.order.OrderPayChannelEnum; +import com.hfkj.sysenum.order.OrderPayTypeEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; @@ -27,7 +37,12 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.io.File; +import java.math.BigDecimal; import java.util.*; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; @Controller @RequestMapping(value="/goods") @@ -63,6 +78,10 @@ public class GoodsController { @Resource private GoodsJumpService goodsJumpService; + + @Resource + private FileRecordsService fileRecordsService; + @RequestMapping(value="/editGoodsMsg",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "编辑商品信息") @@ -500,5 +519,143 @@ public class GoodsController { } } + @RequestMapping(value="/getJdGoodsList",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询京东商品") + public ResponseData getJdGoodsList(@RequestParam(value = "title" , required = false) String title, + @RequestParam(value = "goodsType" , required = false) Long goodsType, + @RequestParam(value = "goodsBrand" , required = false) Integer goodsBrand, + @RequestParam(value = "salePriceS" , required = false) BigDecimal salePriceS, + @RequestParam(value = "salePriceE" , required = false) BigDecimal salePriceE, + @RequestParam(value = "pageNum" , required = true) Integer pageNum, + @RequestParam(value = "pageSize" , required = true) Integer pageSize) { + try { + Map param = new HashMap<>(); + if (goodsType != null) { + GoodsType goodsType1 = goodsTypeService.queryDetail(goodsType); + + if (goodsType1.getParentId() == null) { + param.put("goodsTypeParent", goodsType); + } else { + param.put("goodsType", goodsType); + } + } + param.put("title", title); + param.put("goodsBrand", goodsBrand); + param.put("salePriceS", salePriceS); + param.put("salePriceE", salePriceE); + + PageHelper.startPage(pageNum, pageSize); + return ResponseMsgUtil.success(new PageInfo<>(goodsMsgService.getJdGoodsList(param))); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/exportJdGoods",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "导出京东商品") + public ResponseData exportJdGoods(@RequestParam(value = "title" , required = false) String title, + @RequestParam(value = "goodsType" , required = false) Long goodsType, + @RequestParam(value = "goodsBrand" , required = false) Integer goodsBrand, + @RequestParam(value = "salePriceS" , required = false) BigDecimal salePriceS, + @RequestParam(value = "salePriceE" , required = false) BigDecimal salePriceE, HttpServletRequest request) { + // 插入下载记录 + FileRecords fileRecords = new FileRecords(); + try { + + SessionObject sessionObject = userCenter.getSessionObject(request); + SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject(); + + Map map = new HashMap<>(); + if (goodsType != null) { + GoodsType goodsType1 = goodsTypeService.queryDetail(goodsType); + + if (goodsType1.getParentId() == null) { + map.put("goodsTypeParent", goodsType); + } else { + map.put("goodsType", goodsType); + } + } + map.put("title", title); + map.put("goodsBrand", goodsBrand); + map.put("salePriceS", salePriceS); + map.put("salePriceE", salePriceE); + String dataSting = ""; + dataSting = DateUtil.date2String(new Date(), DateUtil.YMDHMS); + + String fileUrl = CommonSysConst.getSysConfig().getFileUrl(); + String filePath = "/temporary/" + userModel.getAccount().getId() + "/" ; + String pathName = filePath + FileRecordsEnum.status13.getName() + "导出" + dataSting +".xlsx"; + + if (fileRecordsService.findExported(map.toString() , userModel.getAccount().getId())) { + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "相同导出内容请勿重复点击!"); + } + + fileRecords.setCreateTime(new Date()); + fileRecords.setBusinessType(FileRecordsEnum.status13.getCode()); + fileRecords.setDownloadConditions(map.toString()); + fileRecords.setOpId(userModel.getAccount().getId()); + fileRecords.setOpName(userModel.getAccount().getUserName()); + fileRecords.setStatus(2); + fileRecords.setDownloadStatus(2); + fileRecords.setFileUrl(CommonSysConst.getSysConfig().getDomainName() + "/filesystem" + pathName); + fileRecords.setType("2"); + fileRecords.setTitle(FileRecordsEnum.status13.getName() + "导出" + dataSting + ".xls"); + fileRecordsService.create(fileRecords); + + // 创建线程 + ThreadPoolExecutor executor = new ThreadPoolExecutor( + 2, // 核心线程数 + 5, // 最大线程数 + 1, // 线程空闲时间 + TimeUnit.MINUTES, // 时间单位 + new ArrayBlockingQueue<>(5), // 任务队列 + new ThreadPoolExecutor.CallerRunsPolicy() // 拒绝策略 + ); + + // 提交任务给线程池 + executor.execute(() -> { + + try { + + List jdGoodsModels = goodsMsgService.getJdGoodsList(map); + + File file = new File(fileUrl + filePath); + if (!file.exists()) { + file.mkdirs(); + } + + EasyExcel.write(fileUrl+pathName) + .head(JdGoodsModel.class) + .sheet(fileRecords.getTitle()) + .doWrite(jdGoodsModels); + + fileRecords.setStatus(1); + fileRecords.setUpdateTime(new Date()); + fileRecordsService.update(fileRecords); + } catch (Exception e) { + fileRecords.setStatus(3); + fileRecords.setUpdateTime(new Date()); + fileRecords.setExt1(e.toString()); + fileRecordsService.update(fileRecords); + log.error("error!",e); + } + }); + + // 关闭线程池 + executor.shutdown(); + return ResponseMsgUtil.success(fileRecords); + + } catch (Exception e) { + fileRecords.setStatus(3); + fileRecords.setUpdateTime(new Date()); + fileRecordsService.update(fileRecords); + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } } diff --git a/cweb/src/main/java/com/cweb/controller/cms/CmsContentController.java b/cweb/src/main/java/com/cweb/controller/cms/CmsContentController.java index 0fb2eb9..0c39096 100644 --- a/cweb/src/main/java/com/cweb/controller/cms/CmsContentController.java +++ b/cweb/src/main/java/com/cweb/controller/cms/CmsContentController.java @@ -60,8 +60,6 @@ public class CmsContentController { map.put("status", 1); map.put("platformCode", platformCode); List list = cmsContentService.getList(map); - List goodsMsgList = goodsMsgService.getList(new HashMap<>()); - List specsList = goodsSpecsService.getList(new HashMap<>()); List cmsContents = new ArrayList<>(); @@ -69,23 +67,30 @@ public class CmsContentController { List goodsModels = new ArrayList<>(); if (cmsContent.getShowType() != null) { + Map goodsMap = new HashMap<>(); + List goodsMsgs = new ArrayList<>(); if (cmsContent.getShowType() == 1) { - goodsMsgs = goodsMsgList.stream().filter(s -> s.getGoodsType().equals(cmsContent.getShowDataId().longValue())).limit(2).collect(Collectors.toList()); + goodsMap.put("goodsType", cmsContent.getShowDataId()); + goodsMsgs = goodsMsgService.getList(goodsMap).stream().limit(2).collect(Collectors.toList()); } if (cmsContent.getShowType() == 2) { - goodsMsgs = goodsMsgList.stream().filter(s -> s.getGoodsType().equals(cmsContent.getShowDataId().longValue())).limit(4).collect(Collectors.toList()); + goodsMap.put("goodsType", cmsContent.getShowDataId()); + goodsMsgs = goodsMsgService.getList(goodsMap).stream().limit(4).collect(Collectors.toList()); } if (cmsContent.getShowType() == 3) { - goodsMsgs = goodsMsgList.stream().filter(s -> s.getGoodsType().equals(cmsContent.getShowDataId().longValue())).limit(10).collect(Collectors.toList()); + goodsMap.put("goodsType", cmsContent.getShowDataId()); + goodsMsgs = goodsMsgService.getList(goodsMap).stream().limit(10).collect(Collectors.toList()); } for (GoodsMsg goodsMsg : goodsMsgs) { GoodsModel goodsModel = new GoodsModel(); - List goodsSpecs = specsList.stream().filter(s -> s.getGoodsId().equals(goodsMsg.getId())).collect(Collectors.toList()); + Map specMap = new HashMap<>(); + specMap.put("goodsId", goodsMsg.getId()); + List goodsSpecs = goodsSpecsService.getList(specMap); if (!goodsSpecs.isEmpty()) { BigDecimal minPrice = goodsSpecs.get(0).getSalePrice(); diff --git a/cweb/src/main/java/com/cweb/controller/goods/DeliveryAddressController.java b/cweb/src/main/java/com/cweb/controller/goods/DeliveryAddressController.java index 72854c1..b5d225f 100644 --- a/cweb/src/main/java/com/cweb/controller/goods/DeliveryAddressController.java +++ b/cweb/src/main/java/com/cweb/controller/goods/DeliveryAddressController.java @@ -53,6 +53,7 @@ public class DeliveryAddressController { Map map = new HashMap<>(); map.put("userId", userSession.getUser().getId()); + map.put("status", 1); return ResponseMsgUtil.success(deliveryAddressService.getList(map)); @@ -75,6 +76,7 @@ public class DeliveryAddressController { Map map = new HashMap<>(); map.put("userId", userSession.getUser().getId()); + map.put("status", 1); List list = deliveryAddressService.getList(map); if (list.isEmpty()) { @@ -238,6 +240,7 @@ public class DeliveryAddressController { Map map = new HashMap<>(); map.put("userId" , userSession.getUser().getId()); + map.put("status", 1); map.put("whetherDefault" , true); GoodsUserAddress userAddress = goodsUserAddressService.queryDetailByMap(map); diff --git a/cweb/src/main/java/com/cweb/controller/goods/GoodsController.java b/cweb/src/main/java/com/cweb/controller/goods/GoodsController.java index ebd2a18..eefcc10 100644 --- a/cweb/src/main/java/com/cweb/controller/goods/GoodsController.java +++ b/cweb/src/main/java/com/cweb/controller/goods/GoodsController.java @@ -14,6 +14,7 @@ import com.hfkj.entity.GoodsMsg; import com.hfkj.entity.GoodsSpecs; import com.hfkj.entity.GoodsType; import com.hfkj.entity.GoodsVpd; +import com.hfkj.jd.JdService; import com.hfkj.model.ResponseData; import com.hfkj.model.SecUserSessionObject; import com.hfkj.model.goods.GoodsModel; @@ -59,6 +60,10 @@ public class GoodsController { private GoodsVpdService goodsVpdService; + @Resource + private JdService jdService; + + @RequestMapping(value="/getListGoodsType",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询商品分类列表") @@ -112,6 +117,7 @@ public class GoodsController { @RequestParam(value = "goodsBrand", required = false) Long goodsBrand, @RequestParam(value = "price", required = false) Integer price, @RequestParam(value = "saleNum", required = false) Integer saleNum, + @RequestParam(value = "limit", required = false) Integer limit, @RequestParam(value = "time", required = false) Integer time, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize @@ -126,11 +132,12 @@ public class GoodsController { map.put("goodsTypeParent", goodsTypeParent); map.put("goodsBrand", goodsBrand); map.put("saleNum", saleNum); + map.put("limit", limit); map.put("time", time); map.put("status", 1); - List list = goodsMsgService.getList(map); - List specsList = goodsSpecsService.getList(new HashMap<>()); + List list = goodsMsgService.getListCrest(map); + List specsList = goodsSpecsService.getGoodsSpecsCrest(); List goodsModels = new ArrayList<>(); @@ -153,9 +160,7 @@ public class GoodsController { BeanUtils.copyProperties(goodsMsg, goodsModel); goodsModel.setOriginalPrice(minOriginalPrice); goodsModel.setPrice(minPrice); - goodsModels.add(goodsModel); - } } @@ -186,7 +191,11 @@ public class GoodsController { GoodsMsg goodsMsg = goodsMsgService.queryDetail(id); - + if (goodsMsg != null && goodsMsg.getThirdId() != null) { + if (jdService.checkSkuSale(goodsMsg)) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.SOLD_OUT, ""); + } + } GoodsModel goodsModel = new GoodsModel(); @@ -204,9 +213,6 @@ public class GoodsController { BeanUtils.copyProperties(goodsSpec, goodsModelSpec); GoodsVpd goodsVpd = goodsVpdService.queryDetailBySpecsId(goodsSpec.getId()); if (goodsVpd != null) { - - - BeanUtils.copyProperties(goodsVpd, goodsModelSpec); } goodsModelSpec.setSpecsId(goodsSpec.getId()); diff --git a/cweb/src/main/java/com/cweb/controller/goods/ShoppingCartController.java b/cweb/src/main/java/com/cweb/controller/goods/ShoppingCartController.java index a444865..b1db22e 100644 --- a/cweb/src/main/java/com/cweb/controller/goods/ShoppingCartController.java +++ b/cweb/src/main/java/com/cweb/controller/goods/ShoppingCartController.java @@ -9,6 +9,7 @@ import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.entity.GoodsMsg; import com.hfkj.entity.GoodsShoppingCart; import com.hfkj.entity.GoodsSpecs; +import com.hfkj.jd.JdService; import com.hfkj.model.ResponseData; import com.hfkj.model.UserSessionObject; import com.hfkj.service.goods.GoodsMsgService; @@ -45,6 +46,9 @@ public class ShoppingCartController { @Resource private GoodsShoppingCartService shoppingCartService; + @Resource + private JdService jdService; + @RequestMapping(value = "/getShoppingCartList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询购物车列表") @@ -60,6 +64,24 @@ public class ShoppingCartController { List list = shoppingCartService.getList(map); + + for (GoodsShoppingCart shoppingCart : list) { + GoodsMsg goodsMsg = goodsMsgService.queryDetail(shoppingCart.getGoodsId()); + GoodsSpecs goodsSpecs = goodsSpecsService.queryDetailByGoodsId(shoppingCart.getSpecsId()); + + if (goodsMsg.getStatus().equals(0)) { + shoppingCart.setLoseEfficacy(true); + } + if (goodsSpecs.getStatus().equals(0)) { + shoppingCart.setLoseEfficacy(true); + } + if (jdService.checkSkuSale(goodsMsg)) { + shoppingCart.setLoseEfficacy(true); + } + shoppingCart.setUpdateTime(new Date()); + shoppingCartService.update(shoppingCart); + } + Map> collect = list.stream().collect(Collectors.groupingBy(GoodsShoppingCart::getMerName)); List countRecords = collect.keySet().stream().map(key -> { diff --git a/order/src/main/java/com/order/controller/notify/JdNotify.java b/order/src/main/java/com/order/controller/notify/JdNotify.java index 41cd47b..e2e0a86 100644 --- a/order/src/main/java/com/order/controller/notify/JdNotify.java +++ b/order/src/main/java/com/order/controller/notify/JdNotify.java @@ -43,7 +43,7 @@ public class JdNotify { JSONObject jsonObject = HttpsUtils.doGet("https://open-oauth.jd.com/oauth2/access_token", object); log.info("token回调 jsonObject-回调参数: " + jsonObject); log.info("token回调 access_token-回调参数: " + jsonObject.getString("access_token")); - redisUtil.set("access_token", jsonObject.getString("access_token") , jsonObject.getInteger("expires_in") - 10000); + redisUtil.set("jd_access_token", jsonObject.getString("access_token") , jsonObject.getInteger("expires_in") - 10000); log.info("============token回调任务End============="); } catch (Exception e) { diff --git a/service/src/main/java/com/hfkj/common/exception/ErrorCode.java b/service/src/main/java/com/hfkj/common/exception/ErrorCode.java index 8d3a267..7b88650 100644 --- a/service/src/main/java/com/hfkj/common/exception/ErrorCode.java +++ b/service/src/main/java/com/hfkj/common/exception/ErrorCode.java @@ -31,6 +31,7 @@ public enum ErrorCode { REQUEST_TIMED_OUT("2006","请求超时,请稍后重试"), UNKNOW_ERROR("999999","未知异常"), EXCEL_ERROR("80000","Excel处理异常"), + SOLD_OUT("3000","商品已售空,请购买其他商品!"), ;//注意:上面为逗号,此次为分号 diff --git a/service/src/main/java/com/hfkj/dao/GoodsMsgMapperExt.java b/service/src/main/java/com/hfkj/dao/GoodsMsgMapperExt.java index 48b083f..0663266 100644 --- a/service/src/main/java/com/hfkj/dao/GoodsMsgMapperExt.java +++ b/service/src/main/java/com/hfkj/dao/GoodsMsgMapperExt.java @@ -1,7 +1,62 @@ package com.hfkj.dao; +import com.hfkj.entity.GoodsMsg; +import com.hfkj.model.goods.JdGoodsModel; +import com.hfkj.model.order.OrderCouponModel; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; +import java.util.Map; + /** * mapper扩展类 */ public interface GoodsMsgMapperExt { + + + @Select("") + List getJdGoodsList(@Param("param") Map param); + + @Select("") + List getGoodsListCrest(@Param("param") Map param); + } \ No newline at end of file diff --git a/service/src/main/java/com/hfkj/dao/GoodsSpecsMapperExt.java b/service/src/main/java/com/hfkj/dao/GoodsSpecsMapperExt.java index eb9e336..b7a09c9 100644 --- a/service/src/main/java/com/hfkj/dao/GoodsSpecsMapperExt.java +++ b/service/src/main/java/com/hfkj/dao/GoodsSpecsMapperExt.java @@ -1,7 +1,27 @@ package com.hfkj.dao; +import com.hfkj.entity.GoodsMsg; +import com.hfkj.entity.GoodsSpecs; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; +import java.util.Map; + /** * mapper扩展类 */ public interface GoodsSpecsMapperExt { + + + + @Select("") + List getGoodsSpecsCrest(); } \ No newline at end of file diff --git a/service/src/main/java/com/hfkj/jd/Impl/JdServiceImpl.java b/service/src/main/java/com/hfkj/jd/Impl/JdServiceImpl.java index 33dabf2..30504e7 100644 --- a/service/src/main/java/com/hfkj/jd/Impl/JdServiceImpl.java +++ b/service/src/main/java/com/hfkj/jd/Impl/JdServiceImpl.java @@ -1,6 +1,7 @@ package com.hfkj.jd.Impl; import com.hfkj.common.utils.RedisUtil; +import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.entity.*; import com.hfkj.jd.JdPostService; import com.hfkj.jd.JdService; @@ -14,6 +15,7 @@ import com.jd.open.api.sdk.domain.vopsp.SkuInfoGoodsProvider.response.getSkuDeta import com.jd.open.api.sdk.domain.vopsp.SkuInfoGoodsProvider.response.getSkuImageList.GetSkuImageGoodsResp; import com.jd.open.api.sdk.domain.vopsp.SkuInfoGoodsProvider.response.getSkuImageList.SkuImageItemGoodsResp; import com.jd.open.api.sdk.domain.vopsp.SkuPoolGoodsProvider.response.getSkuPoolInfo.GetSkuPoolInfoItemGoodsResp; +import com.jd.open.api.sdk.domain.vopsp.SkuPoolGoodsProvider.response.querySkuByPage.OpenPagingResult; import com.jd.open.api.sdk.response.vopsp.VopGoodsGetSkuDetailInfoResponse; import com.jd.open.api.sdk.response.vopsp.VopGoodsGetSkuImageListResponse; import com.jd.open.api.sdk.response.vopsp.VopGoodsGetSkuPoolInfoResponse; @@ -24,10 +26,11 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; import java.math.RoundingMode; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; @Service("jdService") @@ -54,9 +57,11 @@ public class JdServiceImpl implements JdService { @Resource private GoodsSpecsService goodsSpecsService; + private List skuList = new ArrayList<>(); + @Override public String getToken() throws Exception { - Object token = redisUtil.get("access_token"); + Object token = redisUtil.get("jd_access_token"); if (token == null) { // 请求回调 会在回调存入参数 @@ -68,10 +73,16 @@ public class JdServiceImpl implements JdService { @Override public void getGoodsJd() throws Exception { + String token = getToken(); // 获取京东商品池 - VopGoodsGetSkuPoolInfoResponse sku = JdPostService.getSkuPoolInfo(getToken()); + VopGoodsGetSkuPoolInfoResponse sku = JdPostService.getSkuPoolInfo(token); // 获取sku列表 List skuList = sku.getOpenRpcResult().getResult().getSkuPoolList(); +// List skuIdList; +// for (GetSkuPoolInfoItemGoodsResp skuPoolInfoItemGoodsResp : skuList) { +// skuIdList = getSkuList(token , skuPoolInfoItemGoodsResp.getBizPoolId() , 0L); +// } +// BsMer bsMer = bsMerService.getDetail("166241009282"); // 初始化商品信息 GoodsMsg goodsMsg; @@ -88,33 +99,33 @@ public class JdServiceImpl implements JdService { List goodsMsgs = goodsMsgService.getList(goodsMap); List goodsSpecsList = goodsSpecsService.getList(new HashMap<>()); BsProductConfig productConfig = productConfigService.queryDetail(OrderChildProductTypeEnum.type6.getCode()); - + List skuIdList; for (GetSkuPoolInfoItemGoodsResp skuPoolInfoItemGoodsResp : skuList) { - // 根据sku查询商品 - List skuIdList = JdPostService.querySkuByPage(getToken(), skuPoolInfoItemGoodsResp.getBizPoolId(), 0).getOpenRpcResult().getResult().getSkus(); + skuIdList = getSkuList(token , skuPoolInfoItemGoodsResp.getBizPoolId() , 0L); + for (Long aLong : skuIdList) { // 根据skuId 查询商品详情 - VopGoodsGetSkuDetailInfoResponse skuDetail = JdPostService.getSkuDetailInfo(getToken(), aLong); + VopGoodsGetSkuDetailInfoResponse skuDetail = JdPostService.getSkuDetailInfo(token, aLong); GetSkuPoolInfoGoodsResp detail = skuDetail.getOpenRpcResult().getResult(); if (detail != null) { // 根据skuId 查询商品售价 - OpenRpcResult priceResponse = JdPostService.getSellPrice(getToken(), String.valueOf(aLong)).getOpenRpcResult(); + OpenRpcResult priceResponse = JdPostService.getSellPrice(token, String.valueOf(aLong)).getOpenRpcResult(); if (priceResponse.getSuccess()) { GetSellPriceGoodsResp price = priceResponse.getResult().get(0); // 根据skuId 查询商品图片 - com.jd.open.api.sdk.domain.vopsp.SkuInfoGoodsProvider.response.getSkuImageList.OpenRpcResult imageListResponse = JdPostService.getSkuImageList(getToken(), String.valueOf(aLong)).getOpenRpcResult(); + com.jd.open.api.sdk.domain.vopsp.SkuInfoGoodsProvider.response.getSkuImageList.OpenRpcResult imageListResponse = JdPostService.getSkuImageList(token, String.valueOf(aLong)).getOpenRpcResult(); if (imageListResponse.getSuccess()) { GetSkuImageGoodsResp img = imageListResponse.getResult().get(0); // 查询分类 String[] categoryS = detail.getCategory().split(";"); // 查询一级分类 - String category1 = JdPostService.getCategoryInfoList(getToken(), categoryS[0]).getOpenRpcResult().getResult().get(0).getCategoryName(); + String category1 = JdPostService.getCategoryInfoList(token, categoryS[0]).getOpenRpcResult().getResult().get(0).getCategoryName(); // 查询二级分类 - String category2 = JdPostService.getCategoryInfoList(getToken(), categoryS[1]).getOpenRpcResult().getResult().get(0).getCategoryName(); + String category2 = JdPostService.getCategoryInfoList(token, categoryS[1]).getOpenRpcResult().getResult().get(0).getCategoryName(); GoodsType goodsType1 = goodsType.stream().filter(s -> s.getTitle().equals(category1)).findFirst().orElse(null); GoodsType goodsType2 = goodsType.stream().filter(s -> s.getTitle().equals(category2)).findFirst().orElse(null); @@ -266,9 +277,12 @@ public class JdServiceImpl implements JdService { goodsSpecs.setSalePrice(profitPrice.add(price.getSalePrice())); // 设置原价 goodsSpecs.setOriginalPrice(price.getMarketPrice()); + goodsSpecs.setThirdPrice(price.getJdPrice()); // 设置展示图片 goodsSpecs.setShowImg(goodsMsg.getListImg()); + goodsSpecsList = goodsSpecsList.stream().filter(s-> s.getThirdId() != null).collect(Collectors.toList()); + GoodsSpecs specs = goodsSpecsList.stream().filter(s -> s.getThirdId().equals(aLong.toString())).findFirst().orElse(null); if (specs != null) { @@ -291,6 +305,14 @@ public class JdServiceImpl implements JdService { } } + private List getSkuList(String token , String bizPoolId , Long offset) throws Exception { + OpenPagingResult result = JdPostService.querySkuByPage(token, bizPoolId, offset).getOpenRpcResult().getResult(); + skuList.addAll(result.getSkus()); + if (result.getRemainPage() > 0) { + getSkuList(token, bizPoolId, result.getOffset()); + } + return skuList; + } @Override public Boolean checkSkuSale(GoodsMsg goodsMsg) throws Exception { @@ -299,8 +321,25 @@ public class JdServiceImpl implements JdService { VopGoodsGetSkuStateListResponse skuStateListResponse = JdPostService.getSkuState(getToken(), goodsMsg.getThirdId()); if (skuStateListResponse.getOpenRpcResult().getResult().get(0).getSkuState() == 0) { + // 创建线程 + ThreadPoolExecutor executor = new ThreadPoolExecutor( + 2, // 核心线程数 + 5, // 最大线程数 + 1, // 线程空闲时间 + TimeUnit.MINUTES, // 时间单位 + new ArrayBlockingQueue<>(5), // 任务队列 + new ThreadPoolExecutor.CallerRunsPolicy() // 拒绝策略 + ); + // 提交任务给线程池 + executor.execute(() -> { + goodsMsg.setStatus(0); + goodsMsgService.update(goodsMsg); + }); + // 关闭线程池 + executor.shutdown(); return true; } + BsProductConfig productConfig = productConfigService.queryDetail(OrderChildProductTypeEnum.type6.getCode()); // 查询规格 GoodsSpecs specs = goodsSpecsService.queryDetailByThirdId(goodsMsg.getThirdId()); @@ -310,6 +349,18 @@ public class JdServiceImpl implements JdService { GetSkuPoolInfoGoodsResp detail = skuDetail.getOpenRpcResult().getResult(); // 根据skuId 查询商品售价 OpenRpcResult priceResponse = JdPostService.getSellPrice(getToken(), String.valueOf(goodsMsg.getThirdId())).getOpenRpcResult(); - return null; + GetSellPriceGoodsResp price = priceResponse.getResult().get(0); + // 设置商品名称 + specs.setName(detail.getSpuName()); + BigDecimal profitPrice = price.getSalePrice().multiply(productConfig.getDiscount().divide(new BigDecimal(100) , 2, RoundingMode.HALF_UP)); + // 设置销售价格 + specs.setSalePrice(profitPrice.add(price.getSalePrice())); + // 设置原价 + specs.setOriginalPrice(price.getMarketPrice()); + specs.setThirdPrice(price.getJdPrice()); + // 设置展示图片 + specs.setShowImg(goodsMsg.getListImg()); + goodsSpecsService.update(specs); + return false; } } diff --git a/service/src/main/java/com/hfkj/jd/JdPostService.java b/service/src/main/java/com/hfkj/jd/JdPostService.java index 5d0f362..ac65870 100644 --- a/service/src/main/java/com/hfkj/jd/JdPostService.java +++ b/service/src/main/java/com/hfkj/jd/JdPostService.java @@ -122,12 +122,12 @@ public class JdPostService { } // 根据商品池获取所有商品信息 - public static VopGoodsQuerySkuByPageResponse querySkuByPage(String token , String bizPoolId , Integer offset) throws Exception { + public static VopGoodsQuerySkuByPageResponse querySkuByPage(String token , String bizPoolId , Long offset) throws Exception { JdClient client=new DefaultJdClient(SERVER_URL,token,CommonSysConst.getSysConfig().getJDAppKey(),CommonSysConst.getSysConfig().getJDAppSecret()); VopGoodsQuerySkuByPageRequest request=new VopGoodsQuerySkuByPageRequest(); request.setBizPoolId(bizPoolId); request.setOffset(offset); - request.setPageSize(10); + request.setPageSize(1000); return client.execute(request); } diff --git a/service/src/main/java/com/hfkj/model/goods/JdGoodsModel.java b/service/src/main/java/com/hfkj/model/goods/JdGoodsModel.java new file mode 100644 index 0000000..f386744 --- /dev/null +++ b/service/src/main/java/com/hfkj/model/goods/JdGoodsModel.java @@ -0,0 +1,58 @@ +package com.hfkj.model.goods; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @ClassName JdGoodsModel + * @Author Sum1Dream + * @Description 京东商品 + * @Date 2024/9/29 上午10:50 + **/ +@Data +public class JdGoodsModel { + + @ColumnWidth(50) + @ExcelProperty("一级分类") + public String goodsTypeParentName; + + @ColumnWidth(20) + @ExcelProperty("二级分类") + public String goodsTypeName; + + @ColumnWidth(20) + @ExcelProperty("品牌名称") + public String goodsBrandName; + + @ColumnWidth(20) + @ExcelProperty("商品名称") + public String title; + + @ColumnWidth(40) + @ExcelProperty("列表图") + public String listImg; + + @ColumnWidth(15) + @ExcelProperty("售卖价格") + public BigDecimal salePrice; + + @ColumnWidth(20) + @ExcelProperty("京东价") + public BigDecimal thirdPrice; + + @ColumnWidth(20) + @ExcelProperty({"原价"}) + public BigDecimal originalPrice; + + @ColumnWidth(20) + @ExcelProperty({"sku编码"}) + public String thirdId; + + @ColumnWidth(20) + @ExcelProperty({"销量"}) + public String saleNum; + +} diff --git a/service/src/main/java/com/hfkj/service/goods/GoodsMsgService.java b/service/src/main/java/com/hfkj/service/goods/GoodsMsgService.java index 0764696..f1effd5 100644 --- a/service/src/main/java/com/hfkj/service/goods/GoodsMsgService.java +++ b/service/src/main/java/com/hfkj/service/goods/GoodsMsgService.java @@ -3,6 +3,8 @@ package com.hfkj.service.goods; import com.hfkj.entity.GoodsMsg; +import com.hfkj.model.goods.JdGoodsModel; +import com.hfkj.model.order.OrderCouponModel; import java.util.List; import java.util.Map; @@ -75,6 +77,17 @@ public interface GoodsMsgService { */ List getList(Map map); + /** + * @MethodName getListCrest + * @Description: c端查询 + * @param map + * @return: java.util.List + * @Author: Sum1Dream + * @Date: 2024/11/26 上午10:49 + */ + List getListCrest(Map map); + + List getJdGoodsList(Map param); /** * 编辑商品库存 diff --git a/service/src/main/java/com/hfkj/service/goods/GoodsSpecsService.java b/service/src/main/java/com/hfkj/service/goods/GoodsSpecsService.java index dcfba81..a21692a 100644 --- a/service/src/main/java/com/hfkj/service/goods/GoodsSpecsService.java +++ b/service/src/main/java/com/hfkj/service/goods/GoodsSpecsService.java @@ -86,6 +86,9 @@ public interface GoodsSpecsService { */ List getList(Map map); + + List getGoodsSpecsCrest(); + /** * @Author Sum1Dream * @Name decreaseStockNum diff --git a/service/src/main/java/com/hfkj/service/goods/impl/GoodsMsgServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/GoodsMsgServiceImpl.java index e7e0dbc..54800c4 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/GoodsMsgServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/GoodsMsgServiceImpl.java @@ -7,6 +7,7 @@ import com.hfkj.dao.GoodsMsgMapper; import com.hfkj.entity.GoodsBrand; import com.hfkj.entity.GoodsMsg; import com.hfkj.entity.GoodsMsgExample; +import com.hfkj.model.goods.JdGoodsModel; import com.hfkj.service.goods.GoodsMsgService; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -129,6 +130,16 @@ public class GoodsMsgServiceImpl implements GoodsMsgService { return goodsMsgMapper.selectByExample(example); } + @Override + public List getListCrest(Map map) { + return goodsMsgMapper.getGoodsListCrest(map); + } + + @Override + public List getJdGoodsList(Map param) { + return goodsMsgMapper.getJdGoodsList(param); + } + @Override public void editSaleNum(Long goodsId, Integer num , Integer type) { diff --git a/service/src/main/java/com/hfkj/service/goods/impl/GoodsSpecsServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/GoodsSpecsServiceImpl.java index e24ae28..1d25044 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/GoodsSpecsServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/GoodsSpecsServiceImpl.java @@ -104,6 +104,12 @@ public class GoodsSpecsServiceImpl implements GoodsSpecsService { return goodsSpecsMapper.selectByExample(goodsSpecsExample); } + + @Override + public List getGoodsSpecsCrest() { + return goodsSpecsMapper.getGoodsSpecsCrest(); + } + @Override public void editStockNum(Long specsId, Integer num , Integer type) { String key = "GOODS_STOCK_NUM"; diff --git a/service/src/main/java/com/hfkj/service/goods/impl/GoodsUserAddressServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/GoodsUserAddressServiceImpl.java index 874b6f8..874eb6d 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/GoodsUserAddressServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/GoodsUserAddressServiceImpl.java @@ -1,6 +1,7 @@ package com.hfkj.service.goods.impl; import com.hfkj.dao.GoodsUserAddressMapper; +import com.hfkj.entity.GoodsMsg; import com.hfkj.entity.GoodsUserAddress; import com.hfkj.entity.GoodsUserAddressExample; import com.hfkj.service.goods.GoodsUserAddressService; @@ -8,10 +9,7 @@ import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; @Service("goodsUserAddressService") public class GoodsUserAddressServiceImpl implements GoodsUserAddressService { @@ -31,7 +29,10 @@ public class GoodsUserAddressServiceImpl implements GoodsUserAddressService { @Override public void delete(Long id) { - goodsUserAddressMapper.deleteByPrimaryKey(id); + GoodsUserAddress goodsUserAddress = queryDetail(id); + goodsUserAddress.setStatus(0); + goodsUserAddress.setUpdateTime(new Date()); + update(goodsUserAddress); } @Override @@ -50,7 +51,9 @@ public class GoodsUserAddressServiceImpl implements GoodsUserAddressService { if (MapUtils.getBoolean(map, "whetherDefault") != null) { criteria.andWhetherDefaultEqualTo(MapUtils.getBoolean(map, "whetherDefault")); } - + if (MapUtils.getInteger(map, "status") != null) { + criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); + } List list = goodsUserAddressMapper.selectByExample(example); if (!list.isEmpty()) { @@ -68,6 +71,9 @@ public class GoodsUserAddressServiceImpl implements GoodsUserAddressService { if (MapUtils.getLong(map, "userId") != null) { criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId")); } + if (MapUtils.getInteger(map, "status") != null) { + criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); + } return goodsUserAddressMapper.selectByExample(example); } diff --git a/service/src/main/java/com/hfkj/service/order/OrderCreateService.java b/service/src/main/java/com/hfkj/service/order/OrderCreateService.java index 362c055..972e023 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderCreateService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderCreateService.java @@ -614,6 +614,10 @@ public class OrderCreateService { // 查询库存 VopGoodsGetNewStockByIdResponse stockResponse = JdPostService.getNewStockById(jdService.getToken() , Long.valueOf(skuId), address.getProvinceId() , address.getCityId() , address.getCountyId() , address.getTownId()); + if (stockResponse != null && !stockResponse.getOpenRpcResult().getSuccess()) { + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "商品已售罄!" ); + } + if (!checkStock(stockResponse.getOpenRpcResult().getResult().get(0).getStockStateType())) { throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "商品已售罄!" ); } diff --git a/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java b/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java index 1a667d8..01a257c 100644 --- a/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java @@ -182,7 +182,9 @@ public class BsUserServiceImpl implements BsUserService { BsUser user = getUser(phone); if (user == null) { // 查询用户 - user = getUserByMaOpenId(other.get("maOpenId").toString()); + if (other.get("maOpenId") != null) { + user = getUserByMaOpenId(other.get("maOpenId").toString()); + } if (user == null) { user = register(phone, password, other); } diff --git a/service/src/main/java/com/hfkj/sysenum/fileRecords/FileRecordsEnum.java b/service/src/main/java/com/hfkj/sysenum/fileRecords/FileRecordsEnum.java index 842d9ed..caea7ae 100644 --- a/service/src/main/java/com/hfkj/sysenum/fileRecords/FileRecordsEnum.java +++ b/service/src/main/java/com/hfkj/sysenum/fileRecords/FileRecordsEnum.java @@ -63,6 +63,7 @@ public enum FileRecordsEnum { * 导出结算总和 */ status12(12, "结算总和"), + status13(13, "京东商品"), ; private final int code; diff --git a/service/src/main/resources/prod/commonConfig.properties b/service/src/main/resources/prod/commonConfig.properties index 06efae2..a6f0573 100644 --- a/service/src/main/resources/prod/commonConfig.properties +++ b/service/src/main/resources/prod/commonConfig.properties @@ -27,7 +27,7 @@ pcytCnpcSecret=xstEWAhjw74GzMkXcPr2Cf7z00aYXaSy # BiLingXing blxPostUrl=https://zhctapplet.gyzhtc.com/gateway -huiliantongUrl=https://gzapi.deepermobile.com.cn +huiliantongUrl=http://hltgz.com:4010/api/v2/execute.json huiliantongAppNo=guizhouhuilt huiliantongAppkey=e0ja2Ex%2BmQ2hIPF6x%2BHA%3D huiliantongAppsecret=52662415DDCE55C7BA34223BCF53877A @@ -86,6 +86,12 @@ haiOilPostUrl = https://oil.dctpay.com haiOilAppid = hf166f4b2ed75e71 haiOilAppSecret = 5a11778cfdd4962282a359397bf4f86b +jDPostUrl = https://test-oil.dctpay.com +jDAppKey = C4FF710550C43FE76D4114E1C9C6A0C9 +jDAppSecret = 873bcbc1d8d64f36832270c2ff59c194 + + ytAccessKey=9326673207264334 ytSecretKey=VCLXFV09BNZNMERR9F21KI3LC7L101YY -ytPostUrl= https://sichuan.95504.net/v4 \ No newline at end of file +ytPostUrl= https://sichuan.95504.net/v4 + diff --git a/user/src/main/java/com/user/controller/BsUserController.java b/user/src/main/java/com/user/controller/BsUserController.java index c0afa29..e502ca7 100644 --- a/user/src/main/java/com/user/controller/BsUserController.java +++ b/user/src/main/java/com/user/controller/BsUserController.java @@ -156,49 +156,48 @@ public class BsUserController { } } - @RequestMapping(value = "/phoneNotVerify", method = RequestMethod.POST) - @ResponseBody - @ApiOperation(value = "H5手机号不校验登陆") - public ResponseData phoneNotVerify(@RequestBody JSONObject body) { - try { - if (body == null - || StringUtils.isBlank(body.getString("platform")) - || StringUtils.isBlank(body.getString("type")) - || StringUtils.isBlank(body.getString("phone")) - ) { - log.error("LoginController --> phone() error!", "请求参数校验失败"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - String phone = body.getString("phone"); - String password = body.getString("password"); - - // 客户端 - UserLoginPlatform platform = UserLoginPlatform.getDataByType(body.getString("platform")); - if (platform == null) { - log.error("LoginController --> phone() error!", "未知客户端"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知客户端"); - } - // 校验手机号格式 - if (!MemberValidateUtil.validatePhone(phone)) { - log.error("LoginController --> phone() error!", "请输入正确的手机号"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号"); - } - // 登录类型 - UserLoginType loginType = UserLoginType.getDataByType(body.getString("type")); - if (loginType == null) { - log.error("LoginController --> phone() error!", "未知登录类型;" + body.getString("type")); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知登录类型"); - } - - Map other = new HashMap<>(); - /*other.put("maOpenId", "maOpenId");*/ - return ResponseMsgUtil.success(userService.login(platform, loginType, phone, password, other)); - - } catch (Exception e) { - log.error("LoginController --> phone() error!", e); - return ResponseMsgUtil.exception(e); - } - } +// @RequestMapping(value = "/phoneNotVerify", method = RequestMethod.POST) +// @ResponseBody +// @ApiOperation(value = "H5手机号不校验登陆") +// public ResponseData phoneNotVerify(@RequestBody JSONObject body) { +// try { +// if (body == null +// || StringUtils.isBlank(body.getString("platform")) +// || StringUtils.isBlank(body.getString("type")) +// || StringUtils.isBlank(body.getString("phone")) +// ) { +// log.error("LoginController --> phone() error!", "请求参数校验失败"); +// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); +// } +// String phone = body.getString("phone"); +// String password = body.getString("password"); +// +// // 客户端 +// UserLoginPlatform platform = UserLoginPlatform.getDataByType(body.getString("platform")); +// if (platform == null) { +// log.error("LoginController --> phone() error!", "未知客户端"); +// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知客户端"); +// } +// // 校验手机号格式 +// if (!MemberValidateUtil.validatePhone(phone)) { +// log.error("LoginController --> phone() error!", "请输入正确的手机号"); +// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号"); +// } +// // 登录类型 +// UserLoginType loginType = UserLoginType.getDataByType(body.getString("type")); +// if (loginType == null) { +// log.error("LoginController --> phone() error!", "未知登录类型;" + body.getString("type")); +// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知登录类型"); +// } +// +// Map other = new HashMap<>(); +// return ResponseMsgUtil.success(userService.login(platform, loginType, phone, password, other)); +// +// } catch (Exception e) { +// log.error("LoginController --> phone() error!", e); +// return ResponseMsgUtil.exception(e); +// } +// } @RequestMapping(value = "/phoneTest", method = RequestMethod.POST) @ResponseBody