diff --git a/hai-bweb/src/main/java/com/bweb/controller/Goods/GoodsDetailController.java b/hai-bweb/src/main/java/com/bweb/controller/Goods/GoodsDetailController.java new file mode 100644 index 00000000..e4a92583 --- /dev/null +++ b/hai-bweb/src/main/java/com/bweb/controller/Goods/GoodsDetailController.java @@ -0,0 +1,263 @@ +package com.bweb.controller.Goods; + + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; +import com.hai.common.security.SessionObject; +import com.hai.common.security.UserCenter; +import com.hai.common.utils.ResponseMsgUtil; + +import com.hai.entity.GoodsDetail; +import com.hai.entity.HighGoodsType; +import com.hai.goods.service.GoodsDetailService; +import com.hai.model.ResponseData; +import com.hai.model.UserInfoModel; +import com.hai.service.HighGoodsTypeService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Controller +@RequestMapping(value = "/goods") +@Api(value = "商品") +public class GoodsDetailController { + Logger log = LoggerFactory.getLogger(GoodsDetailController.class); + + @Resource + private GoodsDetailService goodsDetailService; + + @Resource + private HighGoodsTypeService highGoodsTypeService; + + @Autowired + private UserCenter userCenter; + + @RequestMapping(value = "/getListGoodsDetail", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询商品列表") + public ResponseData getListGoodsDetail( + @RequestParam(value = "title", required = false) String title, + @RequestParam(value = "status", required = false) Integer status, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize + ) { + try { + + + Map map = new HashMap<>(); + + map.put("title", title); + map.put("status", status); + + PageHelper.startPage(pageNum,pageSize); + + List list = goodsDetailService.getGoodsDetailList(map); + return ResponseMsgUtil.success(new PageInfo<>(list)); + + } catch (Exception e) { + log.error("GoodsDetailController --> getListUser() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/insertGoods", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "新增产品") + public ResponseData insertGoods(@RequestBody GoodsDetail goodsDetail, HttpServletRequest request) { + try { + + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + if (goodsDetail == null || + goodsDetail.getName() == null || + goodsDetail.getGoodsType() == null || + goodsDetail.getListImg() == null || + goodsDetail.getBannerImg() == null || + goodsDetail.getDetailImg() == null + + ) { + log.error("GoodsDetailController -> insertProduct() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + HighGoodsType goodsType = highGoodsTypeService.findById(goodsDetail.getGoodsType().intValue()); + + goodsDetail.setOpId(userInfoModel.getSecUser().getId()); + goodsDetail.setStatus(2); + goodsDetail.setCompanyId(userInfoModel.getBsCompany().getId()); + goodsDetail.setOpName(userInfoModel.getSecUser().getLoginName()); + goodsDetail.setCreateTime(new Date()); + goodsDetail.setGoodsTypeName(goodsType.getTitle()); + goodsDetail.setUpdateTime(new Date()); + + goodsDetailService.insertGoodsDetail(goodsDetail); + + return ResponseMsgUtil.success("新增成功"); + + } catch (Exception e) { + log.error("GoodsDetailController --> insertPrice() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/updateGoods", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "修改产品") + public ResponseData updateGoods(@RequestBody GoodsDetail goodsDetail, HttpServletRequest request) { + try { + + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + if (goodsDetail == null || + goodsDetail.getId() == null || + goodsDetail.getName() == null || + goodsDetail.getGoodsType() == null || + goodsDetail.getListImg() == null || + goodsDetail.getBannerImg() == null || + goodsDetail.getDetailImg() == null + + ) { + log.error("GoodsDetailController -> insertProduct() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + GoodsDetail goods = goodsDetailService.findGoodsDetailById(goodsDetail.getId()); + + HighGoodsType goodsType = highGoodsTypeService.findById(goodsDetail.getGoodsType().intValue()); + + + goodsDetail.setStatus(goods.getStatus()); + goodsDetail.setCreateTime(goods.getCreateTime()); + goodsDetail.setUpdateTime(new Date()); + goodsDetail.setGoodsTypeName(goodsType.getTitle()); + + goodsDetail.setOpId(userInfoModel.getSecUser().getId()); + goodsDetail.setOpName(userInfoModel.getSecUser().getLoginName()); + + goodsDetailService.updateGoodsDetail(goodsDetail); + + return ResponseMsgUtil.success("修改成功"); + + + } catch (Exception e) { + log.error("GoodsDetailController --> insertPrice() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/findGoodsDetailById", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询商品列表") + public ResponseData findGoodsDetailById( + @RequestParam(value = "id", required = true) Long id + ) { + try { + + GoodsDetail goodsDetail = goodsDetailService.findGoodsDetailById(id); + + if (goodsDetail == null) { + log.error("GoodsDetailController -> findGoodsDetailById() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相关商品信息"); + } + + return ResponseMsgUtil.success(goodsDetail); + + } catch (Exception e) { + log.error("GoodsDetailController --> findGoodsDetailById() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/deleteGoods", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "删除商品") + public ResponseData deleteGoods( + @RequestParam(value = "id", required = true) Long id + , HttpServletRequest request + ) { + try { + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + GoodsDetail goodsDetail = goodsDetailService.findGoodsDetailById(id); + + if (goodsDetail == null) { + log.error("GoodsDetailController -> findGoodsDetailById() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相关商品信息"); + } + + if (goodsDetail.getStatus() == 1) { + log.error("GoodsDetailController -> findGoodsDetailById() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前状态错误,不可删除"); + } + + goodsDetail.setStatus(0); + goodsDetail.setUpdateTime(new Date()); + goodsDetail.setOpId(userInfoModel.getSecUser().getId()); + goodsDetail.setOpName(userInfoModel.getSecUser().getLoginName()); + goodsDetailService.updateGoodsDetail(goodsDetail); + + return ResponseMsgUtil.success("删除成功!"); + + } catch (Exception e) { + log.error("GoodsDetailController --> findGoodsDetailById() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/goodsUpDown", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "商品上下架") + public ResponseData goodsUpDown( + @RequestParam(value = "id", required = true) Long id + , HttpServletRequest request + ) { + try { + + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + GoodsDetail goodsDetail = goodsDetailService.findGoodsDetailById(id); + + if (goodsDetail == null) { + log.error("GoodsDetailController -> findGoodsDetailById() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相关商品信息!"); + } + + if (goodsDetail.getStatus() == 0) { + log.error("GoodsDetailController -> findGoodsDetailById() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前状态错误,无法操作!"); + } + + goodsDetail.setStatus(goodsDetail.getStatus() == 1 ? 2:1); + goodsDetail.setUpdateTime(new Date()); + goodsDetail.setOpId(userInfoModel.getSecUser().getId()); + goodsDetail.setOpName(userInfoModel.getSecUser().getLoginName()); + goodsDetailService.updateGoodsDetail(goodsDetail); + + return ResponseMsgUtil.success("操作成功!"); + + } catch (Exception e) { + log.error("GoodsDetailController --> findGoodsDetailById() error!", e); + return ResponseMsgUtil.exception(e); + } + } +} + diff --git a/hai-bweb/src/main/java/com/bweb/controller/Goods/GoodsSkuController.java b/hai-bweb/src/main/java/com/bweb/controller/Goods/GoodsSkuController.java new file mode 100644 index 00000000..d5bfe19b --- /dev/null +++ b/hai-bweb/src/main/java/com/bweb/controller/Goods/GoodsSkuController.java @@ -0,0 +1,208 @@ +package com.bweb.controller.Goods; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; +import com.hai.common.security.SessionObject; +import com.hai.common.security.UserCenter; +import com.hai.common.utils.ResponseMsgUtil; +import com.hai.entity.GoodsDetail; +import com.hai.entity.GoodsSku; +import com.hai.goods.service.GoodsDetailService; +import com.hai.goods.service.GoodsSkuService; +import com.hai.model.ResponseData; +import com.hai.model.UserInfoModel; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Controller +@RequestMapping(value = "/goodsSku") +@Api(value = "商品") +public class GoodsSkuController { + + Logger log = LoggerFactory.getLogger(GoodsSkuController.class); + + @Resource + private GoodsSkuService goodsSkuService; + + @Autowired + private UserCenter userCenter; + + @RequestMapping(value = "/getListGoodsSku", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询商品SKU") + public ResponseData getListGoodsSku( + @RequestParam(value = "title", required = false) String title, + @RequestParam(value = "goodsId", required = false) Long goodsId + + ) { + try { + + + Map map = new HashMap<>(); + + map.put("title", title); + map.put("goodsId", goodsId); + + return ResponseMsgUtil.success(goodsSkuService.getGoodsSkuList(map)); + + } catch (Exception e) { + log.error("GoodsDetailController --> getListUser() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/insertGoodsSku", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "新增商品SKU") + public ResponseData insertGoodsSku(@RequestBody GoodsSku goodsSku, HttpServletRequest request) { + try { + + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + if (goodsSku == null || + goodsSku.getName() == null || + goodsSku.getGoodsId() == null || + goodsSku.getShowImg() == null || + goodsSku.getBannerImg() == null || + goodsSku.getOriginalPrice() == null || + goodsSku.getPrice() == null || + goodsSku.getStock() == null + + ) { + log.error("GoodsDetailController -> insertProduct() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + + goodsSku.setOpId(userInfoModel.getSecUser().getId()); + goodsSku.setStatus(1); + goodsSku.setOpName(userInfoModel.getSecUser().getLoginName()); + goodsSku.setCreateTime(new Date()); + goodsSku.setUpdateTime(new Date()); + + goodsSkuService.insertGoodsSku(goodsSku); + + return ResponseMsgUtil.success("新增成功"); + + } catch (Exception e) { + log.error("GoodsDetailController --> insertPrice() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/updateGoodsSku", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "更新商品SKU") + public ResponseData updateGoodsSku(@RequestBody GoodsSku goodsSku, HttpServletRequest request) { + try { + + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + if (goodsSku == null || + goodsSku.getId() == null || + goodsSku.getName() == null || + goodsSku.getGoodsId() == null || + goodsSku.getShowImg() == null || + goodsSku.getBannerImg() == null || + goodsSku.getOriginalPrice() == null || + goodsSku.getPrice() == null || + goodsSku.getStock() == null + + ) { + log.error("GoodsDetailController -> insertProduct() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + + GoodsSku sku = goodsSkuService.findGoodsSkuById(goodsSku.getId()); + + goodsSku.setStatus(sku.getStatus()); + goodsSku.setCreateTime(sku.getCreateTime()); + goodsSku.setUpdateTime(new Date()); + + goodsSku.setOpId(userInfoModel.getSecUser().getId()); + goodsSku.setOpName(userInfoModel.getSecUser().getLoginName()); + + goodsSkuService.updateGoodsSku(goodsSku); + + + return ResponseMsgUtil.success("修改成功"); + + } catch (Exception e) { + log.error("GoodsDetailController --> insertPrice() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/findGoodsSkuById", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询商品SKU") + public ResponseData findGoodsSkuById( + @RequestParam(value = "id", required = true) Long id + ) { + try { + + GoodsSku goodsSku = goodsSkuService.findGoodsSkuById(id); + + if (goodsSku == null) { + log.error("GoodsDetailController -> findGoodsDetailById() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相关商品SKU信息"); + } + + return ResponseMsgUtil.success(goodsSku); + + } catch (Exception e) { + log.error("GoodsDetailController --> findGoodsDetailById() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/deleteSku", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "删除SKU") + public ResponseData deleteSku( + @RequestParam(value = "id", required = true) Long id + , HttpServletRequest request + ) { + try { + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + GoodsSku goodsSku = goodsSkuService.findGoodsSkuById(id); + + if (goodsSku == null) { + log.error("GoodsDetailController -> findGoodsDetailById() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相关商品SKU信息"); + } + + goodsSku.setStatus(0); + goodsSku.setUpdateTime(new Date()); + goodsSku.setOpId(userInfoModel.getSecUser().getId()); + goodsSku.setOpName(userInfoModel.getSecUser().getLoginName()); + goodsSkuService.updateGoodsSku(goodsSku); + + return ResponseMsgUtil.success(goodsSku); + + } catch (Exception e) { + log.error("GoodsDetailController --> findGoodsDetailById() error!", e); + return ResponseMsgUtil.exception(e); + } + } +} diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighBrandController.java b/hai-bweb/src/main/java/com/bweb/controller/HighBrandController.java index f7a665e8..ee3b9ac0 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighBrandController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighBrandController.java @@ -134,7 +134,6 @@ public class HighBrandController { if (StringUtils.isBlank(highBrand.getTitle()) || StringUtils.isBlank(highBrand.getImg()) - || highBrand.getGoodTypeId() == null ) { log.error("HighAgentController -> insertAgent() error!","参数错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); @@ -175,7 +174,6 @@ public class HighBrandController { if (StringUtils.isBlank(highBrand.getTitle()) || StringUtils.isBlank(highBrand.getImg()) || highBrand.getId() == null - || highBrand.getGoodTypeId() == null ) { log.error("HighAgentController -> insertAgent() error!","参数错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighGoodsTypeController.java b/hai-bweb/src/main/java/com/bweb/controller/HighGoodsTypeController.java index 3d2b129b..82fa4baa 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighGoodsTypeController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighGoodsTypeController.java @@ -1,5 +1,6 @@ package com.bweb.controller; +import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.hai.common.exception.ErrorCode; @@ -26,6 +27,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.util.Date; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -73,6 +75,43 @@ public class HighGoodsTypeController { } } + @RequestMapping(value = "/getGoodsTypeTree", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取商品类型树结构") + public ResponseData getGoodsTypeTree(@RequestParam(name = "businessType", required = true) Integer businessType) { + try { + + return ResponseMsgUtil.success(highGoodsTypeService.getGoodsTypeTree(businessType)); + + } catch (Exception e) { + log.error("HighOrderController --> getUserOrderList() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + + @RequestMapping(value = "/getListGoodsTypeByParentId", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取子类类型列表") + public ResponseData getListGoodsTypeByParentId(@RequestParam(name = "parentId", required = false) String parentId, + HttpServletRequest request) { + try { + //发布人员 + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + Map map = new HashMap<>(); + map.put("parentId", parentId); + map.put("companyId", userInfoModel.getBsCompany().getId().toString()); + + return ResponseMsgUtil.success(highGoodsTypeService.getListGoodsType(map)); + + } catch (Exception e) { + log.error("HighOrderController --> getUserOrderList() error!", e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value = "/getGoodsTypeById", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据id查询详情") @@ -133,7 +172,6 @@ public class HighGoodsTypeController { if (StringUtils.isBlank(highGoodsType.getTitle()) - || StringUtils.isBlank(highGoodsType.getImg()) || highGoodsType.getBusinessType() == null ) { log.error("HighAgentController -> insertAgent() error!","参数错误"); @@ -174,7 +212,6 @@ public class HighGoodsTypeController { if (StringUtils.isBlank(highGoodsType.getTitle()) - || StringUtils.isBlank(highGoodsType.getImg()) || highGoodsType.getBusinessType() == null || highGoodsType.getId() == null ) { @@ -193,6 +230,8 @@ public class HighGoodsTypeController { highGoodsTypes.setUpdatedTime(new Date()); highGoodsTypes.setUpdatedUserId(userInfoModel.getSecUser().getId().intValue()); highGoodsTypes.setImg(highGoodsType.getImg()); + highGoodsTypes.setParentId(highGoodsType.getParentId()); + highGoodsTypes.setBusinessType(highGoodsType.getBusinessType()); highGoodsTypes.setCompanyId(userInfoModel.getBsCompany().getId()); highGoodsTypes.setTitle(highGoodsType.getTitle()); diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java b/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java index c55794f0..b9072a02 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java @@ -1 +1 @@ - package com.bweb.controller; import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alipay.api.domain.ForbbidenTime; import com.alipay.api.domain.OfferObject; import com.bweb.config.SysConst; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.*; import com.hai.config.*; import com.hai.entity.*; import com.hai.model.OrderRefundModel; import com.hai.model.ResponseData; import com.hai.order.model.ExportOrderMobileModel; import com.hai.order.model.OrderThirdPartyModel; import com.hai.order.service.OrderRefundService; import com.hai.order.service.OrderService; import com.hai.order.type.*; import com.hai.order.utils.OrderUtil; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Controller; 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.regex.Matcher; import java.util.regex.Pattern; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private OutRechargeOrderService outRechargeOrderService; @Autowired private OutRechargeChildOrderService childOrderService; @Resource private HighOrderService highOrderService; @Autowired private RedisTemplate redisTemplate; @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardConsume", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡消费记录") public ResponseData getHuiLianTongCardConsume(@RequestParam(name = "businessType", required = true) String businessType, @RequestParam(name = "cardNo", required = true) String cardNo, @RequestParam(name = "sdate", required = true) Long sdate, @RequestParam(name = "edate", required = true) Long edate, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { try { JSONObject consumptionRecord = HuiLianTongUnionCardConfig.queryConsumptionRecordByBusiness(businessType, cardNo, sdate, edate, pageNum, pageSize); if (StringUtils.isBlank(consumptionRecord.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } JSONArray array = HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data")).getJSONArray("records"); return ResponseMsgUtil.success(array); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getStationStores", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取油站") public ResponseData getStationStores() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/refuelOnline/getStationStore" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getRechargeProduct", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取充值产品") public ResponseData getRechargeProduct() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/mobileRecharge/getMobileProduct" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getAllCities", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询可用城市") public ResponseData getAllCities() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/apiMerchants/getAllCities" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/starbucksStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询星巴克门店") public ResponseData starbucksStore() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("lat" , "29.56900"); mapPost.put("lon" , "106.55843"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("lat" , "29.56900"); map.put("lon" , "106.55843"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/starbucks/starbucksStore" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/starbucksProducts", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询星巴克商品") public ResponseData starbucksProducts() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/starbucks/starbucksProducts" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/kfcStoresList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询肯德基门店") public ResponseData kfcStoresList() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/kfc/kfcStoresList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/kfcProductByStoreCode", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据门店编码查询KFC产品") public ResponseData kfcProductByStoreCode(@RequestParam(name = "storeCode", required = true) String storeCode) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("storeCode" , storeCode); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("storeCode" , storeCode); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/kfc/kfcProductByStoreCode" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/memberProducts", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询会员产品") public ResponseData memberProducts() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/memberRecharge/memberProducts" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/createOrder", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "创建订单") public ResponseData createOrder(@RequestBody JSONObject object) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("timetable" , new Date().getTime()); mapPost.put("orderNo" , "TEST" + OrderUtil.generateOrderNo()); mapPost.put("productType" , object.getString("productType")); mapPost.put("notifyUrl" , "test"); mapPost.put("content" , object.toString()); System.out.println(mapPost); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("timetable" , mapPost.get("timetable").toString()); map.put("orderNo" , mapPost.get("orderNo")); map.put("productType" , object.getString("productType")); map.put("content" , object.toString()); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/createOrder" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/payOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付订单") public ResponseData payOrder(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/orderPay" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryOrderDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询订单详情") public ResponseData queryOrderDetail(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/queryOrderDetail" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/phoneBillOrderError", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费订单错误") public ResponseData phoneBillOrderError() { try { log.info("处理话费订单定时任务开始"); Map map = new HashMap<>(); map.put("payStatus", String.valueOf(102)); map.put("rechargeStatus", String.valueOf(201)); List orderList = outRechargeOrderService.getListRechargeOrder(map); log.info("处理话费订单条数:" + orderList.size()); if (orderList.size() > 0) { for (OutRechargeOrder order : orderList) { // 查询子订单 HighOrder highOrder = highOrderService.getOrderByOrderNo(order.getOrderNo()); // 判断订单是否可以继续充值 1:满足继续充值条件 2:订单满足退款条件 3:订单不可以退款不可以继续充值 4:订单异常 5:订单充值完成 int orderStatus = outRechargeOrderService.orderWhetherRecharge(order); log.info("处理话费订单:" + orderStatus + "订单号" + order.getOrderNo()); if (orderStatus == 2 && highOrder.getOrderStatus() == 4) { order.setRechargeStatus(203); order.setPayStatus(105); } if (orderStatus == 5 && highOrder.getOrderStatus() == 3) { order.setRechargeStatus(202); order.setPayStatus(100); } outRechargeOrderService.updateOrder(order); } } return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/mobileChildOrderByOrderNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据订单号修改话费订单状态") public ResponseData mobileChildOrderByOrderNo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { OutRechargeOrder order = outRechargeOrderService.findByOrderNo(orderNo); // 查询子订单 HighOrder highOrder = highOrderService.getOrderByOrderNo(order.getOrderNo()); // 判断订单是否可以继续充值 1:满足继续充值条件 2:订单满足退款条件 3:订单不可以退款不可以继续充值 4:订单异常 5:订单充值完成 int orderStatus = outRechargeOrderService.orderWhetherRecharge(order); log.info("处理话费订单:" + orderStatus + "订单号" + order.getOrderNo()); if (orderStatus == 2 && highOrder.getOrderStatus() == 4) { order.setRechargeStatus(203); order.setPayStatus(105); } if (orderStatus == 5 && highOrder.getOrderStatus() == 3) { order.setRechargeStatus(202); order.setPayStatus(100); } outRechargeOrderService.updateOrder(order); return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/deposit", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡充值") public ResponseData deposit(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); HighChildOrder highChildOrder = order.getHighChildOrderList().get(0); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } // 汇联通充值 String goodsDesc = "汇联通充值"+order.getPayPrice()+"元"; String tranDesc = ""; String businessType = "ghk_deposit"; String orderNoAgain = OrderUtil.generateOrderNo(); order.setOrderStatus(3); order.setRemarks("工会卡再次充值订单号" + orderNoAgain); highOrderService.updateOrder(order); // 汇联通卡充值 JSONObject deposit = HuiLianTongUnionCardConfig.deposit(orderNoAgain, highChildOrder.getGoodsSpecName(), order.getPayPrice(), businessType, order.getPaySerialNo(), goodsDesc); return ResponseMsgUtil.success( HuiLianTongUnionCardConfig.resolveResponse(deposit.getString("data"))); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/mobileDw", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费订单下载") public ResponseData mobileDw(@RequestParam(name = "createTimeS", required = false) String createTimeS, @RequestParam(name = "createTimeE", required = false) String createTimeE, @RequestParam(name = "refundTimeS", required = false) String refundTimeS, @RequestParam(name = "refundTimeE", required = false) String refundTimeE ) { try { Map map = new HashMap<>(); map.put("productType" , 9); map.put("createTimeS" , createTimeS); map.put("createTimeE" , createTimeE); map.put("refundTimeS" , refundTimeS); map.put("refundTimeE" , refundTimeE); List order = highOrderService.getOrderListNotChild(map); List list = new ArrayList<>(); ExportOrderMobileModel model; for (HighOrder highOrder : order) { model = new ExportOrderMobileModel(); OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderNoNotChild(highOrder.getOrderNo()); if (rechargeOrder != null) { OutRechargeChildOrder childOrder = mobileChildOrderHandle(highOrder,rechargeOrder); model.setRechargeOrderNo(rechargeOrder.getOrderNo()); if (childOrder != null) { model.setChildOrderNo(childOrder.getOrderNo()); if (childOrder.getRechargePlatform() != null) { model.setRechargePlatform(RechargePlatformType.getDataByType(childOrder.getRechargePlatform()).getName()); } model.setRemark(childOrder.getExt1()); } } model.setFinishTime(highOrder.getFinishTime()); model.setOrderStatus(OrderStatus.getDataByType(highOrder.getOrderStatus()).getName()); model.setMemPhone(highOrder.getMemPhone()); model.setCreateTime(highOrder.getCreateTime()); model.setTitle(highOrder.getTitle()); model.setPayablePrice(highOrder.getPayablePrice()); model.setRefundTime(highOrder.getRefundTime()); model.setPayPrice(highOrder.getPayPrice()); model.setOrderNo(highOrder.getOrderNo()); model.setMemCardNo(highOrder.getMemCardNo()); if (highOrder.getPayType() != null) { model.setPayType(OrderPayType.getDataByType(highOrder.getPayType()).getName()); } list.add(model); } String fileUrl = SysConst.getSysConfig().getFileUrl() + "temporary/"; String pathName = System.currentTimeMillis()+".xlsx"; File file = new File(fileUrl); if (!file.exists()) { file.mkdirs(); } EasyExcel.write(fileUrl+pathName) .head(ExportOrderMobileModel.class) .sheet("话费交易订单") .doWrite(list); return ResponseMsgUtil.success(pathName); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } public OutRechargeChildOrder mobileChildOrderHandle(HighOrder highOrder , OutRechargeOrder outRechargeOrder) { // 组装查询子订单数据 Map childOrderMap101 = new HashMap<>(); childOrderMap101.put("parent_order_id", outRechargeOrder.getId()); childOrderMap101.put("status", "101,102"); // 查询充值订单 List childOrders = childOrderService.getListRechargeChildOrder(childOrderMap101); OutRechargeChildOrder childOrder; // 判读是否存在多个充值中的订单 if (childOrders.size() > 0) { childOrder = childOrders.get(0); if (childOrders.size() > 1) { childOrder.setExt1("当前订单存在多个充值订单"); } } else { childOrder = childOrderService.findByOrderId(outRechargeOrder.getId()); if (childOrder != null && highOrder != null && childOrder.getStatus() != null && highOrder.getOrderStatus() != null) { if (highOrder.getOrderStatus() == 2 && childOrder.getStatus() != 102) { childOrder.setExt1("主订单充值中,但是充值订单状态不为充值中"); } if (highOrder.getOrderStatus() == 3 && childOrder.getStatus() != 101) { childOrder.setExt1("主订单充值成功,但是充值订单状态不为充值成功"); } if (highOrder.getOrderStatus() == 4 && !(childOrder.getStatus() == 103 || childOrder.getStatus() == 104)) { childOrder.setExt1("主订单退款,但是充值订单状态不为退款"); } } } return childOrder; } @RequestMapping(value = "/externalOrderRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "对外订单退款") public ResponseData externalOrderRefund(@RequestParam(name = "paySerialNo", required = true) String paySerialNo, @RequestParam(name = "WxMchId", required = true) String WxMchId, @RequestParam(name = "payRealPrice", required = true) String payRealPrice) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); mapPost.put("merchId" , "20230394901"); mapPost.put("paySerialNo" , paySerialNo); mapPost.put("wxMchId" , WxMchId); mapPost.put("payRealPrice" , payRealPrice); mapPost.put("refundPrice" , payRealPrice); Map map = new HashMap<>(); map.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); map.put("merchId" , "20230394901"); map.put("paySerialNo" , paySerialNo); map.put("wxMchId" , WxMchId); map.put("payRealPrice" , payRealPrice); map.put("refundPrice" , payRealPrice); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/order/externalOrderRefund" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file + package com.bweb.controller; import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alipay.api.domain.ForbbidenTime; import com.alipay.api.domain.OfferObject; import com.bweb.config.SysConst; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.*; import com.hai.config.*; import com.hai.entity.*; import com.hai.model.OrderRefundModel; import com.hai.model.ResponseData; import com.hai.order.model.ExportOrderMobileModel; import com.hai.order.model.OrderThirdPartyModel; import com.hai.order.service.OrderRefundService; import com.hai.order.service.OrderService; import com.hai.order.type.*; import com.hai.order.utils.OrderUtil; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Controller; 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.regex.Matcher; import java.util.regex.Pattern; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private OutRechargeOrderService outRechargeOrderService; @Autowired private OutRechargeChildOrderService childOrderService; @Resource private HighOrderService highOrderService; @Autowired private RedisTemplate redisTemplate; @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardConsume", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡消费记录") public ResponseData getHuiLianTongCardConsume(@RequestParam(name = "businessType", required = true) String businessType, @RequestParam(name = "cardNo", required = true) String cardNo, @RequestParam(name = "sdate", required = true) Long sdate, @RequestParam(name = "edate", required = true) Long edate, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { try { JSONObject consumptionRecord = HuiLianTongUnionCardConfig.queryConsumptionRecordByBusiness(businessType, cardNo, sdate, edate, pageNum, pageSize); if (StringUtils.isBlank(consumptionRecord.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } JSONArray array = HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data")).getJSONArray("records"); return ResponseMsgUtil.success(array); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getStationStores", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取油站") public ResponseData getStationStores() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "4B1DF80A2D64376D2807ACA6CFEDE8AA"); mapPost.put("merchId" , "20220896102"); Map map = new HashMap<>(); map.put("apiKey" , "4B1DF80A2D64376D2807ACA6CFEDE8AA"); map.put("merchId" , "20220896102"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/refuelOnline/getStationStore" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getRechargeProduct", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取充值产品") public ResponseData getRechargeProduct() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/mobileRecharge/getMobileProduct" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getAllCities", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询可用城市") public ResponseData getAllCities() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/apiMerchants/getAllCities" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/starbucksStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询星巴克门店") public ResponseData starbucksStore() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("lat" , "29.56900"); mapPost.put("lon" , "106.55843"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("lat" , "29.56900"); map.put("lon" , "106.55843"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/starbucks/starbucksStore" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/starbucksProducts", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询星巴克商品") public ResponseData starbucksProducts() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/starbucks/starbucksProducts" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/kfcStoresList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询肯德基门店") public ResponseData kfcStoresList() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/kfc/kfcStoresList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/kfcProductByStoreCode", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据门店编码查询KFC产品") public ResponseData kfcProductByStoreCode(@RequestParam(name = "storeCode", required = true) String storeCode) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("storeCode" , storeCode); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("storeCode" , storeCode); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/kfc/kfcProductByStoreCode" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/memberProducts", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询会员产品") public ResponseData memberProducts() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/memberRecharge/memberProducts" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/createOrder", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "创建订单") public ResponseData createOrder(@RequestBody JSONObject object) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("timetable" , new Date().getTime()); mapPost.put("orderNo" , "TEST" + OrderUtil.generateOrderNo()); mapPost.put("productType" , object.getString("productType")); mapPost.put("notifyUrl" , "test"); mapPost.put("content" , object.toString()); System.out.println(mapPost); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("timetable" , mapPost.get("timetable").toString()); map.put("orderNo" , mapPost.get("orderNo")); map.put("productType" , object.getString("productType")); map.put("content" , object.toString()); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/createOrder" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/payOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付订单") public ResponseData payOrder(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/orderPay" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryOrderDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询订单详情") public ResponseData queryOrderDetail(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/queryOrderDetail" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/phoneBillOrderError", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费订单错误") public ResponseData phoneBillOrderError() { try { log.info("处理话费订单定时任务开始"); Map map = new HashMap<>(); map.put("payStatus", String.valueOf(102)); map.put("rechargeStatus", String.valueOf(201)); List orderList = outRechargeOrderService.getListRechargeOrder(map); log.info("处理话费订单条数:" + orderList.size()); if (orderList.size() > 0) { for (OutRechargeOrder order : orderList) { // 查询子订单 HighOrder highOrder = highOrderService.getOrderByOrderNo(order.getOrderNo()); // 判断订单是否可以继续充值 1:满足继续充值条件 2:订单满足退款条件 3:订单不可以退款不可以继续充值 4:订单异常 5:订单充值完成 int orderStatus = outRechargeOrderService.orderWhetherRecharge(order); log.info("处理话费订单:" + orderStatus + "订单号" + order.getOrderNo()); if (orderStatus == 2 && highOrder.getOrderStatus() == 4) { order.setRechargeStatus(203); order.setPayStatus(105); } if (orderStatus == 5 && highOrder.getOrderStatus() == 3) { order.setRechargeStatus(202); order.setPayStatus(100); } outRechargeOrderService.updateOrder(order); } } return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/mobileChildOrderByOrderNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据订单号修改话费订单状态") public ResponseData mobileChildOrderByOrderNo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { OutRechargeOrder order = outRechargeOrderService.findByOrderNo(orderNo); // 查询子订单 HighOrder highOrder = highOrderService.getOrderByOrderNo(order.getOrderNo()); // 判断订单是否可以继续充值 1:满足继续充值条件 2:订单满足退款条件 3:订单不可以退款不可以继续充值 4:订单异常 5:订单充值完成 int orderStatus = outRechargeOrderService.orderWhetherRecharge(order); log.info("处理话费订单:" + orderStatus + "订单号" + order.getOrderNo()); if (orderStatus == 2 && highOrder.getOrderStatus() == 4) { order.setRechargeStatus(203); order.setPayStatus(105); } if (orderStatus == 5 && highOrder.getOrderStatus() == 3) { order.setRechargeStatus(202); order.setPayStatus(100); } outRechargeOrderService.updateOrder(order); return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/deposit", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡充值") public ResponseData deposit(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); HighChildOrder highChildOrder = order.getHighChildOrderList().get(0); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } // 汇联通充值 String goodsDesc = "汇联通充值"+order.getPayPrice()+"元"; String tranDesc = ""; String businessType = "ghk_deposit"; String orderNoAgain = OrderUtil.generateOrderNo(); order.setOrderStatus(3); order.setRemarks("工会卡再次充值订单号" + orderNoAgain); highOrderService.updateOrder(order); // 汇联通卡充值 JSONObject deposit = HuiLianTongUnionCardConfig.deposit(orderNoAgain, highChildOrder.getGoodsSpecName(), order.getPayPrice(), businessType, order.getPaySerialNo(), goodsDesc); return ResponseMsgUtil.success( HuiLianTongUnionCardConfig.resolveResponse(deposit.getString("data"))); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/mobileDw", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费订单下载") public ResponseData mobileDw(@RequestParam(name = "createTimeS", required = false) String createTimeS, @RequestParam(name = "createTimeE", required = false) String createTimeE, @RequestParam(name = "refundTimeS", required = false) String refundTimeS, @RequestParam(name = "refundTimeE", required = false) String refundTimeE ) { try { Map map = new HashMap<>(); map.put("productType" , 9); map.put("createTimeS" , createTimeS); map.put("createTimeE" , createTimeE); map.put("refundTimeS" , refundTimeS); map.put("refundTimeE" , refundTimeE); List order = highOrderService.getOrderListNotChild(map); List list = new ArrayList<>(); ExportOrderMobileModel model; for (HighOrder highOrder : order) { model = new ExportOrderMobileModel(); OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderNoNotChild(highOrder.getOrderNo()); if (rechargeOrder != null) { OutRechargeChildOrder childOrder = mobileChildOrderHandle(highOrder,rechargeOrder); model.setRechargeOrderNo(rechargeOrder.getOrderNo()); if (childOrder != null) { model.setChildOrderNo(childOrder.getOrderNo()); if (childOrder.getRechargePlatform() != null) { model.setRechargePlatform(RechargePlatformType.getDataByType(childOrder.getRechargePlatform()).getName()); } model.setRemark(childOrder.getExt1()); } } model.setFinishTime(highOrder.getFinishTime()); model.setOrderStatus(OrderStatus.getDataByType(highOrder.getOrderStatus()).getName()); model.setMemPhone(highOrder.getMemPhone()); model.setCreateTime(highOrder.getCreateTime()); model.setTitle(highOrder.getTitle()); model.setPayablePrice(highOrder.getPayablePrice()); model.setRefundTime(highOrder.getRefundTime()); model.setPayPrice(highOrder.getPayPrice()); model.setOrderNo(highOrder.getOrderNo()); model.setMemCardNo(highOrder.getMemCardNo()); if (highOrder.getPayType() != null) { model.setPayType(OrderPayType.getDataByType(highOrder.getPayType()).getName()); } list.add(model); } String fileUrl = SysConst.getSysConfig().getFileUrl() + "temporary/"; String pathName = System.currentTimeMillis()+".xlsx"; File file = new File(fileUrl); if (!file.exists()) { file.mkdirs(); } EasyExcel.write(fileUrl+pathName) .head(ExportOrderMobileModel.class) .sheet("话费交易订单") .doWrite(list); return ResponseMsgUtil.success(pathName); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } public OutRechargeChildOrder mobileChildOrderHandle(HighOrder highOrder , OutRechargeOrder outRechargeOrder) { // 组装查询子订单数据 Map childOrderMap101 = new HashMap<>(); childOrderMap101.put("parent_order_id", outRechargeOrder.getId()); childOrderMap101.put("status", "101,102"); // 查询充值订单 List childOrders = childOrderService.getListRechargeChildOrder(childOrderMap101); OutRechargeChildOrder childOrder; // 判读是否存在多个充值中的订单 if (childOrders.size() > 0) { childOrder = childOrders.get(0); if (childOrders.size() > 1) { childOrder.setExt1("当前订单存在多个充值订单"); } } else { childOrder = childOrderService.findByOrderId(outRechargeOrder.getId()); if (childOrder != null && highOrder != null && childOrder.getStatus() != null && highOrder.getOrderStatus() != null) { if (highOrder.getOrderStatus() == 2 && childOrder.getStatus() != 102) { childOrder.setExt1("主订单充值中,但是充值订单状态不为充值中"); } if (highOrder.getOrderStatus() == 3 && childOrder.getStatus() != 101) { childOrder.setExt1("主订单充值成功,但是充值订单状态不为充值成功"); } if (highOrder.getOrderStatus() == 4 && !(childOrder.getStatus() == 103 || childOrder.getStatus() == 104)) { childOrder.setExt1("主订单退款,但是充值订单状态不为退款"); } } } return childOrder; } @RequestMapping(value = "/externalOrderRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "对外订单退款") public ResponseData externalOrderRefund(@RequestParam(name = "paySerialNo", required = true) String paySerialNo, @RequestParam(name = "WxMchId", required = true) String WxMchId, @RequestParam(name = "payRealPrice", required = true) String payRealPrice) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); mapPost.put("merchId" , "20230394901"); mapPost.put("paySerialNo" , paySerialNo); mapPost.put("wxMchId" , WxMchId); mapPost.put("payRealPrice" , payRealPrice); mapPost.put("refundPrice" , payRealPrice); Map map = new HashMap<>(); map.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); map.put("merchId" , "20230394901"); map.put("paySerialNo" , paySerialNo); map.put("wxMchId" , WxMchId); map.put("payRealPrice" , payRealPrice); map.put("refundPrice" , payRealPrice); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/order/externalOrderRefund" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file diff --git a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java index a13efa27..cfb3f453 100644 --- a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java +++ b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java @@ -139,6 +139,7 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/sendSms/*") .excludePathPatterns("/test/*") .excludePathPatterns("/sms/*") + .excludePathPatterns("/goods/*") .excludePathPatterns("/SendSms/*") .excludePathPatterns("/czOrder/*") .excludePathPatterns("/outRechargePrice/*") diff --git a/hai-cweb/src/main/java/com/cweb/controller/CommonController.java b/hai-cweb/src/main/java/com/cweb/controller/CommonController.java index f3953224..899146ff 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/CommonController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/CommonController.java @@ -6,6 +6,7 @@ import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.utils.HttpsUtils; +import com.hai.common.utils.RedisUtil; import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; import com.hai.config.WeChatQrcodeUtils; @@ -46,10 +47,7 @@ public class CommonController { private BsCompanyService bsCompanyService; @Autowired - private WeChatQrcodeUtils weChatQrcodeUtils; - - @Resource - private HighOrderService highOrderService; + private RedisUtil redisUtil; @Resource private BsIntegralRebateService bsIntegralRebateService; @@ -377,4 +375,33 @@ public class CommonController { } } + @RequestMapping(value = "/getRegional", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取区域信息") + public ResponseData getRegional() { + try { + + Object data = redisUtil.get("regional"); + + if (data == null) { + + List jsonObjects = commonService.getRegional(); + redisUtil.set("regional" , jsonObjects); + + return ResponseMsgUtil.success(jsonObjects); + + } else { + return ResponseMsgUtil.success(data); + } + + + + + } catch (Exception e) { + log.error("HighOrderController --> unionStagingPay() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + } diff --git a/hai-cweb/src/main/java/com/cweb/controller/Goods/GoodsController.java b/hai-cweb/src/main/java/com/cweb/controller/Goods/GoodsController.java new file mode 100644 index 00000000..8fa03726 --- /dev/null +++ b/hai-cweb/src/main/java/com/cweb/controller/Goods/GoodsController.java @@ -0,0 +1,170 @@ +package com.cweb.controller.Goods; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; +import com.hai.common.security.SessionObject; +import com.hai.common.security.UserCenter; +import com.hai.common.utils.ResponseMsgUtil; +import com.hai.entity.GoodsDetail; +import com.hai.entity.GoodsSku; +import com.hai.goods.model.GoodsModel; +import com.hai.goods.service.GoodsDetailService; +import com.hai.goods.service.GoodsSkuService; +import com.hai.model.ResponseData; +import com.hai.model.UserInfoModel; +import com.hai.service.HighGoodsTypeService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; +import java.util.*; + +@Controller +@RequestMapping(value = "/goods") +@Api(value = "商品") +public class GoodsController { + Logger log = LoggerFactory.getLogger(GoodsController.class); + + @Resource + private GoodsDetailService goodsDetailService; + + @Autowired + private UserCenter userCenter; + + @Resource + private HighGoodsTypeService highGoodsTypeService; + + @Resource + private GoodsSkuService goodsSkuService; + + @RequestMapping(value = "/getListGoodsDetail", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询商品列表") + public ResponseData getListGoodsDetail( + @RequestParam(value = "title", required = false) String title, + @RequestParam(value = "goodsType", required = false) Long goodsType, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize + ) { + try { + + + Map map = new HashMap<>(); + + map.put("title", title); + map.put("goodsType", goodsType); + map.put("status", 1); + + PageHelper.startPage(pageNum,pageSize); + + List list = goodsDetailService.getGoodsDetailList(map); + + List goodsModels = new ArrayList<>(); + + for (GoodsDetail goodsDetail : list) { + + GoodsModel goodsModel = new GoodsModel(); + + List goodsSku = goodsSkuService.getGoodsSkuList(goodsDetail.getId()); + if (goodsSku.size() > 0) { + BigDecimal minPrice = goodsSku.get(0).getPrice(); + BigDecimal minOriginalPrice = goodsSku.get(0).getOriginalPrice(); + + for (GoodsSku sku : goodsSku) { + if (sku.getPrice().compareTo(minPrice) < 0) { + minPrice = sku.getPrice(); + minOriginalPrice = sku.getOriginalPrice(); + } + } + BeanUtils.copyProperties(goodsDetail, goodsModel); + goodsModel.setOriginalPrice(minOriginalPrice); + goodsModel.setPrice(minPrice); + goodsModel.setWhetherMultiple(goodsSku.size() != 1); + + goodsModels.add(goodsModel); + + } + } + + return ResponseMsgUtil.success(new PageInfo<>(goodsModels)); + + } catch (Exception e) { + log.error("GoodsDetailController --> getListUser() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + + @RequestMapping(value = "/findGoodsDetailById", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询商品详情") + public ResponseData findGoodsDetailById( + @RequestParam(value = "id", required = true) Long id + ) { + try { + + GoodsDetail goodsDetail = goodsDetailService.findGoodsDetailById(id); + + if (goodsDetail == null) { + log.error("GoodsDetailController -> findGoodsDetailById() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相关商品信息"); + } + + return ResponseMsgUtil.success(goodsDetail); + + } catch (Exception e) { + log.error("GoodsDetailController --> findGoodsDetailById() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/findGoodsSkuByGoodsId", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询商品sku") + public ResponseData findGoodsSkuByGoodsId( + @RequestParam(value = "goodsId", required = true) Long goodsId + ) { + try { + + List goodsSkus = goodsSkuService.getGoodsSkuList(goodsId); + + if (goodsSkus.size() == 0) { + log.error("GoodsDetailController -> findGoodsDetailById() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相关商品规格信息"); + } + + return ResponseMsgUtil.success(goodsSkus); + + } catch (Exception e) { + log.error("GoodsDetailController --> findGoodsDetailById() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/getGoodsTypeTree", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取商品类型树结构") + public ResponseData getGoodsTypeTree(@RequestParam(name = "businessType", required = true) Integer businessType) { + try { + + return ResponseMsgUtil.success(highGoodsTypeService.getGoodsTypeTree(businessType)); + + } catch (Exception e) { + log.error("HighOrderController --> getUserOrderList() error!", e); + return ResponseMsgUtil.exception(e); + } + } + +} + diff --git a/hai-cweb/src/main/java/com/cweb/controller/Goods/ShoppingCartController.java b/hai-cweb/src/main/java/com/cweb/controller/Goods/ShoppingCartController.java new file mode 100644 index 00000000..d29ad975 --- /dev/null +++ b/hai-cweb/src/main/java/com/cweb/controller/Goods/ShoppingCartController.java @@ -0,0 +1,222 @@ +package com.cweb.controller.Goods; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; +import com.hai.common.security.SessionObject; +import com.hai.common.security.UserCenter; +import com.hai.common.utils.ResponseMsgUtil; +import com.hai.entity.GoodsDetail; +import com.hai.entity.GoodsShoppingCart; +import com.hai.entity.GoodsShoppingCartExample; +import com.hai.entity.GoodsSku; +import com.hai.goods.model.GoodsModel; +import com.hai.goods.model.ShoppingCartModel; +import com.hai.goods.service.GoodsDetailService; +import com.hai.goods.service.GoodsSkuService; +import com.hai.goods.service.ShoppingCartService; +import com.hai.model.HighUserModel; +import com.hai.model.ResponseData; +import com.hai.model.UserInfoModel; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; +import java.util.*; + +@Controller +@RequestMapping(value = "/shoppingCart") +@Api(value = "购物车") +public class ShoppingCartController { + + Logger log = LoggerFactory.getLogger(GoodsController.class); + + @Autowired + private UserCenter userCenter; + + @Resource + private GoodsDetailService goodsDetailService; + + @Resource + private GoodsSkuService goodsSkuService; + + @Resource + private ShoppingCartService shoppingCartService; + + @RequestMapping(value = "/getShoppingCartList", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询购物车列表") + public ResponseData getShoppingCartList( + HttpServletRequest request + ) { + try { + + // 用户 + SessionObject sessionObject = userCenter.getSessionObject(request); + HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); + + Map map = new HashMap<>(); + + map.put("userId", userInfoModel.getHighUser().getId()); + + List list = shoppingCartService.getShoppingCartList(map); + + List shoppingCartModels = new ArrayList<>(); + + for (GoodsShoppingCart shoppingCart : list) { + + ShoppingCartModel shoppingCartModel = new ShoppingCartModel(); + + BeanUtils.copyProperties(shoppingCart, shoppingCartModel); + + GoodsSku sku = goodsSkuService.findGoodsSkuById(Long.valueOf(shoppingCart.getSku())); + shoppingCartModel.setSkuName(sku.getName()); + + shoppingCartModels.add(shoppingCartModel); + + } + + return ResponseMsgUtil.success(new PageInfo<>(shoppingCartModels)); + + } catch (Exception e) { + log.error("GoodsDetailController --> getListUser() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + + @RequestMapping(value = "/insertShoppingCart", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "新增购物车") + public ResponseData insertShoppingCart(@RequestBody GoodsShoppingCart shoppingCart, HttpServletRequest request) { + try { + + // 用户 + SessionObject sessionObject = userCenter.getSessionObject(request); + HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); + + if (shoppingCart == null || + shoppingCart.getGoodsId() == null || + shoppingCart.getSku() == null || + shoppingCart.getNum() == null || + shoppingCart.getWhetherCheck() == null + ) { + log.error("GoodsDetailController -> insertProduct() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + GoodsDetail goodsDetail = goodsDetailService.findGoodsDetailById(shoppingCart.getGoodsId()); + GoodsSku sku = goodsSkuService.findGoodsSkuById(Long.valueOf(shoppingCart.getSku())); + + if (goodsDetail == null || sku == null) { + log.error("GoodsDetailController -> insertProduct() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "添加商品不存在"); + } + + shoppingCart.setUserId(userInfoModel.getHighUser().getId()); + shoppingCart.setTitle(goodsDetail.getName()); + shoppingCart.setImg(goodsDetail.getListImg()); + shoppingCart.setPrice(sku.getPrice()); + shoppingCart.setCreateTime(new Date()); + shoppingCart.setUpdateTime(new Date()); + + shoppingCartService.insertShoppingCart(shoppingCart); + + return ResponseMsgUtil.success("新增成功"); + + } catch (Exception e) { + log.error("GoodsDetailController --> insertPrice() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/deleteShoppingCart", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "删除购物车信息") + public ResponseData deleteShoppingCart( + @RequestParam(value = "ids", required = true) String ids, HttpServletRequest request + ) { + try { + + // 用户 + SessionObject sessionObject = userCenter.getSessionObject(request); + HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); + + String[] idArray = ids.split(","); + + for (String id : idArray) { + + GoodsShoppingCart shoppingCart = shoppingCartService.findShoppingCartById(Long.valueOf(id)); + + if (shoppingCart == null) { + log.error("GoodsDetailController -> findGoodsDetailById() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相关信息"); + } + + if (!Objects.equals(userInfoModel.getHighUser().getId(), shoppingCart.getUserId())) { + log.error("GoodsDetailController -> findGoodsDetailById() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户信息错误"); + } + + + shoppingCartService.deleteShoppingCart(Long.valueOf(id)); + } + + return ResponseMsgUtil.success("删除成功"); + + } catch (Exception e) { + log.error("GoodsDetailController --> findGoodsDetailById() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/goodsAddNum", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "商品增加数量") + public ResponseData goodsAddNum( + @RequestParam(value = "id", required = true) Long id, HttpServletRequest request + ) { + try { + + // 用户 + SessionObject sessionObject = userCenter.getSessionObject(request); + HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); + + GoodsShoppingCart shoppingCart = shoppingCartService.findShoppingCartById(id); + + + + if (shoppingCart == null) { + log.error("GoodsDetailController -> findGoodsDetailById() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相关信息"); + } + + if (!Objects.equals(userInfoModel.getHighUser().getId(), shoppingCart.getUserId())) { + log.error("GoodsDetailController -> findGoodsDetailById() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户信息错误"); + } + + + shoppingCart.setNum(String.valueOf(Integer.parseInt(shoppingCart.getNum())+1)); + shoppingCart.setUpdateTime(new Date()); + + return ResponseMsgUtil.success("增加成功"); + + } catch (Exception e) { + log.error("GoodsDetailController --> findGoodsDetailById() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + +} diff --git a/hai-service/src/main/java/com/hai/goods/model/GoodsModel.java b/hai-service/src/main/java/com/hai/goods/model/GoodsModel.java new file mode 100644 index 00000000..3d01ff8b --- /dev/null +++ b/hai-service/src/main/java/com/hai/goods/model/GoodsModel.java @@ -0,0 +1,38 @@ +package com.hai.goods.model; + +import com.hai.entity.GoodsDetail; + +import java.math.BigDecimal; + +public class GoodsModel extends GoodsDetail { + + private BigDecimal price; + + private BigDecimal originalPrice; + + private Boolean whetherMultiple; + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } + + public BigDecimal getOriginalPrice() { + return originalPrice; + } + + public void setOriginalPrice(BigDecimal originalPrice) { + this.originalPrice = originalPrice; + } + + public Boolean getWhetherMultiple() { + return whetherMultiple; + } + + public void setWhetherMultiple(Boolean whetherMultiple) { + this.whetherMultiple = whetherMultiple; + } +} diff --git a/hai-service/src/main/java/com/hai/goods/model/ShoppingCartModel.java b/hai-service/src/main/java/com/hai/goods/model/ShoppingCartModel.java new file mode 100644 index 00000000..f66680a6 --- /dev/null +++ b/hai-service/src/main/java/com/hai/goods/model/ShoppingCartModel.java @@ -0,0 +1,16 @@ +package com.hai.goods.model; + +import com.hai.entity.GoodsShoppingCart; + +public class ShoppingCartModel extends GoodsShoppingCart { + + private String skuName; + + public String getSkuName() { + return skuName; + } + + public void setSkuName(String skuName) { + this.skuName = skuName; + } +} diff --git a/hai-service/src/main/java/com/hai/goods/service/GoodsDetailService.java b/hai-service/src/main/java/com/hai/goods/service/GoodsDetailService.java new file mode 100644 index 00000000..99d00d3f --- /dev/null +++ b/hai-service/src/main/java/com/hai/goods/service/GoodsDetailService.java @@ -0,0 +1,58 @@ +package com.hai.goods.service; + +import com.hai.entity.ApiMchProduct; +import com.hai.entity.GoodsDetail; + +import java.util.List; +import java.util.Map; + +/** + * @serviceName GoodsDetailService.java + * @author Sum1Dream + * @version 1.0.0 + * @Description // 商品详情业务 + * @createTime 15:00 2023/4/11 + **/ +public interface GoodsDetailService { + + /** + * @Author Sum1Dream + * @Name insertGoodsDetail + * @Description // 新增商品详情 + * @Date 15:08 2023/4/11 + * @Param [goodsDetail] + * @Return void + */ + void insertGoodsDetail(GoodsDetail goodsDetail); + + /** + * @Author Sum1Dream + * @Name updateGoodsDetail + * @Description // 更新商品详情 + * @Date 15:14 2023/4/11 + * @Param [goodsDetail] + * @Return void + */ + void updateGoodsDetail(GoodsDetail goodsDetail); + + /** + * @Author Sum1Dream + * @Name getGoodsDetailList + * @Description // 查询商品列表 + * @Date 15:17 2023/4/11 + * @Param [map] + * @Return java.util.List + */ + List getGoodsDetailList(Map map); + + + /** + * @Author Sum1Dream + * @Name findGoodsDetailById + * @Description // 根据id商品详情 + * @Date 16:19 2023/4/11 + * @Param [id] + * @Return com.hai.entity.GoodsDetail + */ + GoodsDetail findGoodsDetailById(Long id); +} diff --git a/hai-service/src/main/java/com/hai/goods/service/GoodsSkuService.java b/hai-service/src/main/java/com/hai/goods/service/GoodsSkuService.java new file mode 100644 index 00000000..45b5af9e --- /dev/null +++ b/hai-service/src/main/java/com/hai/goods/service/GoodsSkuService.java @@ -0,0 +1,59 @@ +package com.hai.goods.service; + +import com.hai.entity.GoodsSku; + +import java.util.List; +import java.util.Map; + +/** + * @serviceName GoodsSkuService.java + * @author Sum1Dream + * @version 1.0.0 + * @Description // 商品sku业务 + * @createTime 18:03 2023/4/12 + **/ +public interface GoodsSkuService { + + /** + * @Author Sum1Dream + * @Name insertGoodsSku + * @Description // 新增商品SKu + * @Date 15:08 2023/4/11 + * @Param [GoodsSku] + * @Return void + */ + void insertGoodsSku(GoodsSku goodsSku); + + /** + * @Author Sum1Dream + * @Name updateGoodsSku + * @Description // 更新商品SKu + * @Date 15:14 2023/4/11 + * @Param [GoodsSku] + * @Return void + */ + void updateGoodsSku(GoodsSku goodsSku); + + /** + * @Author Sum1Dream + * @Name getGoodsSkuList + * @Description // 查询商品SKu列表 + * @Date 15:17 2023/4/11 + * @Param [map] + * @Return java.util.List + */ + List getGoodsSkuList(Map map); + + List getGoodsSkuList(Long goodsId); + + /** + * @Author Sum1Dream + * @Name findGoodsSkuById + * @Description // 根据id商品SKu + * @Date 16:19 2023/4/11 + * @Param [id] + * @Return com.hai.entity.GoodsSku + */ + GoodsSku findGoodsSkuById(Long id); + +} diff --git a/hai-service/src/main/java/com/hai/goods/service/ShoppingCartService.java b/hai-service/src/main/java/com/hai/goods/service/ShoppingCartService.java new file mode 100644 index 00000000..5904d383 --- /dev/null +++ b/hai-service/src/main/java/com/hai/goods/service/ShoppingCartService.java @@ -0,0 +1,68 @@ +package com.hai.goods.service; + +import com.hai.entity.GoodsDetail; +import com.hai.entity.GoodsShoppingCart; + +import java.util.List; +import java.util.Map; + +/** + * @serviceName ShoppingCartService.java + * @author Sum1Dream + * @version 1.0.0 + * @Description // 购物车业务 + * @createTime 15:06 2023/4/13 + **/ +public interface ShoppingCartService { + + /** + * @Author Sum1Dream + * @Name insertShoppingCart + * @Description // 新增购物车 + * @Date 15:08 2023/4/11 + * @Param [shoppingCart] + * @Return void + */ + void insertShoppingCart(GoodsShoppingCart shoppingCart); + + /** + * @Author Sum1Dream + * @Name updateShoppingCart + * @Description // 更新购物车 + * @Date 15:14 2023/4/11 + * @Param [shoppingCart] + * @Return void + */ + void updateShoppingCart(GoodsShoppingCart shoppingCart); + + /** + * @Author Sum1Dream + * @Name getShoppingCartList + * @Description // 查询购物车列表 + * @Date 15:17 2023/4/11 + * @Param [map] + * @Return java.util.List + */ + List getShoppingCartList(Map map); + + + /** + * @Author Sum1Dream + * @Name findGoodsDetailById + * @Description // 查询详情 + * @Date 16:19 2023/4/11 + * @Param [id] + * @Return com.hai.entity.GoodsDetail + */ + GoodsShoppingCart findShoppingCartById(Long id); + + /** + * @Author Sum1Dream + * @Name DeleteShoppingCart + * @Description // 删除购物车 + * @Date 15:09 2023/4/13 + * @Param [id] + * @Return void + */ + void deleteShoppingCart(Long id); +} diff --git a/hai-service/src/main/java/com/hai/goods/service/impl/GoodsDetailServiceImpl.java b/hai-service/src/main/java/com/hai/goods/service/impl/GoodsDetailServiceImpl.java new file mode 100644 index 00000000..1e8b7bef --- /dev/null +++ b/hai-service/src/main/java/com/hai/goods/service/impl/GoodsDetailServiceImpl.java @@ -0,0 +1,56 @@ +package com.hai.goods.service.impl; + +import com.hai.dao.GoodsDetailMapper; +import com.hai.entity.ApiMerchantsExample; +import com.hai.entity.GoodsDetail; +import com.hai.entity.GoodsDetailExample; +import com.hai.goods.service.GoodsDetailService; +import org.apache.commons.collections4.MapUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + + +@Service("goodsDetailService") +public class GoodsDetailServiceImpl implements GoodsDetailService { + + @Resource + private GoodsDetailMapper goodsDetailMapper; + + @Override + public void insertGoodsDetail(GoodsDetail goodsDetail) { + goodsDetailMapper.insert(goodsDetail); + } + + @Override + public void updateGoodsDetail(GoodsDetail goodsDetail) { + goodsDetailMapper.updateByPrimaryKey(goodsDetail); + } + + @Override + public List getGoodsDetailList(Map map) { + + GoodsDetailExample example = new GoodsDetailExample(); + GoodsDetailExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getString(map, "name") != null) { + criteria.andNameLike("%" + MapUtils.getString(map, "name") + "%"); + } + if (MapUtils.getLong(map, "goodsType") != null) { + criteria.andGoodsTypeEqualTo(MapUtils.getLong(map, "goodsType") ); + } + if (MapUtils.getInteger(map, "status") != null) { + criteria.andStatusEqualTo(MapUtils.getInteger(map, "status") ); + } else { + criteria.andStatusNotEqualTo(0); + } + return goodsDetailMapper.selectByExample(example); + } + + @Override + public GoodsDetail findGoodsDetailById(Long id) { + return goodsDetailMapper.selectByPrimaryKey(id); + } +} diff --git a/hai-service/src/main/java/com/hai/goods/service/impl/GoodsSkuServiceImpl.java b/hai-service/src/main/java/com/hai/goods/service/impl/GoodsSkuServiceImpl.java new file mode 100644 index 00000000..6a5cfe7b --- /dev/null +++ b/hai-service/src/main/java/com/hai/goods/service/impl/GoodsSkuServiceImpl.java @@ -0,0 +1,64 @@ +package com.hai.goods.service.impl; + +import com.hai.dao.GoodsSkuMapper; +import com.hai.entity.GoodsDetailExample; +import com.hai.entity.GoodsSku; +import com.hai.entity.GoodsSkuExample; +import com.hai.goods.service.GoodsSkuService; +import org.apache.commons.collections4.MapUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +@Service("goodsSkuService") +public class GoodsSkuServiceImpl implements GoodsSkuService { + + @Resource + private GoodsSkuMapper goodsSkuMapper; + + @Override + public void insertGoodsSku(GoodsSku goodsSku) { + goodsSkuMapper.insert(goodsSku); + } + + @Override + public void updateGoodsSku(GoodsSku goodsSku) { + goodsSkuMapper.updateByPrimaryKey(goodsSku); + } + + @Override + public List getGoodsSkuList(Map map) { + GoodsSkuExample example = new GoodsSkuExample(); + GoodsSkuExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getString(map, "name") != null) { + criteria.andNameLike("%" + MapUtils.getString(map, "name") + "%"); + } + if (MapUtils.getInteger(map, "status") != null) { + criteria.andStatusEqualTo(MapUtils.getInteger(map, "status") ); + } else { + criteria.andStatusNotEqualTo(0); + } + if (MapUtils.getLong(map, "goodsId") != null) { + criteria.andGoodsIdEqualTo(MapUtils.getLong(map, "goodsId") ); + } + + return goodsSkuMapper.selectByExample(example); + } + + @Override + public List getGoodsSkuList(Long goodsId) { + GoodsSkuExample example = new GoodsSkuExample(); + GoodsSkuExample.Criteria criteria = example.createCriteria(); + criteria.andGoodsIdEqualTo(goodsId).andStatusEqualTo(1); + + return goodsSkuMapper.selectByExample(example); + } + + @Override + public GoodsSku findGoodsSkuById(Long id) { + return goodsSkuMapper.selectByPrimaryKey(id); + } +} diff --git a/hai-service/src/main/java/com/hai/goods/service/impl/ShoppingCartServiceImpl.java b/hai-service/src/main/java/com/hai/goods/service/impl/ShoppingCartServiceImpl.java new file mode 100644 index 00000000..042c2f2c --- /dev/null +++ b/hai-service/src/main/java/com/hai/goods/service/impl/ShoppingCartServiceImpl.java @@ -0,0 +1,51 @@ +package com.hai.goods.service.impl; + +import com.hai.dao.GoodsShoppingCartMapper; +import com.hai.entity.GoodsShoppingCart; +import com.hai.entity.GoodsShoppingCartExample; +import com.hai.goods.service.ShoppingCartService; +import org.apache.commons.collections4.MapUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +@Service("shoppingCartService") +public class ShoppingCartServiceImpl implements ShoppingCartService { + + @Resource + private GoodsShoppingCartMapper shoppingCartMapper; + + @Override + public void insertShoppingCart(GoodsShoppingCart shoppingCart) { + shoppingCartMapper.insert(shoppingCart); + } + + @Override + public void updateShoppingCart(GoodsShoppingCart shoppingCart) { + shoppingCartMapper.updateByPrimaryKey(shoppingCart); + } + + @Override + public List getShoppingCartList(Map map) { + GoodsShoppingCartExample example = new GoodsShoppingCartExample(); + GoodsShoppingCartExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getLong(map, "userId") != null) { + criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId")); + } + + return shoppingCartMapper.selectByExample(example); + } + + @Override + public GoodsShoppingCart findShoppingCartById(Long id) { + return shoppingCartMapper.selectByPrimaryKey(id); + } + + @Override + public void deleteShoppingCart(Long id) { + shoppingCartMapper.deleteByPrimaryKey(id); + } +} diff --git a/hai-service/src/main/java/com/hai/service/CommonService.java b/hai-service/src/main/java/com/hai/service/CommonService.java index 1e02830a..07e6f297 100644 --- a/hai-service/src/main/java/com/hai/service/CommonService.java +++ b/hai-service/src/main/java/com/hai/service/CommonService.java @@ -309,5 +309,23 @@ public interface CommonService { */ SecConfig findSecConfigByType(String codeType); + /** + * @Author Sum1Dream + * @Name getRegional + * @Description // 获取区域信息 + * @Date 16:56 2023/4/13 + * @Param [] + * @Return com.alibaba.fastjson.JSONObject + */ + List getRegional(); + /** + * @Author Sum1Dream + * @Name getSecRegion + * @Description // 获取地区信息 + * @Date 17:00 2023/4/13 + * @Param [parentId] + * @Return java.util.List + */ + List getSecRegion(Long parentId); } diff --git a/hai-service/src/main/java/com/hai/service/HighGoodsTypeService.java b/hai-service/src/main/java/com/hai/service/HighGoodsTypeService.java index ee2033c5..7ed85264 100644 --- a/hai-service/src/main/java/com/hai/service/HighGoodsTypeService.java +++ b/hai-service/src/main/java/com/hai/service/HighGoodsTypeService.java @@ -1,5 +1,6 @@ package com.hai.service; +import com.alibaba.fastjson.JSONObject; import com.hai.entity.HighGoodsType; import com.hai.entity.HighOrderPre; @@ -54,4 +55,14 @@ public interface HighGoodsTypeService { * @return void **/ void updateGoodsType(HighGoodsType highGoodsType); + + /** + * @Author Sum1Dream + * @Name getGoodsTypeTree + * @Description // 获取商品类型树结构 + * @Date 14:23 2023/4/12 + * @Param [businessType] + * @Return com.alibaba.fastjson.JSONObject + */ + List getGoodsTypeTree(Integer businessType); } diff --git a/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java index c0442626..e79380c2 100644 --- a/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java @@ -14,10 +14,7 @@ import com.hai.dao.order.OrderStatisticsMapperExt; import com.hai.entity.*; import com.hai.model.IndexCountModel; import com.hai.model.LineCountModel; -import com.hai.service.CommonService; -import com.hai.service.HighOrderService; -import com.hai.service.HighUserService; -import com.hai.service.SecConfigService; +import com.hai.service.*; import org.apache.commons.lang3.StringUtils; @@ -76,6 +73,7 @@ public class CommonServiceImpl implements CommonService { + private Map> dicCache = new HashMap>(); private List citiesCache = new ArrayList<>(); @@ -731,4 +729,67 @@ public class CommonServiceImpl implements CommonService { return null; } + + @Override + public List getRegional() { + + // 获取父类 + List regionListParent = getSecRegion(null); + + List jsonProvince = new ArrayList<>(); + + for (SecRegion secRegion : regionListParent) { + JSONObject provinceObject = new JSONObject(); + provinceObject.put("code" , secRegion.getRegionId()); + provinceObject.put("name" , secRegion.getRegionName()); + + List regionList = getSecRegion(secRegion.getRegionId()); + + if (regionList.size() > 0) { + List jsonCity = new ArrayList<>(); + for (SecRegion city : regionList) { + JSONObject objectCity = new JSONObject(); + objectCity.put("code" , city.getRegionId()); + objectCity.put("name" , city.getRegionName()); + + List areaList = getSecRegion(city.getRegionId()); + + if (areaList.size() > 0 ) { + List jsonArea = new ArrayList<>(); + for (SecRegion area : areaList) { + JSONObject objectArea = new JSONObject(); + objectArea.put("code" , area.getRegionId()); + objectArea.put("name" , area.getRegionName()); + jsonArea.add(objectArea); + } + provinceObject.put("childs" , jsonArea); + } + jsonCity.add(objectCity); + } + provinceObject.put("childs" , jsonCity); + + } + jsonProvince.add(provinceObject); + + } + + return jsonProvince; + } + + @Override + public List getSecRegion(Long parentId) { + + SecRegionExample example = new SecRegionExample(); + SecRegionExample.Criteria criteria = example.createCriteria(); + + if (parentId != null) { + criteria.andParentIdEqualTo(parentId); + }else { + criteria.andParentIdIsNull(); + } + criteria.andStatusEqualTo(1); + + + return regionMapper.selectByExample(example); + } } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighGoodsTypeServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighGoodsTypeServiceImpl.java index c78a6a7a..b15b0ceb 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighGoodsTypeServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighGoodsTypeServiceImpl.java @@ -1,13 +1,17 @@ package com.hai.service.impl; +import com.alibaba.fastjson.JSONObject; import com.hai.dao.HighGoodsTypeMapper; import com.hai.entity.HighGoodsType; import com.hai.entity.HighGoodsTypeExample; import com.hai.service.HighGoodsTypeService; +import net.sf.jsqlparser.statement.select.First; import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -36,6 +40,11 @@ public class HighGoodsTypeServiceImpl implements HighGoodsTypeService { if (MapUtils.getString(map, "userService") != null) { criteria.andUserServiceEqualTo(MapUtils.getString(map, "userService")); } + if (MapUtils.getInteger(map, "parentId") != null) { + criteria.andParentIdEqualTo(MapUtils.getInteger(map, "parentId")); + }else { + criteria.andParentIdIsNull(); + } criteria.andStatusEqualTo(1); @@ -72,4 +81,48 @@ public class HighGoodsTypeServiceImpl implements HighGoodsTypeService { highGoodsTypeMapper.updateByPrimaryKey(highGoodsType); } + + @Override + public List getGoodsTypeTree(Integer businessType) { + + Map map = new HashMap<>(); + map.put("businessType", String.valueOf(businessType)); + + + + // 获取顶级 + List goodsTypeList = getListGoodsType(map); + + List list = new ArrayList<>(); + + for (HighGoodsType goodsType: goodsTypeList) { + JSONObject object = new JSONObject(); + object.put("title" , goodsType.getTitle()); + object.put("key" , goodsType.getId()); + object.put("img" , goodsType.getImg()); + + map.clear(); + map.put("parentId" , goodsType.getId().toString()); + + List goodsTypesChild = getListGoodsType(map); + + // 判断是否存在子类 + if (goodsTypesChild.size() > 0) { + List listChild = new ArrayList<>(); + for (HighGoodsType goodsTypeChild: goodsTypesChild) { + JSONObject objectChild = new JSONObject(); + objectChild.put("title" , goodsTypeChild.getTitle()); + objectChild.put("key" , goodsTypeChild.getId()); + objectChild.put("img" , goodsTypeChild.getImg()); + objectChild.put("isLeaf" , true); + listChild.add(objectChild); + } + list.add(object); + object.put("children" , listChild); + object.put("selectable" , false); + } + + } + return list; + } }