:wq
Merge branch '2.0-dev' of http://gitea.dctpay.com/hurui/hai-server into 2.0-dev
new-dev
胡锐 2 years ago
commit 6af731d8d6
  1. 62
      hai-bweb/src/main/java/com/bweb/controller/CommonController.java
  2. 263
      hai-bweb/src/main/java/com/bweb/controller/Goods/GoodsDetailController.java
  3. 179
      hai-bweb/src/main/java/com/bweb/controller/Goods/GoodsPresentController.java
  4. 233
      hai-bweb/src/main/java/com/bweb/controller/Goods/GoodsRegionFreightController.java
  5. 208
      hai-bweb/src/main/java/com/bweb/controller/Goods/GoodsSkuController.java
  6. 2
      hai-bweb/src/main/java/com/bweb/controller/HighBrandController.java
  7. 43
      hai-bweb/src/main/java/com/bweb/controller/HighGoodsTypeController.java
  8. 2
      hai-bweb/src/main/java/com/bweb/controller/HighTestController.java
  9. 1
      hai-cweb/src/main/java/com/cweb/config/AuthConfig.java
  10. 163
      hai-cweb/src/main/java/com/cweb/controller/CommonController.java
  11. 255
      hai-cweb/src/main/java/com/cweb/controller/Goods/DeliveryAddressController.java
  12. 243
      hai-cweb/src/main/java/com/cweb/controller/Goods/GoodsController.java
  13. 219
      hai-cweb/src/main/java/com/cweb/controller/Goods/ShoppingCartController.java
  14. 10
      hai-order/src/main/java/com/web/controller/OrderController.java
  15. 1
      hai-service/src/main/java/com/hai/common/utils/PageUtil.java
  16. 18
      hai-service/src/main/java/com/hai/config/CommonConfig.java
  17. 3
      hai-service/src/main/java/com/hai/config/CommonSysConfig.java
  18. 41
      hai-service/src/main/java/com/hai/goods/model/GoodsModel.java
  19. 16
      hai-service/src/main/java/com/hai/goods/model/ShoppingCartModel.java
  20. 77
      hai-service/src/main/java/com/hai/goods/service/DeliveryAddressService.java
  21. 60
      hai-service/src/main/java/com/hai/goods/service/GoodsDetailService.java
  22. 77
      hai-service/src/main/java/com/hai/goods/service/GoodsLogisticsService.java
  23. 68
      hai-service/src/main/java/com/hai/goods/service/GoodsPresentService.java
  24. 89
      hai-service/src/main/java/com/hai/goods/service/GoodsRegionFreightService.java
  25. 59
      hai-service/src/main/java/com/hai/goods/service/GoodsSkuService.java
  26. 68
      hai-service/src/main/java/com/hai/goods/service/ShoppingCartService.java
  27. 72
      hai-service/src/main/java/com/hai/goods/service/impl/DeliveryAddressServiceImpl.java
  28. 62
      hai-service/src/main/java/com/hai/goods/service/impl/GoodsDetailServiceImpl.java
  29. 88
      hai-service/src/main/java/com/hai/goods/service/impl/GoodsLogisticsServiceImpl.java
  30. 53
      hai-service/src/main/java/com/hai/goods/service/impl/GoodsPresentServiceImpl.java
  31. 119
      hai-service/src/main/java/com/hai/goods/service/impl/GoodsRegionFreightServiceImpl.java
  32. 64
      hai-service/src/main/java/com/hai/goods/service/impl/GoodsSkuServiceImpl.java
  33. 51
      hai-service/src/main/java/com/hai/goods/service/impl/ShoppingCartServiceImpl.java
  34. 17
      hai-service/src/main/java/com/hai/order/model/CreateOrderChildModel.java
  35. 5
      hai-service/src/main/java/com/hai/order/model/CreateOrderModel.java
  36. 1
      hai-service/src/main/java/com/hai/order/type/OrderChildGoodsType.java
  37. 18
      hai-service/src/main/java/com/hai/service/CommonService.java
  38. 11
      hai-service/src/main/java/com/hai/service/HighGoodsTypeService.java
  39. 70
      hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java
  40. 53
      hai-service/src/main/java/com/hai/service/impl/HighGoodsTypeServiceImpl.java
  41. 4
      hai-service/src/main/resources/dev/commonConfig.properties

@ -7,9 +7,12 @@ import com.hai.common.exception.SysCode;
import com.hai.common.utils.DateUtil; import com.hai.common.utils.DateUtil;
import com.hai.common.utils.RedisUtil; import com.hai.common.utils.RedisUtil;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.CommonConfig;
import com.hai.config.TuanYouConfig; import com.hai.config.TuanYouConfig;
import com.hai.entity.GoodsLogistics;
import com.hai.entity.SecConfig; import com.hai.entity.SecConfig;
import com.hai.entity.SecDictionary; import com.hai.entity.SecDictionary;
import com.hai.goods.service.GoodsLogisticsService;
import com.hai.model.*; import com.hai.model.*;
import com.hai.service.CommonService; import com.hai.service.CommonService;
import com.hai.service.SecConfigService; import com.hai.service.SecConfigService;
@ -45,6 +48,9 @@ public class CommonController {
@Resource @Resource
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Resource
private GoodsLogisticsService logisticsService;
@RequestMapping(value="/getRedisValueByType",method= RequestMethod.GET) @RequestMapping(value="/getRedisValueByType",method= RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "查询redis中的value") @ApiOperation(value = "查询redis中的value")
@ -384,5 +390,61 @@ public class CommonController {
} }
} }
@RequestMapping(value = "/getLogisticsMsg", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据快递单号查询物流信息")
public ResponseData getLogisticsMsg(@RequestParam(name = "num", required = true) String num) {
try {
Object data = redisUtil.get("logisticsMsg" + num);
if (data == null) {
JSONObject jsonObjects = CommonConfig.getLogisticsMsg(num);
if (jsonObjects.getInteger("code") == 200 && jsonObjects.getBoolean("success")) {
GoodsLogistics logistics = logisticsService.editLogistics((JSONObject) jsonObjects.get("data"));
redisUtil.set("logisticsMsg" + num , logistics ,21600);
return ResponseMsgUtil.success(logistics);
}
return ResponseMsgUtil.success(jsonObjects);
} else {
return ResponseMsgUtil.success(data);
}
} catch (Exception e) {
log.error("HighOrderController --> getUserOrderList() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/getRegional", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取区域信息")
public ResponseData getRegional() {
try {
Object data = redisUtil.get("regionalB");
if (data == null) {
List<JSONObject> jsonObjects = commonService.getRegional("key" , "title" , "children");
redisUtil.set("regionalB", jsonObjects);
return ResponseMsgUtil.success(jsonObjects);
} else {
return ResponseMsgUtil.success(data);
}
} catch (Exception e) {
log.error("HighOrderController --> unionStagingPay() error!", e);
return ResponseMsgUtil.exception(e);
}
}
} }

@ -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<String, Object> map = new HashMap<>();
map.put("title", title);
map.put("status", status);
PageHelper.startPage(pageNum,pageSize);
List<GoodsDetail> 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);
}
}
}

