添加退货申请接口

This commit is contained in:
zhh 2018-10-18 14:37:04 +08:00
parent 74a4448931
commit 7054e92cf4
11 changed files with 411 additions and 0 deletions

View File

@ -0,0 +1,34 @@
package com.macro.mall.controller;
import com.macro.mall.dto.CommonResult;
import com.macro.mall.model.OmsCompanyAddress;
import com.macro.mall.service.OmsCompanyAddressService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
* 收货地址管理Controller
* Created by macro on 2018/10/18.
*/
@Controller
@Api(tags = "OmsCompanyAddressController", description = "收货地址管理")
@RequestMapping("/companyAddress")
public class OmsCompanyAddressController {
@Autowired
private OmsCompanyAddressService companyAddressService;
@ApiOperation("获取所有收货地址")
@RequestMapping(value = "/list",method = RequestMethod.GET)
@ResponseBody
public Object list() {
List<OmsCompanyAddress> companyAddressList = companyAddressService.list();
return new CommonResult().success(companyAddressList);
}
}

View File

@ -0,0 +1,68 @@
package com.macro.mall.controller;
import com.macro.mall.dto.CommonResult;
import com.macro.mall.dto.OmsOrderReturnApplyResult;
import com.macro.mall.dto.OmsReturnApplyQueryParam;
import com.macro.mall.dto.OmsUpdateStatusParam;
import com.macro.mall.model.OmsOrderReturnApply;
import com.macro.mall.service.OmsOrderReturnApplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 订单退货申请管理
* Created by macro on 2018/10/18.
*/
@Controller
@Api(tags = "OmsOrderReturnApplyController", description = "订单退货申请管理")
@RequestMapping("/returnApply")
public class OmsOrderReturnApplyController {
@Autowired
private OmsOrderReturnApplyService returnApplyService;
@ApiOperation("分页查询退货申请")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public Object list(OmsReturnApplyQueryParam queryParam,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
List<OmsOrderReturnApply> returnApplyList = returnApplyService.list(queryParam, pageSize, pageNum);
return new CommonResult().pageSuccess(returnApplyList);
}
@ApiOperation("批量删除申请")
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@ResponseBody
public Object delete(@RequestParam("ids") List<Long> ids) {
int count = returnApplyService.delete(ids);
if (count > 0) {
return new CommonResult().success(count);
}
return new CommonResult().failed();
}
@ApiOperation("获取退货申请详情")
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody
public Object getItem(@PathVariable Long id) {
OmsOrderReturnApplyResult result = returnApplyService.getItem(id);
return new CommonResult().success(result);
}
@ApiOperation("修改申请状态")
@RequestMapping(value = "/update/status/{id}", method = RequestMethod.POST)
@ResponseBody
public Object updateStatus(@PathVariable Long id, @RequestBody OmsUpdateStatusParam statusParam) {
int count = returnApplyService.updateStatus(id, statusParam);
if (count > 0) {
return new CommonResult().success(count);
}
return new CommonResult().failed();
}
}

View File

@ -0,0 +1,24 @@
package com.macro.mall.dao;
import com.macro.mall.dto.OmsOrderReturnApplyResult;
import com.macro.mall.dto.OmsReturnApplyQueryParam;
import com.macro.mall.model.OmsOrderReturnApply;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 订单退货申请自定义Dao
* Created by macro on 2018/10/18.
*/
public interface OmsOrderReturnApplyDao {
/**
* 查询申请列表
*/
List<OmsOrderReturnApply> getList(@Param("queryParam") OmsReturnApplyQueryParam queryParam);
/**
* 获取申请详情
*/
OmsOrderReturnApplyResult getDetail(@Param("id")Long id);
}

View File

@ -0,0 +1,16 @@
package com.macro.mall.dto;
import com.macro.mall.model.OmsCompanyAddress;
import com.macro.mall.model.OmsOrderReturnApply;
import lombok.Getter;
import lombok.Setter;
/**
* 申请信息封装
* Created by macro on 2018/10/18.
*/
public class OmsOrderReturnApplyResult extends OmsOrderReturnApply {
@Getter
@Setter
private OmsCompanyAddress companyAddress;
}

View File

