parent
2b5a42f1c7
commit
3accfad213
@ -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); |
||||
} |
||||
} |
||||
} |
File diff suppressed because one or more lines are too long
@ -0,0 +1,206 @@ |
||||
package com.cweb.controller.Goods; |
||||
|
||||
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.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; |
||||
|
||||
@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(); |
||||
|
||||
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 = "/deleteShoppingCart", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "删除购物车信息") |
||||
public ResponseData deleteShoppingCart( |
||||
@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); |
||||
} |
||||
} |
||||
|
||||
} |
@ -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,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,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,69 @@ |
||||
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")); |
||||
} |
||||
|
||||
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,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,186 @@ |
||||
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; |
||||
} |
||||
|
||||
getRegionFreight(region.getParentId().toString()); |
||||
|
||||
return jsonObject; |
||||
} |
||||
|
||||
// @Override
|
||||
// public JSONObject getRegionFreight(String regionId) throws Exception {
|
||||
//
|
||||
// // 获取默认包邮价格 , 运费
|
||||
// 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;
|
||||
// }
|
||||
//
|
||||
// GoodsRegionFreight goodsRegionFreight1 = findRegionFreightByRegionId(region.getParentId().toString());
|
||||
// SecRegion region1 = commonService.getRegionsById(region.getParentId());
|
||||
//
|
||||
// if (goodsRegionFreight1 != null) {
|
||||
// jsonObject.put("freePostPrice" , goodsRegionFreight1.getFreePostPrice());
|
||||
// jsonObject.put("freightPrice" , goodsRegionFreight1.getFreightPrice());
|
||||
// return jsonObject;
|
||||
// }
|
||||
//
|
||||
// if (region1.getParentId() == null) {
|
||||
// jsonObject.put("freePostPrice" , freePostPrice);
|
||||
// jsonObject.put("freightPrice" , freightPrice);
|
||||
// return jsonObject;
|
||||
// }
|
||||
//
|
||||
// GoodsRegionFreight goodsRegionFreight2 = findRegionFreightByRegionId(region1.getParentId().toString());
|
||||
// SecRegion region2 = commonService.getRegionsById(region1.getParentId());
|
||||
//
|
||||
// if (goodsRegionFreight2 != null) {
|
||||
// jsonObject.put("freePostPrice" , goodsRegionFreight2.getFreePostPrice());
|
||||
// jsonObject.put("freightPrice" , goodsRegionFreight2.getFreightPrice());
|
||||
// return jsonObject;
|
||||
// }
|
||||
//
|
||||
// if (region2.getParentId() == null) {
|
||||
// jsonObject.put("freePostPrice" , freePostPrice);
|
||||
// jsonObject.put("freightPrice" , freightPrice);
|
||||
// return jsonObject;
|
||||
// }
|
||||
//
|
||||
// jsonObject.put("freePostPrice" , freePostPrice);
|
||||
// jsonObject.put("freightPrice" , freightPrice);
|
||||
//
|
||||
// return jsonObject;
|
||||
// }
|
||||
} |
Loading…
Reference in new issue