@ -0,0 +1,179 @@
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.GoodsPresent;
import com.hai.goods.service.GoodsPresentService;
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.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 = "/goodsPresent")
@Api(value = "商品赠送")
public class GoodsPresentController {
Logger log = LoggerFactory.getLogger(GoodsPresentController.class);
@Resource
private GoodsPresentService presentService;
@Autowired
private UserCenter userCenter;
@RequestMapping(value = "/getListPresent", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询列表")
public ResponseData getListPresent(
@RequestParam(value = "goodsId", required = false) Long goodsId
) {
try {
Map<String, Object> map = new HashMap<>();
map.put("goodsId", goodsId);
return ResponseMsgUtil.success(presentService.getPresentList(map));
} catch (Exception e) {
log.error("GoodsDetailController --> getListUser() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/insertPresent", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "新增赠送内容")
public ResponseData insertPresent(@RequestBody GoodsPresent present, HttpServletRequest request) {
try {
// 用户
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (present == null ||
present.getGoodsId() == null ||
present.getNum() == null ||
present.getSourceId() == null ||
present.getSourceName() == null ||
present.getType() == null
) {
log.error("GoodsDetailController -> insertProduct() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
present.setOpId(userInfoModel.getSecUser().getId());
present.setOpName(userInfoModel.getSecUser().getLoginName());
present.setCreateTime(new Date());
present.setUpdateTime(new Date());
present.setStatus(String.valueOf(1));
presentService.insertPresent(present);
return ResponseMsgUtil.success("新增成功");
} catch (Exception e) {
log.error("GoodsDetailController --> insertPrice() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/updatePresent", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "更新赠送内容")
public ResponseData updatePresent(@RequestBody GoodsPresent present, HttpServletRequest request) {
try {
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (present == null ||
present.getId() == null ||
present.getGoodsId() == null ||
present.getNum() == null ||
present.getSourceId() == null ||
present.getSourceName() == null ||
present.getType() == null
) {
log.error("GoodsDetailController -> insertProduct() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
GoodsPresent goodsPresent = presentService.findPresentById(present.getId());
if (goodsPresent == null) {
log.error("GoodsDetailController -> insertProduct() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相关信息!");
}
present.setOpId(userInfoModel.getSecUser().getId());
present.setOpName(userInfoModel.getSecUser().getLoginName());
present.setStatus(present.getStatus());
present.setUpdateTime(new Date());
presentService.insertPresent(present);
return ResponseMsgUtil.success("新增成功");
} catch (Exception e) {
log.error("GoodsDetailController --> insertPrice() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/deletePresent", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "删除")
public ResponseData deletePresent(
@RequestParam(value = "id", required = true) Long id
, HttpServletRequest request
) {
try {
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
GoodsPresent goodsPresent = presentService.findPresentById(id);
if (goodsPresent == null) {
log.error("GoodsDetailController -> findGoodsDetailById() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相关信息");
}
goodsPresent.setStatus(String.valueOf(0));
goodsPresent.setUpdateTime(new Date());
goodsPresent.setOpId(userInfoModel.getSecUser().getId());
goodsPresent.setOpName(userInfoModel.getSecUser().getLoginName());
presentService.updatePresent(goodsPresent);
return ResponseMsgUtil.success("删除成功!");
} catch (Exception e) {
log.error("GoodsDetailController --> findGoodsDetailById() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -0,0 +1,233 @@
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.GoodsRegionFreight;
import com.hai.entity.HighGoodsType;
import com.hai.entity.SecRegion;
import com.hai.goods.service.GoodsRegionFreightService;
import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel;
import com.hai.service.CommonService;
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.*;
@Controller
@RequestMapping(value = "/regionFreight")
@Api(value = "区域运费业务")
public class GoodsRegionFreightController {
Logger log = LoggerFactory.getLogger(GoodsRegionFreightController.class);
@Resource
private GoodsRegionFreightService regionFreightService;
@Autowired
private UserCenter userCenter;
@Resource
private CommonService commonService;
@RequestMapping(value = "/getListRegionFreight", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询列表")
public ResponseData getListRegionFreight(
@RequestParam(value = "regionName", required = false) String regionName,
@RequestParam(value = "regionId", required = false) String regionId,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize
) {
try {
Map<String, Object> map = new HashMap<>();
map.put("regionName", regionName);
map.put("regionId", regionId);
PageHelper.startPage(pageNum,pageSize);
List<GoodsRegionFreight> list = regionFreightService.getRegionFreightList(map);
return ResponseMsgUtil.success(new PageInfo<>(list));
} catch (Exception e) {
log.error("GoodsDetailController --> getListUser() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/insertRegionFreight", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "新增产品")
public ResponseData insertRegionFreight(@RequestBody GoodsRegionFreight regionFreight, HttpServletRequest request) {
try {
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (regionFreight == null ||
regionFreight.getRegionId() == null ||
regionFreight.getFreightPrice() == null ||
regionFreight.getFreePostPrice() == null
) {
log.error("GoodsDetailController -> insertProduct() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
GoodsRegionFreight goodsRegionFreight = regionFreightService.findRegionFreightByRegionId(regionFreight.getRegionId());
if (goodsRegionFreight != null) {
log.error("GoodsDetailController -> insertProduct() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前区域已经配置!");
}
SecRegion region = commonService.getRegionsById(Long.valueOf(regionFreight.getRegionId()));
if (region == null) {
log.error("GoodsDetailController -> insertProduct() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "区域错误!");
}
regionFreight.setRegionName(region.getRegionName());
regionFreight.setOpId(userInfoModel.getSecUser().getId());
regionFreight.setStatus(1);
regionFreight.setOpName(userInfoModel.getSecUser().getLoginName());
regionFreight.setCreateTime(new Date());
regionFreight.setUpdateTime(new Date());
regionFreightService.insertRegionFreight(regionFreight);
return ResponseMsgUtil.success("新增成功");
} catch (Exception e) {
log.error("GoodsDetailController --> insertPrice() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/updateRegionFreight", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "修改产品")
public ResponseData updateRegionFreight(@RequestBody GoodsRegionFreight regionFreight, HttpServletRequest request) {
try {
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (regionFreight == null ||
regionFreight.getId() == null ||
regionFreight.getRegionId() == null ||
regionFreight.getFreightPrice() == null ||
regionFreight.getFreePostPrice() == null
) {
log.error("GoodsDetailController -> insertProduct() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
GoodsRegionFreight goodsRegionFreight = regionFreightService.findRegionFreightById(regionFreight.getId());
GoodsRegionFreight freightByRegionId = regionFreightService.findRegionFreightByRegionId(regionFreight.getRegionId());
if (goodsRegionFreight != null && !Objects.equals(freightByRegionId.getId(), goodsRegionFreight.getId())) {
log.error("GoodsDetailController -> insertProduct() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前区域已经配置!");
}
SecRegion region = commonService.getRegionsById(Long.valueOf(regionFreight.getRegionId()));
if (region == null) {
log.error("GoodsDetailController -> insertProduct() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "区域错误!");
}
if (goodsRegionFreight == null) {
log.error("GoodsDetailController -> insertProduct() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相关信息!");
}
regionFreight.setRegionName(region.getRegionName());
regionFreight.setOpId(userInfoModel.getSecUser().getId());
regionFreight.setStatus(goodsRegionFreight.getStatus());
regionFreight.setOpName(userInfoModel.getSecUser().getLoginName());
regionFreight.setCreateTime(goodsRegionFreight.getCreateTime());
regionFreight.setUpdateTime(new Date());
regionFreightService.updateRegionFreight(regionFreight);
return ResponseMsgUtil.success("修改成功");
} catch (Exception e) {
log.error("GoodsDetailController --> insertPrice() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/findRegionFreightById", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询商品")
public ResponseData findRegionFreightById(
@RequestParam(value = "id", required = true) Long id
) {
try {
GoodsRegionFreight goodsRegionFreight = regionFreightService.findRegionFreightById(id);
if (goodsRegionFreight == null) {
log.error("GoodsDetailController -> findGoodsDetailById() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相关信息");
}
return ResponseMsgUtil.success(goodsRegionFreight);
} catch (Exception e) {
log.error("GoodsDetailController --> findGoodsDetailById() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/deleteRegionFreight", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "删除")
public ResponseData deleteRegionFreight(
@RequestParam(value = "id", required = true) Long id
) {
try {
GoodsRegionFreight goodsRegionFreight = regionFreightService.findRegionFreightById(id);
if (goodsRegionFreight == null) {
log.error("GoodsDetailController -> findGoodsDetailById() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相关信息");
}
regionFreightService.deleteRegionFreight(goodsRegionFreight.getId());
return ResponseMsgUtil.success("删除成功");
} catch (Exception e) {
log.error("GoodsDetailController --> findGoodsDetailById() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -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<String, Object> 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);
}
}
}

@ -134,7 +134,6 @@ public class HighBrandController {
if (StringUtils.isBlank(highBrand.getTitle()) if (StringUtils.isBlank(highBrand.getTitle())
|| StringUtils.isBlank(highBrand.getImg()) || StringUtils.isBlank(highBrand.getImg())
|| highBrand.getGoodTypeId() == null
) { ) {
log.error("HighAgentController -> insertAgent() error!","参数错误"); log.error("HighAgentController -> insertAgent() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
@ -175,7 +174,6 @@ public class HighBrandController {
if (StringUtils.isBlank(highBrand.getTitle()) if (StringUtils.isBlank(highBrand.getTitle())
|| StringUtils.isBlank(highBrand.getImg()) || StringUtils.isBlank(highBrand.getImg())
|| highBrand.getId() == null || highBrand.getId() == null
|| highBrand.getGoodTypeId() == null
) { ) {
log.error("HighAgentController -> insertAgent() error!","参数错误"); log.error("HighAgentController -> insertAgent() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");

@ -1,5 +1,6 @@
package com.bweb.controller; package com.bweb.controller;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorCode;
@ -26,6 +27,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; 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<String,String> 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) @RequestMapping(value = "/getGoodsTypeById", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "根据id查询详情") @ApiOperation(value = "根据id查询详情")
@ -133,7 +172,6 @@ public class HighGoodsTypeController {
if (StringUtils.isBlank(highGoodsType.getTitle()) if (StringUtils.isBlank(highGoodsType.getTitle())
|| StringUtils.isBlank(highGoodsType.getImg())
|| highGoodsType.getBusinessType() == null || highGoodsType.getBusinessType() == null
) { ) {
log.error("HighAgentController -> insertAgent() error!","参数错误"); log.error("HighAgentController -> insertAgent() error!","参数错误");
@ -174,7 +212,6 @@ public class HighGoodsTypeController {
if (StringUtils.isBlank(highGoodsType.getTitle()) if (StringUtils.isBlank(highGoodsType.getTitle())
|| StringUtils.isBlank(highGoodsType.getImg())
|| highGoodsType.getBusinessType() == null || highGoodsType.getBusinessType() == null
|| highGoodsType.getId() == null || highGoodsType.getId() == null
) { ) {
@ -193,6 +230,8 @@ public class HighGoodsTypeController {
highGoodsTypes.setUpdatedTime(new Date()); highGoodsTypes.setUpdatedTime(new Date());
highGoodsTypes.setUpdatedUserId(userInfoModel.getSecUser().getId().intValue()); highGoodsTypes.setUpdatedUserId(userInfoModel.getSecUser().getId().intValue());
highGoodsTypes.setImg(highGoodsType.getImg()); highGoodsTypes.setImg(highGoodsType.getImg());
highGoodsTypes.setParentId(highGoodsType.getParentId());
highGoodsTypes.setBusinessType(highGoodsType.getBusinessType());
highGoodsTypes.setCompanyId(userInfoModel.getBsCompany().getId()); highGoodsTypes.setCompanyId(userInfoModel.getBsCompany().getId());
highGoodsTypes.setTitle(highGoodsType.getTitle()); highGoodsTypes.setTitle(highGoodsType.getTitle());

File diff suppressed because one or more lines are too long

@ -139,6 +139,7 @@ public class AuthConfig implements WebMvcConfigurer {
.excludePathPatterns("/sendSms/*") .excludePathPatterns("/sendSms/*")
.excludePathPatterns("/test/*") .excludePathPatterns("/test/*")
.excludePathPatterns("/sms/*") .excludePathPatterns("/sms/*")
.excludePathPatterns("/goods/*")
.excludePathPatterns("/SendSms/*") .excludePathPatterns("/SendSms/*")
.excludePathPatterns("/czOrder/*") .excludePathPatterns("/czOrder/*")
.excludePathPatterns("/outRechargePrice/*") .excludePathPatterns("/outRechargePrice/*")

@ -6,10 +6,12 @@ import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode; import com.hai.common.exception.SysCode;
import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.HttpsUtils;
import com.hai.common.utils.RedisUtil;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.common.utils.WxUtils; import com.hai.common.utils.WxUtils;
import com.hai.config.WeChatQrcodeUtils; import com.hai.config.WeChatQrcodeUtils;
import com.hai.entity.*; import com.hai.entity.*;
import com.hai.goods.service.GoodsRegionFreightService;
import com.hai.model.ResponseData; import com.hai.model.ResponseData;
import com.hai.service.*; import com.hai.service.*;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -30,8 +32,8 @@ import java.util.Map;
@RestController @RestController
@RequestMapping(value="/common") @RequestMapping(value = "/common")
@Api(value="共用接口") @Api(value = "共用接口")
public class CommonController { public class CommonController {
Logger log = LoggerFactory.getLogger(CommonController.class); Logger log = LoggerFactory.getLogger(CommonController.class);
@ -46,22 +48,22 @@ public class CommonController {
private BsCompanyService bsCompanyService; private BsCompanyService bsCompanyService;
@Autowired @Autowired
private WeChatQrcodeUtils weChatQrcodeUtils; private RedisUtil redisUtil;
@Resource @Resource
private HighOrderService highOrderService; private BsIntegralRebateService bsIntegralRebateService;
@Resource @Resource
private BsIntegralRebateService bsIntegralRebateService; private GoodsRegionFreightService goodsRegionFreightService;
@RequestMapping(value="/getDredgeProvince",method= RequestMethod.GET) @RequestMapping(value = "/getDredgeProvince", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "查询已开通的省份") @ApiOperation(value = "查询已开通的省份")
public ResponseData getDredgeProvince(){ public ResponseData getDredgeProvince() {
try { try {
List<BsCompany> list = bsCompanyService.getCompany(new HashMap<>()); List<BsCompany> list = bsCompanyService.getCompany(new HashMap<>());
List<Map<String,Object>> mapList = new ArrayList<>(); List<Map<String, Object>> mapList = new ArrayList<>();
Map<String,Object> map; Map<String, Object> map;
if (list.size() > 0) { if (list.size() > 0) {
for (BsCompany company : list) { for (BsCompany company : list) {
map = new HashMap<>(); map = new HashMap<>();
@ -82,12 +84,12 @@ public class CommonController {
} }
} }
@RequestMapping(value="/getRegionsByParentId",method= RequestMethod.GET) @RequestMapping(value = "/getRegionsByParentId", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "分级查询区域信息") @ApiOperation(value = "分级查询区域信息")
public ResponseData getRegionsByParentId(@RequestParam(name = "regionId", required = false) Long regionId){ public ResponseData getRegionsByParentId(@RequestParam(name = "regionId", required = false) Long regionId) {
try { try {
if (regionId == null){ if (regionId == null) {
return ResponseMsgUtil.success(commonService.getCities()); return ResponseMsgUtil.success(commonService.getCities());
} }
return ResponseMsgUtil.success(commonService.getRegionsByParentId(regionId)); return ResponseMsgUtil.success(commonService.getRegionsByParentId(regionId));
@ -96,7 +98,7 @@ public class CommonController {
} }
} }
@RequestMapping(value="/getParentInfosByRegionId",method= RequestMethod.GET) @RequestMapping(value = "/getParentInfosByRegionId", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "查询父级区域信息") @ApiOperation(value = "查询父级区域信息")
public ResponseData getParentInfosByRegionId(@RequestParam(name = "regionId", required = true) Long regionId) { public ResponseData getParentInfosByRegionId(@RequestParam(name = "regionId", required = true) Long regionId) {
@ -107,10 +109,10 @@ public class CommonController {
} }
} }
@RequestMapping(value="/getRegionsById",method= RequestMethod.GET) @RequestMapping(value = "/getRegionsById", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "查询区域详细信息") @ApiOperation(value = "查询区域详细信息")
public ResponseData getRegionsById(@RequestParam(name = "regionId", required = true) Long regionId){ public ResponseData getRegionsById(@RequestParam(name = "regionId", required = true) Long regionId) {
try { try {
return ResponseMsgUtil.success(commonService.getRegionsById(regionId)); return ResponseMsgUtil.success(commonService.getRegionsById(regionId));
} catch (Exception e) { } catch (Exception e) {
@ -119,10 +121,10 @@ public class CommonController {
} }
@RequestMapping(value="/getDictionaries",method= RequestMethod.GET) @RequestMapping(value = "/getDictionaries", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "查询数据字典") @ApiOperation(value = "查询数据字典")
public ResponseData getDictionaries(){ public ResponseData getDictionaries() {
try { try {
return ResponseMsgUtil.success(commonService.getDictionaries()); return ResponseMsgUtil.success(commonService.getDictionaries());
} catch (Exception e) { } catch (Exception e) {
@ -131,8 +133,7 @@ public class CommonController {
} }
@RequestMapping(value = "/getDictionaryByCodeType", method = RequestMethod.GET)
@RequestMapping(value="/getDictionaryByCodeType",method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "根据 码值类型 查询数据字典") @ApiOperation(value = "根据 码值类型 查询数据字典")
public ResponseData getDictionaryByCodeType(@RequestParam(name = "codeType", required = true) String codeType) { public ResponseData getDictionaryByCodeType(@RequestParam(name = "codeType", required = true) String codeType) {
@ -146,7 +147,7 @@ public class CommonController {
} }
} }
@RequestMapping(value="/mappingSysNameOl",method = RequestMethod.GET) @RequestMapping(value = "/mappingSysNameOl", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "根据 码值类型 查询数据字典") @ApiOperation(value = "根据 码值类型 查询数据字典")
public ResponseData mappingSysNameOl(@RequestParam(name = "codeType", required = true) String codeType) { public ResponseData mappingSysNameOl(@RequestParam(name = "codeType", required = true) String codeType) {
@ -160,7 +161,7 @@ public class CommonController {
} }
} }
@RequestMapping(value="/getDictionaryByCodeTypeOl",method = RequestMethod.GET) @RequestMapping(value = "/getDictionaryByCodeTypeOl", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "根据 码值类型 查询数据字典") @ApiOperation(value = "根据 码值类型 查询数据字典")
public ResponseData getDictionaryByCodeTypeOl(@RequestParam(name = "codeType", required = true) String codeType) { public ResponseData getDictionaryByCodeTypeOl(@RequestParam(name = "codeType", required = true) String codeType) {
@ -174,13 +175,10 @@ public class CommonController {
} }
} }
@RequestMapping(value="/updateDictionary",method = RequestMethod.GET) @RequestMapping(value = "/updateDictionary", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "根据 码值类型 查询数据字典") @ApiOperation(value = "根据 码值类型 查询数据字典")
public ResponseData updateDictionary( public ResponseData updateDictionary(@RequestParam(name = "codeType", required = true) String codeType, @RequestParam(name = "codeValue", required = true) String codeValue) {
@RequestParam(name = "codeType", required = true) String codeType,
@RequestParam(name = "codeValue", required = true) String codeValue
) {
try { try {
SecConfig secConfig = secConfigService.findByCodeType(codeType); SecConfig secConfig = secConfigService.findByCodeType(codeType);
@ -194,13 +192,13 @@ public class CommonController {
} }
} }
@RequestMapping(value="/getDictionaryByCodeTypeAndExt",method = RequestMethod.GET) @RequestMapping(value = "/getDictionaryByCodeTypeAndExt", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "根据 码值类型 查询数据字典") @ApiOperation(value = "根据 码值类型 查询数据字典")
public ResponseData getDictionaryByCodeTypeAndExt(@RequestParam(name = "codeType", required = true) String codeType, String ext1) { public ResponseData getDictionaryByCodeTypeAndExt(@RequestParam(name = "codeType", required = true) String codeType, String ext1) {
try { try {
return ResponseMsgUtil.success(commonService.getDictionarysAndExt(codeType,ext1)); return ResponseMsgUtil.success(commonService.getDictionarysAndExt(codeType, ext1));
} catch (Exception e) { } catch (Exception e) {
log.error("CommonController --> getDictionaryByCodeType() error!", e); log.error("CommonController --> getDictionaryByCodeType() error!", e);
@ -208,7 +206,7 @@ public class CommonController {
} }
} }
@RequestMapping(value="/getIdAndNameByCodeType",method = RequestMethod.GET) @RequestMapping(value = "/getIdAndNameByCodeType", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "根据 码值类型 查询数据字典的id和name") @ApiOperation(value = "根据 码值类型 查询数据字典的id和name")
public ResponseData getIdAndNameByCodeType(@RequestParam(name = "codeType", required = true) String codeType) { public ResponseData getIdAndNameByCodeType(@RequestParam(name = "codeType", required = true) String codeType) {
@ -222,14 +220,13 @@ public class CommonController {
} }
} }
@RequestMapping(value="/getDictionaryByCodeTypeAndValue",method = RequestMethod.GET) @RequestMapping(value = "/getDictionaryByCodeTypeAndValue", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "根据码值类型及value查询数据字典") @ApiOperation(value = "根据码值类型及value查询数据字典")
public ResponseData getDictionaryByCodeType(@RequestParam(name = "codeType", required = true) String codeType, public ResponseData getDictionaryByCodeType(@RequestParam(name = "codeType", required = true) String codeType, @RequestParam(name = "codeValue", required = true) String codeValue) {
@RequestParam(name = "codeValue", required = true) String codeValue) {
try { try {
return ResponseMsgUtil.success(commonService.mappingSysCode(codeType,codeValue)); return ResponseMsgUtil.success(commonService.mappingSysCode(codeType, codeValue));
} catch (Exception e) { } catch (Exception e) {
log.error("CommonController --> getDictionaryByCodeTypeAndValue() error!", e); log.error("CommonController --> getDictionaryByCodeTypeAndValue() error!", e);
@ -237,7 +234,7 @@ public class CommonController {
} }
} }
@RequestMapping(value="/findSecConfigByType",method = RequestMethod.GET) @RequestMapping(value = "/findSecConfigByType", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "根据码值类型查询数据") @ApiOperation(value = "根据码值类型查询数据")
public ResponseData findSecConfigByType(@RequestParam(name = "codeType", required = true) String codeType) { public ResponseData findSecConfigByType(@RequestParam(name = "codeType", required = true) String codeType) {
@ -255,44 +252,41 @@ public class CommonController {
@RequestMapping(value = "/findByLatAndLng", method = RequestMethod.GET) @RequestMapping(value = "/findByLatAndLng", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "获取定位信息") @ApiOperation(value = "获取定位信息")
public ResponseData findByLatAndLng( public ResponseData findByLatAndLng(@RequestParam(name = "lng", required = true) String lng, @RequestParam(name = "lat", required = true) String lat) {
@RequestParam(name = "lng", required = true) String lng,
@RequestParam(name = "lat", required = true) String lat
) {
try { try {
JSONObject jsonObjectR = commonService.findByLatAndLng(lng , lat); JSONObject jsonObjectR = commonService.findByLatAndLng(lng, lat);
if (!jsonObjectR.getString("status").equals("0")) { if (!jsonObjectR.getString("status").equals("0")) {
log.error("findByLatAndLng error!", "定位错误,请重新定位" ); log.error("findByLatAndLng error!", "定位错误,请重新定位");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "定位错误,请重新定位"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "定位错误,请重新定位");
} }
JSONObject object = commonService.findByLatAndLng(lng , lat).getJSONObject("result").getJSONObject("addressComponent"); JSONObject object = commonService.findByLatAndLng(lng, lat).getJSONObject("result").getJSONObject("addressComponent");
ApiCity apiCity = commonService.findCityByName(object.getString("city")); ApiCity apiCity = commonService.findCityByName(object.getString("city"));
if (apiCity == null) { if (apiCity == null) {
log.error("findByLatAndLng error!", "当前城市暂未开通任何服务" ); log.error("findByLatAndLng error!", "当前城市暂未开通任何服务");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前城市暂未开通任何服务,请选择其他城市"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前城市暂未开通任何服务,请选择其他城市");
} }
BsCompany company = bsCompanyService.selectCompanyByRegion(apiCity.getProvinceCode()); BsCompany company = bsCompanyService.selectCompanyByRegion(apiCity.getProvinceCode());
if (company == null) { if (company == null) {
log.error("findByLatAndLng error!", "当前城市暂未开通任何服务" ); log.error("findByLatAndLng error!", "当前城市暂未开通任何服务");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前城市暂未开通任何服务,请选择其他城市"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前城市暂未开通任何服务,请选择其他城市");
} }
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("cityName" , apiCity.getCityName()); jsonObject.put("cityName", apiCity.getCityName());
jsonObject.put("provinceName" , apiCity.getProvinceName()); jsonObject.put("provinceName", apiCity.getProvinceName());
jsonObject.put("regionId" , company.getRegionId()); jsonObject.put("regionId", company.getRegionId());
jsonObject.put("companyName" , company.getName()); jsonObject.put("companyName", company.getName());
jsonObject.put("companyId" , company.getId()); jsonObject.put("companyId", company.getId());
return ResponseMsgUtil.success(jsonObject); return ResponseMsgUtil.success(jsonObject);
@ -305,32 +299,30 @@ public class CommonController {
@RequestMapping(value = "/findCompanyByCityName", method = RequestMethod.GET) @RequestMapping(value = "/findCompanyByCityName", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "获取定位信息") @ApiOperation(value = "获取定位信息")
public ResponseData findCompanyByCityName( public ResponseData findCompanyByCityName(@RequestParam(name = "cityName", required = true) String cityName) {
@RequestParam(name = "cityName", required = true) String cityName
) {
try { try {
ApiCity apiCity = commonService.findCityByName(cityName); ApiCity apiCity = commonService.findCityByName(cityName);
if (apiCity == null) { if (apiCity == null) {
log.error("findByLatAndLng error!", "当前城市暂未开通任何服务" ); log.error("findByLatAndLng error!", "当前城市暂未开通任何服务");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前城市暂未开通任何服务,请选择其他城市"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前城市暂未开通任何服务,请选择其他城市");
} }
BsCompany company = bsCompanyService.selectCompanyByRegion(apiCity.getProvinceCode()); BsCompany company = bsCompanyService.selectCompanyByRegion(apiCity.getProvinceCode());
if (company == null) { if (company == null) {
log.error("findByLatAndLng error!", "当前城市暂未开通任何服务" ); log.error("findByLatAndLng error!", "当前城市暂未开通任何服务");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前城市暂未开通任何服务,请选择其他城市"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前城市暂未开通任何服务,请选择其他城市");
} }
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("cityName" , apiCity.getCityName()); jsonObject.put("cityName", apiCity.getCityName());
jsonObject.put("provinceName" , apiCity.getProvinceName()); jsonObject.put("provinceName", apiCity.getProvinceName());
jsonObject.put("regionId" , company.getRegionId()); jsonObject.put("regionId", company.getRegionId());
jsonObject.put("companyName" , company.getName()); jsonObject.put("companyName", company.getName());
jsonObject.put("companyId" , company.getId()); jsonObject.put("companyId", company.getId());
return ResponseMsgUtil.success(jsonObject); return ResponseMsgUtil.success(jsonObject);
@ -348,26 +340,23 @@ public class CommonController {
System.out.println(object); System.out.println(object);
if (object.getInteger("type") == null || if (object.getInteger("type") == null || object.getLong("companyId") == null || object.getBigDecimal("price") == null) {
object.getLong("companyId") == null || log.error("CommonController -> getRebateIntegral() error!", "请求参数校验失败");
object.getBigDecimal("price") == null
) {
log.error("CommonController -> getRebateIntegral() error!","请求参数校验失败");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR);
} }
// 查询订单来源 // 查询订单来源
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("type" , object.getInteger("type")); map.put("type", object.getInteger("type"));
map.put("companyId" , object.getLong("companyId")); map.put("companyId", object.getLong("companyId"));
BsIntegralRebate bsIntegralRebate = bsIntegralRebateService.findIntegralRebateByMap(map); BsIntegralRebate bsIntegralRebate = bsIntegralRebateService.findIntegralRebateByMap(map);
if (bsIntegralRebate == null) { if (bsIntegralRebate == null) {
throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "暂无积分返利活动"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂无积分返利活动");
} }
BigDecimal integralNum = object.getBigDecimal("price").multiply(bsIntegralRebate.getPercentage()).setScale( 0, BigDecimal.ROUND_HALF_UP ); BigDecimal integralNum = object.getBigDecimal("price").multiply(bsIntegralRebate.getPercentage()).setScale(0, BigDecimal.ROUND_HALF_UP);
return ResponseMsgUtil.success(integralNum); return ResponseMsgUtil.success(integralNum);
@ -377,4 +366,44 @@ 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<JSONObject> jsonObjects = commonService.getRegional("code" , "name" , "childs");
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);
}
}
@RequestMapping(value = "/getRegionFreight", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取区域运费")
public ResponseData getRegionFreight(@RequestParam(name = "regionId", required = true) String regionId) {
try {
return ResponseMsgUtil.success(goodsRegionFreightService.getRegionFreight(regionId));
} catch (Exception e) {
log.error("HighOrderController --> unionStagingPay() error!", e);
return ResponseMsgUtil.exception(e);
}
}
} }

@ -0,0 +1,255 @@
package com.cweb.controller.Goods;
import com.alibaba.fastjson.JSONObject;
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.GoodsDeliveryAddress;
import com.hai.entity.GoodsDetail;
import com.hai.entity.GoodsShoppingCart;
import com.hai.entity.GoodsSku;
import com.hai.goods.model.ShoppingCartModel;
import com.hai.goods.service.DeliveryAddressService;
import com.hai.goods.service.GoodsRegionFreightService;
import com.hai.model.HighUserModel;
import com.hai.model.ResponseData;
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.util.*;
@Controller
@RequestMapping(value = "/deliveryAddress")
@Api(value = "收货地址")
public class DeliveryAddressController {
Logger log = LoggerFactory.getLogger(DeliveryAddressController.class);
@Resource
private DeliveryAddressService deliveryAddressService;
@Autowired
private UserCenter userCenter;
@Resource
private GoodsRegionFreightService goodsRegionFreightService;
@RequestMapping(value = "/getDeliveryAddressList", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询收货地址列表")
public ResponseData getDeliveryAddressList(
HttpServletRequest request
) {
try {
// 用户
SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
Map<String, Object> map = new HashMap<>();
map.put("userId", userInfoModel.getHighUser().getId());
return ResponseMsgUtil.success(deliveryAddressService.getDeliveryAddressList(map));
} catch (Exception e) {
log.error("GoodsDetailController --> getListUser() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/insertDeliveryAddress", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "新增收货地址")
public ResponseData insertDeliveryAddress(@RequestBody GoodsDeliveryAddress deliveryAddress, HttpServletRequest request) {
try {
// 用户
SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
Map<String, Object> map = new HashMap<>();
map.put("userId", userInfoModel.getHighUser().getId());
List<GoodsDeliveryAddress> list = deliveryAddressService.getDeliveryAddressList(map);
if (list.size() == 0) {
deliveryAddress.setWhetherDefault(true);
}
if (deliveryAddress == null ||
deliveryAddress.getAddress() == null ||
deliveryAddress.getWhetherDefault() == null ||
deliveryAddress.getConsignee() == null ||
deliveryAddress.getPhone() == null ||
deliveryAddress.getRegionName() == null ||
deliveryAddress.getRegionId() == null
) {
log.error("GoodsDetailController -> insertProduct() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
deliveryAddress.setUserId(userInfoModel.getHighUser().getId());
deliveryAddress.setCreateTime(new Date());
deliveryAddress.setUpdateTime(new Date());
deliveryAddressService.insertDeliveryAddress(deliveryAddress);
return ResponseMsgUtil.success("新增成功");
} catch (Exception e) {
log.error("GoodsDetailController --> insertPrice() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/updateDeliveryAddress", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "修改收货地址")
public ResponseData updateDeliveryAddress(@RequestBody GoodsDeliveryAddress deliveryAddress, HttpServletRequest request) {
try {
// 用户
SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
if (deliveryAddress == null ||
deliveryAddress.getId() == null ||
deliveryAddress.getAddress() == null ||
deliveryAddress.getWhetherDefault() == null ||
deliveryAddress.getConsignee() == null ||
deliveryAddress.getPhone() == null ||
deliveryAddress.getRegionName() == null ||
deliveryAddress.getRegionId() == null
) {
log.error("GoodsDetailController -> insertProduct() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
if (deliveryAddress.getWhetherDefault()) {
deliveryAddressService.cleanDeliveryAddressDefault(deliveryAddress.getUserId());
}
GoodsDeliveryAddress goodsDeliveryAddress = deliveryAddressService.findDeliveryAddressById(deliveryAddress.getId());
if (goodsDeliveryAddress == null) {
log.error("GoodsDetailController -> insertProduct() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前收货地址异常!");
}
deliveryAddress.setUserId(userInfoModel.getHighUser().getId());
deliveryAddress.setCreateTime(goodsDeliveryAddress.getCreateTime());
deliveryAddress.setUpdateTime(new Date());
deliveryAddressService.updateDeliveryAddress(deliveryAddress);
return ResponseMsgUtil.success("修改成功");
} catch (Exception e) {
log.error("GoodsDetailController --> insertPrice() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/findDeliveryAddressById", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询收货地址详情")
public ResponseData findDeliveryAddressById(
@RequestParam(value = "id", required = true) Long id
) {
try {
GoodsDeliveryAddress deliveryAddress = deliveryAddressService.findDeliveryAddressById(id);
if (deliveryAddress == null) {
log.error("GoodsDetailController -> findGoodsDetailById() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相信息");
}
return ResponseMsgUtil.success(deliveryAddress);
} catch (Exception e) {
log.error("GoodsDetailController --> findGoodsDetailById() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/deleteDeliveryAddress", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "删除删除收货地址")
public ResponseData deleteDeliveryAddress(
@RequestParam(value = "id", required = true) Long id, HttpServletRequest request
) {
try {
// 用户
SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
GoodsDeliveryAddress deliveryAddress = deliveryAddressService.findDeliveryAddressById(id);
if (deliveryAddress == null) {
log.error("GoodsDetailController -> findGoodsDetailById() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相关信息");
}
if (!Objects.equals(userInfoModel.getHighUser().getId(), deliveryAddress.getUserId())) {
log.error("GoodsDetailController -> findGoodsDetailById() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户信息错误");
}
deliveryAddressService.deleteDeliveryAddress(id);
return ResponseMsgUtil.success("删除成功");
} catch (Exception e) {
log.error("GoodsDetailController --> findGoodsDetailById() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/getAddressPrice", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询收货地址包邮金额和运费金额")
public ResponseData getAddressPrice( HttpServletRequest request
) {
try {
// 用户
SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
Map<String, Object> map = new HashMap<>();
map.put("userId", userInfoModel.getHighUser().getId());
map.put("whetherDefault", true);
List<GoodsDeliveryAddress> list = deliveryAddressService.getDeliveryAddressList(map);
if (list.size() == 0) {
log.error("GoodsDetailController -> findGoodsDetailById() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相关信息");
}
JSONObject object = goodsRegionFreightService.getRegionFreight(list.get(0).getRegionId());
object.put("deliveryAddress" , list.get(0));
return ResponseMsgUtil.success(object);
} catch (Exception e) {
log.error("GoodsDetailController --> findGoodsDetailById() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -0,0 +1,243 @@
package com.cweb.controller.Goods;
import com.alibaba.fastjson.JSONObject;
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.PageUtil;
import com.hai.common.utils.RedisUtil;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.CommonConfig;
import com.hai.entity.*;
import com.hai.goods.model.GoodsModel;
import com.hai.goods.service.GoodsDetailService;
import com.hai.goods.service.GoodsLogisticsService;
import com.hai.goods.service.GoodsSkuService;
import com.hai.model.HighUserModel;
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.*;
import java.util.stream.Collectors;
@Controller
@RequestMapping(value = "/goods")
@Api(value = "商品")
public class GoodsController {
Logger log = LoggerFactory.getLogger(GoodsController.class);
@Resource
private GoodsDetailService goodsDetailService;
@Autowired
private RedisUtil redisUtil;
@Resource
private GoodsLogisticsService logisticsService;
@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(value = "price", required = false) Integer price,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize
) {
try {
Map<String, Object> map = new HashMap<>();
map.put("title", title);
map.put("goodsType", goodsType);
map.put("status", 1);
List<GoodsDetail> list = goodsDetailService.getGoodsDetailList(map);
List<GoodsModel> goodsModels = new ArrayList<>();
for (GoodsDetail goodsDetail : list) {
GoodsModel goodsModel = new GoodsModel();
List<GoodsSku> 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);
}
}
if (price == 1) {
goodsModels = goodsModels.stream().sorted(Comparator.comparing(GoodsModel::getPrice)).collect(Collectors.toList());
}
if (price == 2) {
goodsModels = goodsModels.stream().sorted(Comparator.comparing(GoodsModel::getPrice).reversed()).collect(Collectors.toList());
}
return ResponseMsgUtil.success(PageUtil.initPageInfoObj(pageNum, goodsModels.size(), pageSize, 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, "未找到相关商品信息");
}
GoodsModel goodsModel = new GoodsModel();
List<GoodsSku> 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);
}
return ResponseMsgUtil.success(goodsModel);
} 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<GoodsSku> 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);
}
}
@RequestMapping(value = "/getLogisticsMsg", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据快递单号查询物流信息")
public ResponseData getLogisticsMsg(@RequestParam(name = "num", required = true) String num) {
try {
Object data = redisUtil.get("logisticsMsg" + num);
if (data == null) {
JSONObject jsonObjects = CommonConfig.getLogisticsMsg(num);
if (jsonObjects.getInteger("code") == 200 && jsonObjects.getBoolean("success")) {
GoodsLogistics logistics = logisticsService.editLogistics((JSONObject) jsonObjects.get("data"));
redisUtil.set("logisticsMsg" + num , logistics ,21600);
redisUtil.set("logisticsMsgOl" + num , logistics ,21600);
return ResponseMsgUtil.success(logistics);
}
return ResponseMsgUtil.success(jsonObjects);
} else {
return ResponseMsgUtil.success(data);
}
} catch (Exception e) {
log.error("HighOrderController --> getUserOrderList() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -0,0 +1,219 @@
package com.cweb.controller.Goods;
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.GoodsSku;
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 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.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<String, Object> map = new HashMap<>();
map.put("userId", userInfoModel.getHighUser().getId());
List<GoodsShoppingCart> list = shoppingCartService.getShoppingCartList(map);
List<ShoppingCartModel> 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(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 = "/goodsEditNum", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "商品编辑数量")
public ResponseData goodsEditNum(
@RequestParam(value = "id", required = true) Long id,
@RequestParam(value = "num", required = true) String num
, 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(num);
shoppingCart.setUpdateTime(new Date());
shoppingCartService.updateShoppingCart(shoppingCart);
return ResponseMsgUtil.success("增加成功");
} catch (Exception e) {
log.error("GoodsDetailController --> findGoodsDetailById() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -113,6 +113,16 @@ public class OrderController {
log.error("OrderController -> create() error!",""); log.error("OrderController -> create() error!","");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入下单手机号!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入下单手机号!");
} }
} else if (childModel.getGoodsType().equals(OrderChildGoodsType.TYPE11.getNumber())) {
if (childModel.getSkuId() == null) {
log.error("OrderController -> create() error!","");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请选择规格!");
}
if (body.getDeliveryAddressId() == null) {
log.error("OrderController -> create() error!","");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请选择收货地址!");
}
} }
} }

@ -51,6 +51,7 @@ public class PageUtil {
pageInfo.setNextPage(currentPage < ((total + pageSize - 1) / pageSize) ? currentPage + 1 : currentPage); pageInfo.setNextPage(currentPage < ((total + pageSize - 1) / pageSize) ? currentPage + 1 : currentPage);
pageInfo.setTotal(total); pageInfo.setTotal(total);
pageInfo.setPageNum(currentPage); pageInfo.setPageNum(currentPage);
pageInfo.setPageSize(pageSize);
pageInfo.setPages((total + pageSize - 1) / pageSize); pageInfo.setPages((total + pageSize - 1) / pageSize);
pageInfo.setNavigateLastPage((total + pageSize - 1) / pageSize); pageInfo.setNavigateLastPage((total + pageSize - 1) / pageSize);
pageInfo.setPrePage(currentPage > 1 ? currentPage - 1 : currentPage); pageInfo.setPrePage(currentPage > 1 ? currentPage - 1 : currentPage);

@ -1,5 +1,12 @@
package com.hai.config; package com.hai.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.utils.HttpUtils;
import com.hai.common.utils.HttpsUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import sun.font.FontDesignMetrics; import sun.font.FontDesignMetrics;
@ -10,6 +17,7 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
@ -164,6 +172,16 @@ public class CommonConfig {
} }
} }
public static JSONObject getLogisticsMsg(String num) {
String appcode = "f9ace4c915054ca697a76fb9a4e1e8c0";
Map<String, String> headers = new HashMap<>();
headers.put("Authorization", "APPCODE " + appcode);
Map<String, String> querys = new HashMap<>();
querys.put("number", num);
return HttpsUtils.doGet("https://express3.market.alicloudapi.com/express3" , querys ,headers);
}
} }

@ -127,4 +127,7 @@ public class CommonSysConfig {
private String wxH5AppId; private String wxH5AppId;
private String wxH5AppSecret; private String wxH5AppSecret;
private String LogisticsAppKey;
private String logisticsAppSecret;
} }

@ -0,0 +1,41 @@
package com.hai.goods.model;
import com.hai.entity.GoodsDetail;
import java.io.Serializable;
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;
}
}

@ -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;
}
}

@ -0,0 +1,77 @@
package com.hai.goods.service;
import com.hai.entity.GoodsDeliveryAddress;
import java.util.List;
import java.util.Map;
/**
* @serviceName deliveryAddressService.java
* @author Sum1Dream
* @version 1.0.0
* @Description // 收货地址业务
* @createTime 17:33 2023/4/13
**/
public interface DeliveryAddressService {
/**
* @Author Sum1Dream
* @Name insertGoodsDeliveryAddress
* @Description // 新增收货地址
* @Date 15:08 2023/4/11
* @Param [GoodsDeliveryAddress]
* @Return void
*/
void insertDeliveryAddress(GoodsDeliveryAddress deliveryAddress);
/**
* @Author Sum1Dream
* @Name updateGoodsDeliveryAddress
* @Description // 更新收货地址
* @Date 15:14 2023/4/11
* @Param [GoodsDeliveryAddress]
* @Return void
*/
void updateDeliveryAddress(GoodsDeliveryAddress deliveryAddress);
/**
* @Author Sum1Dream
* @Name getGoodsDeliveryAddressList
* @Description // 查询收货地址
* @Date 15:17 2023/4/11
* @Param [map]
* @Return java.util.List<com.hai.entity.GoodsDeliveryAddress>
*/
List<GoodsDeliveryAddress> getDeliveryAddressList(Map<String , Object> map);
/**
* @Author Sum1Dream
* @Name findGoodsDeliveryAddressById
* @Description // 根据id查询详情
* @Date 16:19 2023/4/11
* @Param [id]
* @Return com.hai.entity.GoodsDeliveryAddress
*/
GoodsDeliveryAddress findDeliveryAddressById(Long id);
/**
* @Author Sum1Dream
* @Name deleteDeliveryAddress
* @Description // 删除收货地址
* @Date 17:37 2023/4/13
* @Param [id]
* @Return void
*/
void deleteDeliveryAddress(Long id);
/**
* @Author Sum1Dream
* @Name cleanDeliveryAddressDefault
* @Description // 清空所有的默认收货地址
* @Date 10:33 2023/4/17
* @Param [userId]
* @Return void
*/
void cleanDeliveryAddressDefault(Long userId);
}

@ -0,0 +1,60 @@
package com.hai.goods.service;
import com.hai.entity.ApiMchProduct;
import com.hai.entity.GoodsDetail;
import com.hai.entity.GoodsLogistics;
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<com.hai.entity.GoodsDetail>
*/
List<GoodsDetail> getGoodsDetailList(Map<String , Object> map);
/**
* @Author Sum1Dream
* @Name findGoodsDetailById
* @Description // 根据id商品详情
* @Date 16:19 2023/4/11
* @Param [id]
* @Return com.hai.entity.GoodsDetail
*/
GoodsDetail findGoodsDetailById(Long id);
}

@ -0,0 +1,77 @@
package com.hai.goods.service;
import com.alibaba.fastjson.JSONObject;
import com.hai.entity.GoodsLogistics;
import java.util.List;
import java.util.Map;
/**
* @serviceName GoodsLogisticsService.java
* @author Sum1Dream
* @version 1.0.0
* @Description // 物流信息业务
* @createTime 18:39 2023/4/13
**/
public interface GoodsLogisticsService {
/**
* @Author Sum1Dream
* @Name insertGoodsLogistics
* @Description // 新增物流信息
* @Date 15:08 2023/4/11
* @Param [GoodsLogistics]
* @Return void
*/
void insertGoodsLogistics(GoodsLogistics goodsLogistics);
/**
* @Author Sum1Dream
* @Name updateGoodsLogistics
* @Description // 更新物流信息
* @Date 15:14 2023/4/11
* @Param [GoodsLogistics]
* @Return void
*/
void updateGoodsLogistics(GoodsLogistics goodsLogistics);
/**
* @Author Sum1Dream
* @Name getGoodsLogisticsList
* @Description // 查询物流信息列表
* @Date 15:17 2023/4/11
* @Param [map]
* @Return java.util.List<com.hai.entity.GoodsLogistics>
*/
List<GoodsLogistics> getGoodsLogisticsList(Map<String , Object> map);
/**
* @Author Sum1Dream
* @Name findGoodsLogisticsById
* @Description // 根据id查询物流信息
* @Date 16:19 2023/4/11
* @Param [id]
* @Return com.hai.entity.GoodsLogistics
*/
GoodsLogistics findGoodsLogisticsById(Long id);
/**
* @Author Sum1Dream
* @Name findGoodsLogisticsByNum
* @Description // 根据快递单号查询物流信息
* @Date 11:41 2023/4/14
* @Param [num]
* @Return com.hai.entity.GoodsLogistics
*/
GoodsLogistics findGoodsLogisticsByNum(String num);
/**
* @Author Sum1Dream
* @Name editLogistics
* @Description // 编辑物流信息
* @Date 11:33 2023/4/14
* @Param [goodsLogistics]
* @Return void
*/
GoodsLogistics editLogistics(JSONObject object);
}

@ -0,0 +1,68 @@
package com.hai.goods.service;
import com.hai.entity.GoodsPresent;
import java.util.List;
import java.util.Map;
/**
* @serviceName GoodsPresentService.java
* @author Sum1Dream
* @version 1.0.0
* @Description // 商品赠送业务
* @createTime 14:17 2023/4/17
**/
public interface GoodsPresentService {
/**
* @Author Sum1Dream
* @Name insertGoodsPresent
* @Description // 新增
* @Date 15:08 2023/4/11
* @Param [GoodsPresent]
* @Return void
*/
void insertPresent(GoodsPresent present);
/**
* @Author Sum1Dream
* @Name updateGoodsPresent
* @Description // 更新
* @Date 15:14 2023/4/11
* @Param [GoodsPresent]
* @Return void
*/
void updatePresent(GoodsPresent present);
/**
* @Author Sum1Dream
* @Name getGoodsPresentList
* @Description // 查询
* @Date 15:17 2023/4/11
* @Param [map]
* @Return java.util.List<com.hai.entity.GoodsPresent>
*/
List<GoodsPresent> getPresentList(Map<String , Object> map);
/**
* @Author Sum1Dream
* @Name findGoodsPresentById
* @Description // 根据id查询详情
* @Date 16:19 2023/4/11
* @Param [id]
* @Return com.hai.entity.GoodsPresent
*/
GoodsPresent findPresentById(Long id);
/**
* @Author Sum1Dream
* @Name deletePresent
* @Description // 删除
* @Date 17:37 2023/4/13
* @Param [id]
* @Return void
*/
void deletePresent(Long id);
}

@ -0,0 +1,89 @@
package com.hai.goods.service;
import com.alibaba.fastjson.JSONObject;
import com.hai.entity.GoodsRegionFreight;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
/**
* @serviceName GoodsRegionFreightService.java
* @author Sum1Dream
* @version 1.0.0
* @Description // 区域运费业务
* @createTime 15:11 2023/4/14
**/
public interface GoodsRegionFreightService {
/**
* @Author Sum1Dream
* @Name insertRegionFreight
* @Description // 新增
* @Date 15:08 2023/4/11
* @Param [RegionFreight]
* @Return void
*/
void insertRegionFreight(GoodsRegionFreight regionFreight);
/**
* @Author Sum1Dream
* @Name updateRegionFreight
* @Description // 更新
* @Date 15:14 2023/4/11
* @Param [RegionFreight]
* @Return void
*/
void updateRegionFreight(GoodsRegionFreight regionFreight);
/**
* @Author Sum1Dream
* @Name getRegionFreightList
* @Description // 查询列表
* @Date 15:17 2023/4/11
* @Param [map]
* @Return java.util.List<com.hai.entity.GoodsDetail>
*/
List<GoodsRegionFreight> getRegionFreightList(Map<String , Object> map);
/**
* @Author Sum1Dream
* @Name findGoodsDetailById
* @Description // 查询详情
* @Date 16:19 2023/4/11
* @Param [id]
* @Return com.hai.entity.GoodsDetail
*/
GoodsRegionFreight findRegionFreightById(Long id);
/**
* @Author Sum1Dream
* @Name findRegionFreightByRegionId
* @Description // 获取区域运费根据区域编码
* @Date 19:08 2023/4/14
* @Param [regionId]
* @Return com.hai.entity.GoodsRegionFreight
*/
GoodsRegionFreight findRegionFreightByRegionId(String regionId);
/**
* @Author Sum1Dream
* @Name DeleteRegionFreight
* @Description // 删除
* @Date 15:09 2023/4/13
* @Param [id]
* @Return void
*/
void deleteRegionFreight(Long id);
/**
* @Author Sum1Dream
* @Name getRegionFreight
* @Description // 获取运费
* @Date 19:03 2023/4/14
* @Param [regionId]
* @Return java.math.BigDecimal
*/
JSONObject getRegionFreight(String regionId) throws Exception;
}

@ -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<com.hai.entity.GoodsSku>
*/
List<GoodsSku> getGoodsSkuList(Map<String , Object> map);
List<GoodsSku> 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);
}

@ -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<com.hai.entity.GoodsDetail>
*/
List<GoodsShoppingCart> getShoppingCartList(Map<String , Object> 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);
}

@ -0,0 +1,72 @@
package com.hai.goods.service.impl;
import com.hai.dao.GoodsDeliveryAddressMapper;
import com.hai.entity.GoodsDeliveryAddress;
import com.hai.entity.GoodsDeliveryAddressExample;
import com.hai.goods.service.DeliveryAddressService;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service("deliveryAddressService")
public class DeliveryAddressServiceImpl implements DeliveryAddressService {
@Resource
private GoodsDeliveryAddressMapper deliveryAddressMapper;
@Override
public void insertDeliveryAddress(GoodsDeliveryAddress deliveryAddress) {
deliveryAddressMapper.insert(deliveryAddress);
}
@Override
public void updateDeliveryAddress(GoodsDeliveryAddress deliveryAddress) {
deliveryAddressMapper.updateByPrimaryKey(deliveryAddress);
}
@Override
public List<GoodsDeliveryAddress> getDeliveryAddressList(Map<String, Object> map) {
GoodsDeliveryAddressExample example = new GoodsDeliveryAddressExample();
GoodsDeliveryAddressExample.Criteria criteria = example.createCriteria();
if (MapUtils.getLong(map, "userId") != null) {
criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId"));
}
if (MapUtils.getBoolean(map, "whetherDefault") != null) {
criteria.andWhetherDefaultEqualTo(MapUtils.getBoolean(map, "whetherDefault"));
}
return deliveryAddressMapper.selectByExample(example);
}
@Override
public GoodsDeliveryAddress findDeliveryAddressById(Long id) {
return deliveryAddressMapper.selectByPrimaryKey(id);
}
@Override
public void deleteDeliveryAddress(Long id) {
deliveryAddressMapper.deleteByPrimaryKey(id);
}
@Override
public void cleanDeliveryAddressDefault(Long userId) {
Map<String , Object> map = new HashMap<>();
map.put("userId" , userId);
List<GoodsDeliveryAddress> list = getDeliveryAddressList(map);
if (list.size()>1) {
for (GoodsDeliveryAddress deliveryAddress : list) {
deliveryAddress.setWhetherDefault(false);
updateDeliveryAddress(deliveryAddress);
}
}
}
}

@ -0,0 +1,62 @@
package com.hai.goods.service.impl;
import com.hai.dao.GoodsDetailMapper;
import com.hai.dao.GoodsLogisticsMapper;
import com.hai.entity.ApiMerchantsExample;
import com.hai.entity.GoodsDetail;
import com.hai.entity.GoodsDetailExample;
import com.hai.entity.GoodsLogistics;
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;
@Resource
private GoodsLogisticsMapper logisticsMapper;
@Override
public void insertGoodsDetail(GoodsDetail goodsDetail) {
goodsDetailMapper.insert(goodsDetail);
}
@Override
public void updateGoodsDetail(GoodsDetail goodsDetail) {
goodsDetailMapper.updateByPrimaryKey(goodsDetail);
}
@Override
public List<GoodsDetail> getGoodsDetailList(Map<String, Object> map) {
GoodsDetailExample example = new GoodsDetailExample();
GoodsDetailExample.Criteria criteria = example.createCriteria();
if (MapUtils.getString(map, "title") != null) {
criteria.andNameLike("%" + MapUtils.getString(map, "title") + "%");
}
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);
}
}

@ -0,0 +1,88 @@
package com.hai.goods.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.hai.dao.GoodsLogisticsMapper;
import com.hai.entity.GoodsLogistics;
import com.hai.entity.GoodsLogisticsExample;
import com.hai.goods.service.GoodsLogisticsService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Service("goodsLogisticsService")
public class GoodsLogisticsServiceImpl implements GoodsLogisticsService {
@Resource
private GoodsLogisticsMapper goodsLogisticsMapper;
@Override
public void insertGoodsLogistics(GoodsLogistics goodsLogistics) {
goodsLogisticsMapper.insert(goodsLogistics);
}
@Override
public void updateGoodsLogistics(GoodsLogistics goodsLogistics) {
goodsLogisticsMapper.updateByPrimaryKey(goodsLogistics);
}
@Override
public List<GoodsLogistics> getGoodsLogisticsList(Map<String, Object> map) {
return null;
}
@Override
public GoodsLogistics findGoodsLogisticsById(Long id) {
return goodsLogisticsMapper.selectByPrimaryKey(id);
}
@Override
public GoodsLogistics findGoodsLogisticsByNum(String num) {
GoodsLogisticsExample example = new GoodsLogisticsExample();
GoodsLogisticsExample.Criteria criteria = example.createCriteria();
criteria.andNumberEqualTo(num).andStatusEqualTo(1);
List<GoodsLogistics> logistics = goodsLogisticsMapper.selectByExample(example);
if (logistics.size() > 0) {
return logistics.get(0);
}
return null;
}
@Override
public GoodsLogistics editLogistics(JSONObject jsonObject) {
JSONObject info = (JSONObject) jsonObject.getJSONArray("info").get(0);
GoodsLogistics logistics = findGoodsLogisticsByNum(info.getString("mailNo"));
if (logistics == null) {
logistics = new GoodsLogistics();
}
logistics.setTaskNo(jsonObject.getString("orderNo"));
logistics.setTheLastTime(info.getDate("theLastTime"));
logistics.setTheLastMessage(info.getString("theLastMessage"));
logistics.setTakeTime(info.getString("takeTime"));
logistics.setNumber(info.getString("mailNo"));
logistics.setLogisticsStatus(info.getString("logisticsStatus"));
logistics.setExpressCompanyName(info.getString("logisticsCompanyName"));
logistics.setLogisticsStatusDesc(info.getString("logisticsStatusDesc"));
logistics.setLogisticsTraceDetails(info.getString("logisticsTraceDetailList"));
logistics.setStatus(1);
if ( logistics.getId() == null) {
logistics.setCreateTime(new Date());
insertGoodsLogistics(logistics);
} else {
updateGoodsLogistics(logistics);
}
return logistics;
}
}

@ -0,0 +1,53 @@
package com.hai.goods.service.impl;
import com.hai.dao.GoodsPresentMapper;
import com.hai.entity.GoodsPresent;
import com.hai.entity.GoodsPresentExample;
import com.hai.entity.GoodsRegionFreight;
import com.hai.goods.service.GoodsPresentService;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@Service("goodsPresentService")
public class GoodsPresentServiceImpl implements GoodsPresentService {
@Resource
private GoodsPresentMapper goodsPresentMapper;
@Override
public void insertPresent(GoodsPresent present) {
goodsPresentMapper.insert(present);
}
@Override
public void updatePresent(GoodsPresent present) {
goodsPresentMapper.updateByPrimaryKey(present);
}
@Override
public List<GoodsPresent> getPresentList(Map<String, Object> map) {
GoodsPresentExample example = new GoodsPresentExample();
GoodsPresentExample.Criteria criteria = example.createCriteria();
if (MapUtils.getLong(map, "goodsId") != null) {
criteria.andGoodsIdEqualTo(MapUtils.getLong(map, "goodsId"));
}
criteria.andStatusNotEqualTo(String.valueOf(0));
return goodsPresentMapper.selectByExample(example);
}
@Override
public GoodsPresent findPresentById(Long id) {
return goodsPresentMapper.selectByPrimaryKey(id);
}
@Override
public void deletePresent(Long id) {
goodsPresentMapper.deleteByPrimaryKey(id);
}
}

@ -0,0 +1,119 @@
package com.hai.goods.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.dao.GoodsRegionFreightMapper;
import com.hai.entity.GoodsRegionFreight;
import com.hai.entity.GoodsRegionFreightExample;
import com.hai.entity.SecRegion;
import com.hai.goods.service.GoodsRegionFreightService;
import com.hai.service.CommonService;
import com.hai.service.SecConfigService;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
@Service("goodsRegionFreightService")
public class GoodsRegionFreightServiceImpl implements GoodsRegionFreightService {
@Resource
private GoodsRegionFreightMapper regionFreightMapper;
@Resource
private SecConfigService secConfigService;
@Resource
private CommonService commonService;
@Override
public void insertRegionFreight(GoodsRegionFreight regionFreight) {
regionFreightMapper.insert(regionFreight);
}
@Override
public void updateRegionFreight(GoodsRegionFreight regionFreight) {
regionFreightMapper.updateByPrimaryKey(regionFreight);
}
@Override
public List<GoodsRegionFreight> getRegionFreightList(Map<String, Object> map) {
GoodsRegionFreightExample example = new GoodsRegionFreightExample();
GoodsRegionFreightExample.Criteria criteria = example.createCriteria();
if (MapUtils.getString(map, "regionName") != null) {
criteria.andRegionNameLike("%" + MapUtils.getString(map, "regionName") + "%");
}
if (MapUtils.getString(map, "regionId") != null) {
criteria.andRegionIdEqualTo(MapUtils.getString(map, "regionId"));
}
criteria.andStatusEqualTo(1);
return regionFreightMapper.selectByExample(example);
}
@Override
public GoodsRegionFreight findRegionFreightById(Long id) {
return regionFreightMapper.selectByPrimaryKey(id);
}
@Override
public GoodsRegionFreight findRegionFreightByRegionId(String regionId) {
GoodsRegionFreightExample example = new GoodsRegionFreightExample();
example.createCriteria().andRegionIdEqualTo(regionId).andStatusEqualTo(1);
List<GoodsRegionFreight> list = regionFreightMapper.selectByExample(example);
if (list.size() > 0 ) {
return list.get(0);
}
return null;
}
@Override
public void deleteRegionFreight(Long id) {
regionFreightMapper.deleteByPrimaryKey(id);
}
@Override
public JSONObject getRegionFreight(String regionId) {
// 获取默认包邮价格 , 运费
BigDecimal freePostPrice = new BigDecimal(secConfigService.findByCodeType("FREE_POST_PRICE").getCodeValue());
BigDecimal freightPrice = new BigDecimal(secConfigService.findByCodeType("FREIGHT_PRICE").getCodeValue());
JSONObject jsonObject = new JSONObject();
// 查询当前登记
GoodsRegionFreight goodsRegionFreight = findRegionFreightByRegionId(regionId);
SecRegion region = commonService.getRegionsById(Long.parseLong(regionId));
if (region == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无效区域编码!");
}
if (goodsRegionFreight != null) {
jsonObject.put("freePostPrice" , goodsRegionFreight.getFreePostPrice());
jsonObject.put("freightPrice" , goodsRegionFreight.getFreightPrice());
return jsonObject;
}
if (region.getParentId() == null) {
jsonObject.put("freePostPrice" , freePostPrice);
jsonObject.put("freightPrice" , freightPrice);
return jsonObject;
}
return getRegionFreight(region.getParentId().toString());
}
}

@ -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<GoodsSku> getGoodsSkuList(Map<String, Object> 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<GoodsSku> 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);
}
}

@ -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<GoodsShoppingCart> getShoppingCartList(Map<String, Object> 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);
}
}

@ -36,6 +36,17 @@ public class CreateOrderChildModel {
/** /**
* 产品类型 * 产品类型
* 1. 卡卷
* 2. 积分充值
* 3. 加油订单
* 4. KFC
* 5. 电影票
* 6. 话费充值
* 7. 优惠卷包
* 8. 汇联通充值
* 9. 星巴克
* 10. 第三方充值
* 11. 实物商品购买
*/ */
private Integer goodsType; private Integer goodsType;
@ -101,5 +112,11 @@ public class CreateOrderChildModel {
// 充值内容 // 充值内容
private String rechargeContent; private String rechargeContent;
/** ======================= 话费充值所需参数 end ======================== **/ /** ======================= 话费充值所需参数 end ======================== **/
/** ======================= 实物商品所需参数 start ======================== **/
// 规格编码
private Long skuId;
// 商品内容
private Long shopCartId;
/** ======================= 实物商品所需参数 end ======================== **/
} }

@ -64,6 +64,11 @@ public class CreateOrderModel {
*/ */
private String remarks; private String remarks;
/**
* 收货地址
*/
private Long deliveryAddressId;
/** /**
* 子订单参数模型 * 子订单参数模型
*/ */

@ -19,6 +19,7 @@ public enum OrderChildGoodsType {
TYPE8(8, "贵州汇联通工会卡充值"), TYPE8(8, "贵州汇联通工会卡充值"),
TYPE9(9, "星巴克"), TYPE9(9, "星巴克"),
TYPE10(10, "第三方充值"), TYPE10(10, "第三方充值"),
TYPE11(11, "实物商品购买"),
; ;
private Integer number; private Integer number;

@ -309,5 +309,23 @@ public interface CommonService {
*/ */
SecConfig findSecConfigByType(String codeType); SecConfig findSecConfigByType(String codeType);
/**
* @Author Sum1Dream
* @Name getRegional
* @Description // 获取区域信息
* @Date 16:56 2023/4/13
* @Param []
* @Return com.alibaba.fastjson.JSONObject
*/
List<JSONObject> getRegional(String code , String name ,String child);
/**
* @Author Sum1Dream
* @Name getSecRegion
* @Description // 获取地区信息
* @Date 17:00 2023/4/13
* @Param [parentId]
* @Return java.util.List<com.hai.entity.SecRegion>
*/
List<SecRegion> getSecRegion(Long parentId);
} }

@ -1,5 +1,6 @@
package com.hai.service; package com.hai.service;
import com.alibaba.fastjson.JSONObject;
import com.hai.entity.HighGoodsType; import com.hai.entity.HighGoodsType;
import com.hai.entity.HighOrderPre; import com.hai.entity.HighOrderPre;
@ -54,4 +55,14 @@ public interface HighGoodsTypeService {
* @return void * @return void
**/ **/
void updateGoodsType(HighGoodsType highGoodsType); void updateGoodsType(HighGoodsType highGoodsType);
/**
* @Author Sum1Dream
* @Name getGoodsTypeTree
* @Description // 获取商品类型树结构
* @Date 14:23 2023/4/12
* @Param [businessType]
* @Return com.alibaba.fastjson.JSONObject
*/
List<JSONObject> getGoodsTypeTree(Integer businessType);
} }

@ -14,10 +14,7 @@ import com.hai.dao.order.OrderStatisticsMapperExt;
import com.hai.entity.*; import com.hai.entity.*;
import com.hai.model.IndexCountModel; import com.hai.model.IndexCountModel;
import com.hai.model.LineCountModel; import com.hai.model.LineCountModel;
import com.hai.service.CommonService; import com.hai.service.*;
import com.hai.service.HighOrderService;
import com.hai.service.HighUserService;
import com.hai.service.SecConfigService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -76,6 +73,7 @@ public class CommonServiceImpl implements CommonService {
private Map<String, Map<String, SecDictionary>> dicCache = new HashMap<String, Map<String, SecDictionary>>(); private Map<String, Map<String, SecDictionary>> dicCache = new HashMap<String, Map<String, SecDictionary>>();
private List<SecRegion> citiesCache = new ArrayList<>(); private List<SecRegion> citiesCache = new ArrayList<>();
@ -731,4 +729,68 @@ public class CommonServiceImpl implements CommonService {
return null; return null;
} }
@Override
public List<JSONObject> getRegional(String code , String name , String child) {
// 获取父类
List<SecRegion> regionListParent = getSecRegion(null);
List<JSONObject> jsonProvince = new ArrayList<>();
for (SecRegion secRegion : regionListParent) {
JSONObject provinceObject = new JSONObject();
provinceObject.put(code , secRegion.getRegionId());
provinceObject.put(name , secRegion.getRegionName());
List<SecRegion> regionList = getSecRegion(secRegion.getRegionId());
if (regionList.size() > 0) {
List<JSONObject> jsonCity = new ArrayList<>();
for (SecRegion city : regionList) {
JSONObject objectCity = new JSONObject();
objectCity.put(code , city.getRegionId());
objectCity.put(name , city.getRegionName());
List<SecRegion> areaList = getSecRegion(city.getRegionId());
if (areaList.size() > 0 ) {
List<JSONObject> jsonArea = new ArrayList<>();
for (SecRegion area : areaList) {
JSONObject objectArea = new JSONObject();
objectArea.put(code , area.getRegionId());
objectArea.put(name , area.getRegionName());
objectArea.put("isLeaf" , true);
jsonArea.add(objectArea);
}
objectCity.put(child , jsonArea);
}
jsonCity.add(objectCity);
}
provinceObject.put(child , jsonCity);
}
jsonProvince.add(provinceObject);
}
return jsonProvince;
}
@Override
public List<SecRegion> 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);
}
} }

@ -1,13 +1,17 @@
package com.hai.service.impl; package com.hai.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.hai.dao.HighGoodsTypeMapper; import com.hai.dao.HighGoodsTypeMapper;
import com.hai.entity.HighGoodsType; import com.hai.entity.HighGoodsType;
import com.hai.entity.HighGoodsTypeExample; import com.hai.entity.HighGoodsTypeExample;
import com.hai.service.HighGoodsTypeService; import com.hai.service.HighGoodsTypeService;
import net.sf.jsqlparser.statement.select.First;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -36,6 +40,11 @@ public class HighGoodsTypeServiceImpl implements HighGoodsTypeService {
if (MapUtils.getString(map, "userService") != null) { if (MapUtils.getString(map, "userService") != null) {
criteria.andUserServiceEqualTo(MapUtils.getString(map, "userService")); criteria.andUserServiceEqualTo(MapUtils.getString(map, "userService"));
} }
if (MapUtils.getInteger(map, "parentId") != null) {
criteria.andParentIdEqualTo(MapUtils.getInteger(map, "parentId"));
}else {
criteria.andParentIdIsNull();
}
criteria.andStatusEqualTo(1); criteria.andStatusEqualTo(1);
@ -72,4 +81,48 @@ public class HighGoodsTypeServiceImpl implements HighGoodsTypeService {
highGoodsTypeMapper.updateByPrimaryKey(highGoodsType); highGoodsTypeMapper.updateByPrimaryKey(highGoodsType);
} }
@Override
public List<JSONObject> getGoodsTypeTree(Integer businessType) {
Map<String,String> map = new HashMap<>();
map.put("businessType", String.valueOf(businessType));
// 获取顶级
List<HighGoodsType> goodsTypeList = getListGoodsType(map);
List<JSONObject> 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<HighGoodsType> goodsTypesChild = getListGoodsType(map);
// 判断是否存在子类
if (goodsTypesChild.size() > 0) {
List<JSONObject> 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;
}
} }

@ -119,3 +119,7 @@ wxAppSecret=d8d6dcaef77d3b659258a01b5ddba5df
wxH5AppId=wxa075e8509802f826 wxH5AppId=wxa075e8509802f826
wxH5AppSecret=0e606fc1378d35e359fcf3f15570b2c5 wxH5AppSecret=0e606fc1378d35e359fcf3f15570b2c5
logisticsAppKey=5d806a99fbcc48e19717beef11fa1700
logisticsAppSecret=5ba7552b194e4147b7db1c34143e3317

Loading…
Cancel
Save