@ -0,0 +1,26 @@
package com.macro.mall.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
/**
* 订单退货申请查询参数
* Created by macro on 2018/10/18.
*/
@Getter
@Setter
public class OmsReturnApplyQueryParam {
@ApiModelProperty("服务单号")
private Long id;
@ApiModelProperty(value = "收货人姓名/号码")
private String receiverKeyword;
@ApiModelProperty(value = "申请状态0->待处理1->退货中2->已完成3->已拒绝")
private Integer status;
@ApiModelProperty(value = "申请时间")
private String createTime;
@ApiModelProperty(value = "处理人员")
private String handleMan;
@ApiModelProperty(value = "处理时间")
private String handleTime;
}

View File

@ -0,0 +1,32 @@
package com.macro.mall.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.math.BigDecimal;
/**
* 确认收货提交参数
* Created by macro on 2018/10/18.
*/
@Getter
@Setter
public class OmsUpdateStatusParam {
@ApiModelProperty("服务单号")
private Long id;
@ApiModelProperty("收货地址关联id")
private Long companyAddressId;
@ApiModelProperty("确认退款金额")
private BigDecimal returnAmount;
@ApiModelProperty("处理备注")
private String handleNote;
@ApiModelProperty("处理人")
private String handleMan;
@ApiModelProperty("收货备注")
private String receiveNote;
@ApiModelProperty("收货人")
private String receiveMan;
@ApiModelProperty("申请状态1->退货中2->已完成3->已拒绝")
private Integer status;
}

View File

@ -0,0 +1,16 @@
package com.macro.mall.service;
import com.macro.mall.model.OmsCompanyAddress;
import java.util.List;
/**
* 收货地址管Service
* Created by macro on 2018/10/18.
*/
public interface OmsCompanyAddressService {
/**
* 获取全部收货地址
*/
List<OmsCompanyAddress> list();
}

View File

@ -0,0 +1,34 @@
package com.macro.mall.service;
import com.macro.mall.dto.OmsOrderReturnApplyResult;
import com.macro.mall.dto.OmsReturnApplyQueryParam;
import com.macro.mall.dto.OmsUpdateStatusParam;
import com.macro.mall.model.OmsOrderReturnApply;
import java.util.List;
/**
* 退货申请管理Service
* Created by macro on 2018/10/18.
*/
public interface OmsOrderReturnApplyService {
/**
* 分页查询申请
*/
List<OmsOrderReturnApply> list(OmsReturnApplyQueryParam queryParam, Integer pageSize, Integer pageNum);
/**
* 批量删除申请
*/
int delete(List<Long> ids);
/**
* 修改申请状态
*/
int updateStatus(Long id, OmsUpdateStatusParam statusParam);
/**
* 获取指定申请详情
*/
OmsOrderReturnApplyResult getItem(Long id);
}

View File

@ -0,0 +1,24 @@
package com.macro.mall.service.impl;
import com.macro.mall.mapper.OmsCompanyAddressMapper;
import com.macro.mall.model.OmsCompanyAddress;
import com.macro.mall.model.OmsCompanyAddressExample;
import com.macro.mall.service.OmsCompanyAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 收货地址管理Service实现类
* Created by macro on 2018/10/18.
*/
@Service
public class OmsCompanyAddressServiceImpl implements OmsCompanyAddressService {
@Autowired
private OmsCompanyAddressMapper companyAddressMapper;
@Override
public List<OmsCompanyAddress> list() {
return companyAddressMapper.selectByExample(new OmsCompanyAddressExample());
}
}

View File

@ -0,0 +1,78 @@
package com.macro.mall.service.impl;
import com.github.pagehelper.PageHelper;
import com.macro.mall.dao.OmsOrderReturnApplyDao;
import com.macro.mall.dto.OmsOrderReturnApplyResult;
import com.macro.mall.dto.OmsReturnApplyQueryParam;
import com.macro.mall.dto.OmsUpdateStatusParam;
import com.macro.mall.mapper.OmsOrderReturnApplyMapper;
import com.macro.mall.model.OmsOrderReturnApply;
import com.macro.mall.model.OmsOrderReturnApplyExample;
import com.macro.mall.service.OmsOrderReturnApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* 订单退货管理Service
* Created by macro on 2018/10/18.
*/
@Service
public class OmsOrderReturnApplyServiceImpl implements OmsOrderReturnApplyService {
@Autowired
private OmsOrderReturnApplyDao returnApplyDao;
@Autowired
private OmsOrderReturnApplyMapper returnApplyMapper;
@Override
public List<OmsOrderReturnApply> list(OmsReturnApplyQueryParam queryParam, Integer pageSize, Integer pageNum) {
PageHelper.startPage(pageNum,pageSize);
return returnApplyDao.getList(queryParam);
}
@Override
public int delete(List<Long> ids) {
OmsOrderReturnApplyExample example = new OmsOrderReturnApplyExample();
example.createCriteria().andIdIn(ids).andStatusEqualTo(3);
return returnApplyMapper.deleteByExample(example);
}
@Override
public int updateStatus(Long id, OmsUpdateStatusParam statusParam) {
Integer status = statusParam.getStatus();
OmsOrderReturnApply returnApply = new OmsOrderReturnApply();
if(status.equals(1)){
//确认退货
returnApply.setId(statusParam.getId());
returnApply.setStatus(1);
returnApply.setReturnAmount(statusParam.getReturnAmount());
returnApply.setCompanyAddressId(statusParam.getCompanyAddressId());
returnApply.setHandleTime(new Date());
returnApply.setHandleMan(statusParam.getHandleMan());
returnApply.setHandleNote(statusParam.getHandleNote());
}else if(status.equals(2)){
//完成退货
returnApply.setId(statusParam.getId());
returnApply.setStatus(2);
returnApply.setReceiveTime(new Date());
returnApply.setReceiveMan(statusParam.getReceiveMan());
returnApply.setReceiveNote(statusParam.getReceiveNote());
}else if(status.equals(3)){
//拒绝退货
returnApply.setId(statusParam.getId());
returnApply.setStatus(3);
returnApply.setHandleTime(new Date());
returnApply.setHandleMan(statusParam.getHandleMan());
returnApply.setHandleNote(statusParam.getHandleNote());
}else{
return 0;
}
return returnApplyMapper.updateByPrimaryKeySelective(returnApply);
}
@Override
public OmsOrderReturnApplyResult getItem(Long id) {
return returnApplyDao.getDetail(id);
}
}

View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.macro.mall.dao.OmsOrderReturnApplyDao">
<resultMap id="returnApplyDetailResultMap" type="com.macro.mall.dto.OmsOrderReturnApplyResult" extends="com.macro.mall.mapper.OmsOrderReturnApplyMapper.BaseResultMap">
<association property="companyAddress" resultMap="com.macro.mall.mapper.OmsCompanyAddressMapper.BaseResultMap" columnPrefix="ca_"/>
</resultMap>
<select id="getList" resultMap="com.macro.mall.mapper.OmsOrderReturnApplyMapper.BaseResultMap">
SELECT
id,
create_time,
member_username,
product_real_price,
product_count,
return_name,
status,
handle_time
FROM
oms_order_return_apply
WHERE
1 = 1
<if test="queryParam.id!=null">
AND id = #{queryParam.id}
</if>
<if test="queryParam.status!=null">
AND status = #{queryParam.status}
</if>
<if test="queryParam.status!=null">
AND status = #{queryParam.status}
</if>
<if test="queryParam.handleMan!=null and queryParam.handleMan!=''">
AND handle_man = #{queryParam.handleMan}
</if>
<if test="queryParam.createTime!=null and queryParam.createTime!=''">
AND create_time LIKE CONCAT(#{queryParam.createTime}, '%')
</if>
<if test="queryParam.handleTime!=null and queryParam.handleTime!=''">
AND handle_time LIKE CONCAT(#{queryParam.handleTime}, '%')
</if>
<if test="queryParam.receiverKeyword!=null and queryParam.receiverKeyword!=''">
AND (return_name LIKE concat("%",#{queryParam.receiverKeyword},"%")
OR return_phone LIKE concat("%",#{queryParam.receiverKeyword},"%"))
</if>
</select>
<select id="getDetail" resultMap="returnApplyDetailResultMap">
SELECT
ra.*, ca.id ca_id,
ca.address_name ca_address_name,
ca.`name` ca_name,
ca.phone ca_phone,
ca.province ca_province,
ca.city ca_city,
ca.region ca_region,
ca.detail_address ca_detail_address
FROM
oms_order_return_apply ra
LEFT JOIN oms_company_address ca ON ra.company_address_id = ca.id
WHERE ra.id=#{id};
</select>
</mapper>