diff --git a/admin-web/src/models/orderRefunds/orderRefunds.js b/admin-web/src/models/orderRefunds/orderRefunds.js index 82111fcaf..87ed12315 100644 --- a/admin-web/src/models/orderRefunds/orderRefunds.js +++ b/admin-web/src/models/orderRefunds/orderRefunds.js @@ -1,4 +1,5 @@ -import { list } from '../../services/orderRefunds'; +import { message } from 'antd'; +import { list, agree, refuse, confirmReceipt, confirmRefund } from '../../services/orderRefunds'; export default { namespace: 'orderRefunds', @@ -18,6 +19,54 @@ export default { payload: response.data, }); }, + *agree({ payload }, { call }) { + const { callback, params } = payload; + const response = yield call(agree, params); + if (response.code !== 0) { + message.error('操作失败!'); + } else { + message.success('操作成功!'); + if (callback) { + callback(response); + } + } + }, + *refuse({ payload }, { call }) { + const { callback, params } = payload; + const response = yield call(refuse, params); + if (response.code !== 0) { + message.error('操作失败!'); + } else { + message.success('操作成功!'); + if (callback) { + callback(response); + } + } + }, + *confirmReceipt({ payload }, { call }) { + const { callback, params } = payload; + const response = yield call(confirmReceipt, params); + if (response.code !== 0) { + message.error('操作失败!'); + } else { + message.success('操作成功!'); + if (callback) { + callback(response); + } + } + }, + *confirmRefund({ payload }, { call }) { + const { callback, params } = payload; + const response = yield call(confirmRefund, params); + if (response.code !== 0) { + message.error('操作失败!'); + } else { + message.success('操作成功!'); + if (callback) { + callback(response); + } + } + }, }, reducers: { diff --git a/admin-web/src/pages/OrderRefunds/OrderRefundsList.js b/admin-web/src/pages/OrderRefunds/OrderRefundsList.js index 8230041a2..3f4607792 100644 --- a/admin-web/src/pages/OrderRefunds/OrderRefundsList.js +++ b/admin-web/src/pages/OrderRefunds/OrderRefundsList.js @@ -1,7 +1,7 @@ import React, { PureComponent } from 'react'; import { connect } from 'dva'; import moment from 'moment'; -import { Card, Tabs, Table } from 'antd'; +import { Card, Tabs, Modal, Table, Divider } from 'antd'; import PageHeaderWrapper from '../../components/PageHeaderWrapper'; import DictionaryText from '../../components/Dictionary/DictionaryText'; import TableSearch from './TableSearch'; @@ -19,29 +19,46 @@ import dictionary from '../../utils/dictionary'; class OrderRefundsList extends PureComponent { componentDidMount() { // 查询 list - this.queryList({ index: 1 }, {}); + this.queryList({ index: 1, pageSize: 10 }, {}); } handleSearch = searchParams => { const { orderRefunds } = this.props; const { index, pageSize } = orderRefunds; - this.queryList({ index, pageSize }, searchParams); + this.queryList( + { index, pageSize }, + { + ...searchParams, + ...this.tabsValue, + } + ); }; - queryList = ({ index = 0, pageSize = 10 }, searchParams) => { + queryList = (pageParams, searchParams) => { const { dispatch } = this.props; + + this.pageParams = pageParams; + this.searchParams = searchParams; dispatch({ type: 'orderRefunds/list', payload: { - index, - pageSize, + ...pageParams, ...searchParams, }, }); }; handleTabsChange = value => { - console.log(value); + this.tabsValue = { + status: value, + }; + this.queryList( + { index: 1, pageSize: 10 }, + { + ...this.searchParams, + status: value, + } + ); }; handleTableChange = pagination => { @@ -49,11 +66,116 @@ class OrderRefundsList extends PureComponent { this.queryList({ pageSize, index: current }, {}); }; + handleAgreeClick = ({ id }) => { + const { dispatch } = this.props; + const self = this; + Modal.confirm({ + title: '提示消息', + content: '确认同意!', + onOk() { + dispatch({ + type: 'orderRefunds/agree', + payload: { + params: { + id, + }, + callback: () => { + self.queryList(self.pageParams, self.searchParams); + }, + }, + }); + }, + onCancel() { + console.log('Cancel'); + }, + }); + }; + + handleRefuse = ({ id }) => { + const { dispatch } = this.props; + const self = this; + Modal.confirm({ + title: '提示消息', + content: '确认拒绝!', + onOk() { + dispatch({ + type: 'orderRefunds/refuse', + payload: { + params: { + id, + }, + callback: () => { + self.queryList(self.pageParams, self.searchParams); + }, + }, + }); + }, + onCancel() { + console.log('Cancel'); + }, + }); + }; + + handleConfirmReceipt = ({ id }) => { + const { dispatch } = this.props; + const self = this; + Modal.confirm({ + title: '提示消息', + content: '确认收货!', + onOk() { + dispatch({ + type: 'orderRefunds/confirmReceipt', + payload: { + params: { + id, + }, + callback: () => { + self.queryList(self.pageParams, self.searchParams); + }, + }, + }); + }, + onCancel() { + console.log('Cancel'); + }, + }); + }; + + handleConfirmRefund = ({ id }) => { + const { dispatch } = this.props; + const self = this; + Modal.confirm({ + title: '提示消息', + content: '确认退款!', + onOk() { + dispatch({ + type: 'orderRefunds/confirmRefund', + payload: { + params: { + id, + }, + callback: () => { + self.queryList(self.pageParams, self.searchParams); + }, + }, + }); + }, + onCancel() { + console.log('Cancel'); + }, + }); + }; + render() { - const { orderRefunds } = this.props; + const { orderRefunds, loading } = this.props; const { list, totalCount, index, pageSize } = orderRefunds; const columns = [ + { + title: '订单号', + dataIndex: 'orderId', + key: 'orderId', + }, { title: '服务编号', dataIndex: 'serviceNumber', @@ -111,12 +233,31 @@ class OrderRefundsList extends PureComponent { }, { title: '操作', - render() { - return ( -
- 同意 -
- ); + render: row => { + const { status } = row; + let buttons; + if (status === 1) { + buttons = ( +
+ 同意 + + 拒绝 +
+ ); + } else if (status === 2) { + buttons = ( +
+ 确认收货 +
+ ); + } else if (status === 5) { + buttons = ( +
+ 退款 +
+ ); + } + return buttons; }, }, ]; @@ -137,11 +278,14 @@ class OrderRefundsList extends PureComponent { - - + + + + >} */ const TableSearch = Form.create()(props => { - const { getFieldDecorator, form, handleSearch } = props.form; + const { handleSearch } = props; + const { getFieldDecorator, validateFields, form } = props.form; function onSubmit(e) { e.preventDefault(); - form.validateFields((err, fields) => { + validateFields((err, fields) => { const buildTime = (fieldValue, key) => { const res = {}; if (fieldValue && fieldValue.length >= 2) { @@ -68,6 +69,11 @@ const TableSearch = Form.create()(props => { {getFieldDecorator('orderNo')()} + + + {getFieldDecorator('serviceNumber')()} + + diff --git a/admin-web/src/services/orderRefunds.js b/admin-web/src/services/orderRefunds.js index 62f417ea4..94eb68b40 100644 --- a/admin-web/src/services/orderRefunds.js +++ b/admin-web/src/services/orderRefunds.js @@ -8,8 +8,26 @@ export async function list(params) { }); } -export async function orderPage(params) { - return request(`/order-api/admins/order/page?${stringify(params)}`, { - method: 'GET', +export async function agree(params) { + return request(`/order-api/admins/order_return/agree?${stringify(params)}`, { + method: 'POST', + }); +} + +export async function refuse(params) { + return request(`/order-api/admins/order_return/refuse?${stringify(params)}`, { + method: 'POST', + }); +} + +export async function confirmReceipt(params) { + return request(`/order-api/admins/order_return/confirm_receipt?${stringify(params)}`, { + method: 'POST', + }); +} + +export async function confirmRefund(params) { + return request(`/order-api/admins/order_return/confirm_refund?${stringify(params)}`, { + method: 'POST', }); } diff --git a/mobile-web/src/assets/style/common.css b/mobile-web/src/assets/style/common.css index a49a9c171..fd9190ff6 100644 --- a/mobile-web/src/assets/style/common.css +++ b/mobile-web/src/assets/style/common.css @@ -14,18 +14,26 @@ body { border-right: 1px solid #ccc2bf; } -#app, .van-goods-action, .van-overflow-hidden { - max-width: 600px!important; - margin: 0 auto; +@media screen and (min-width: 769px) { + #app, .van-goods-action, .van-overflow-hidden { + max-width: 600px!important; + margin: 0 auto; + } + + .van-tabbar, .van-submit-bar { + max-width: 600px!important; + position:fixed; + margin:auto; + left:0; + right:0; + } +} +.wap-wrap { + font-size: 0.32rem; + width: 100%; } -.van-tabbar, .van-submit-bar { - max-width: 600px!important; - position:fixed; - margin:auto; - left:0; - right:0; -} + #maxWidth { diff --git a/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/admins/AdminOrderReturnController.java b/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/admins/AdminOrderReturnController.java index c2e1bd906..de95a3049 100644 --- a/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/admins/AdminOrderReturnController.java +++ b/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/admins/AdminOrderReturnController.java @@ -46,13 +46,13 @@ public class AdminOrderReturnController { return orderReturnService.orderReturnRefuse(id); } - @PostMapping("confirm_commodity") - public CommonResult confirmCommodity(@RequestParam("id") Integer id) { + @PostMapping("confirm_receipt") + public CommonResult confirmReceipt(@RequestParam("id") Integer id) { return orderReturnService.confirmReceipt(id); } - @PostMapping("confirm_order") - public CommonResult confirmOrder(HttpServletRequest request, @RequestParam("id") Integer id) { + @PostMapping("confirm_refund") + public CommonResult confirmRefund(HttpServletRequest request, @RequestParam("id") Integer id) { String ip = HttpUtil.getIp(request); return orderReturnService.refund(id, ip); } diff --git a/order/order-application/src/main/java/cn/iocoder/mall/order/application/po/admin/OrderReturnQueryPO.java b/order/order-application/src/main/java/cn/iocoder/mall/order/application/po/admin/OrderReturnQueryPO.java index 99e185e90..b1b496b32 100644 --- a/order/order-application/src/main/java/cn/iocoder/mall/order/application/po/admin/OrderReturnQueryPO.java +++ b/order/order-application/src/main/java/cn/iocoder/mall/order/application/po/admin/OrderReturnQueryPO.java @@ -2,6 +2,7 @@ package cn.iocoder.mall.order.application.po.admin; import lombok.Data; import lombok.experimental.Accessors; +import org.springframework.format.annotation.DateTimeFormat; import javax.validation.constraints.NotNull; import java.io.Serializable; @@ -26,14 +27,24 @@ public class OrderReturnQueryPO implements Serializable { * 订单编号 */ private Integer orderNo; + /** + * 服务号 + */ + private String serviceNumber; /** * 创建时间 - 开始 */ + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date startCreateTime; /** * 创建时间 - 结束 */ + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date endCreateTime; + /** + * 状态 + */ + private Integer status; /// /// 分页信息 diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderReturnQueryDTO.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderReturnQueryDTO.java index dc98e13c8..fe775ae4e 100644 --- a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderReturnQueryDTO.java +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderReturnQueryDTO.java @@ -25,6 +25,10 @@ public class OrderReturnQueryDTO implements Serializable { * 订单编号 */ private Integer orderNo; + /** + * 服务号 + */ + private String serviceNumber; /** * 创建时间 - 开始 */ @@ -33,6 +37,10 @@ public class OrderReturnQueryDTO implements Serializable { * 创建时间 - 结束 */ private Date endCreateTime; + /** + * 状态 + */ + private Integer status; /// /// 分页信息 diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dao/OrderReturnMapper.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dao/OrderReturnMapper.java index ea25d903e..5e4277bf6 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dao/OrderReturnMapper.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dao/OrderReturnMapper.java @@ -30,7 +30,7 @@ public interface OrderReturnMapper { * @param orderReturnDO * @return */ - int updateByOrderId(OrderReturnDO orderReturnDO); + int updateById(OrderReturnDO orderReturnDO); /** * 查询 - 根据 orderId diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dataobject/OrderReturnDO.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dataobject/OrderReturnDO.java index 90a27a524..242844968 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dataobject/OrderReturnDO.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dataobject/OrderReturnDO.java @@ -63,6 +63,10 @@ public class OrderReturnDO extends BaseDO { * 同意时间 */ private Date approvalTime; + /** + * 拒绝时间 + */ + private Date refuseTime; /** * 物流时间(填写物流单号时间) */ @@ -90,8 +94,7 @@ public class OrderReturnDO extends BaseDO { * - 3、申请失败 * - 4、退货中 * - 5、已收货 - * - 6、拒绝退款 - * - 7、退货成功 + * - 6、退货成功 */ private Integer status; } diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/OrderReturnServiceImpl.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/OrderReturnServiceImpl.java index ec303e3b7..c96a7a19e 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/OrderReturnServiceImpl.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/OrderReturnServiceImpl.java @@ -3,15 +3,14 @@ package cn.iocoder.mall.order.biz.service; import cn.iocoder.common.framework.constant.DeletedStatusEnum; import cn.iocoder.common.framework.util.ServiceExceptionUtil; import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.admin.api.DataDictService; +import cn.iocoder.mall.admin.api.bo.DataDictBO; import cn.iocoder.mall.order.api.OrderLogisticsService; import cn.iocoder.mall.order.api.OrderReturnService; import cn.iocoder.mall.order.api.bo.OrderLastLogisticsInfoBO; import cn.iocoder.mall.order.api.bo.OrderReturnInfoBO; import cn.iocoder.mall.order.api.bo.OrderReturnListBO; -import cn.iocoder.mall.order.api.constant.OrderErrorCodeEnum; -import cn.iocoder.mall.order.api.constant.OrderReturnStatusEnum; -import cn.iocoder.mall.order.api.constant.OrderStatusEnum; -import cn.iocoder.mall.order.api.constant.PayAppId; +import cn.iocoder.mall.order.api.constant.*; import cn.iocoder.mall.order.api.dto.OrderReturnApplyDTO; import cn.iocoder.mall.order.api.dto.OrderReturnQueryDTO; import cn.iocoder.mall.order.biz.convert.OrderReturnConvert; @@ -55,6 +54,9 @@ public class OrderReturnServiceImpl implements OrderReturnService { private OrderLogisticsService orderLogisticsService; @Reference(validation = "true", version = "${dubbo.consumer.PayRefundService.version}") private PayRefundService payRefundService; + @Reference(validation = "true", version = "${dubbo.consumer.DataDictService.version}") + private DataDictService dataDictService; + @Override public CommonResult orderReturnApply(OrderReturnApplyDTO orderReturnDTO) { @@ -156,9 +158,10 @@ public class OrderReturnServiceImpl implements OrderReturnService { .error(OrderErrorCodeEnum.ORDER_RETURN_NOT_EXISTENT.getCode()); } - orderReturnMapper.updateByOrderId( + orderReturnMapper.updateById( new OrderReturnDO() .setId(id) + .setApprovalTime(new Date()) .setStatus(OrderReturnStatusEnum.APPLICATION_SUCCESSFUL.getValue()) ); return CommonResult.success(null); @@ -171,9 +174,10 @@ public class OrderReturnServiceImpl implements OrderReturnService { return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_RETURN_NOT_EXISTENT.getCode()); } - orderReturnMapper.updateByOrderId( + orderReturnMapper.updateById( new OrderReturnDO() .setId(id) + .setRefuseTime(new Date()) .setStatus(OrderReturnStatusEnum.APPLICATION_FAIL.getValue()) ); return CommonResult.success(null); @@ -186,9 +190,10 @@ public class OrderReturnServiceImpl implements OrderReturnService { return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_RETURN_NOT_EXISTENT.getCode()); } - orderReturnMapper.updateByOrderId( + orderReturnMapper.updateById( new OrderReturnDO() .setId(id) + .setReceiverTime(new Date()) .setStatus(OrderReturnStatusEnum.ORDER_RECEIPT.getValue()) ); return CommonResult.success(null); @@ -207,13 +212,24 @@ public class OrderReturnServiceImpl implements OrderReturnService { // TODO: 2019/5/8 sin 退货+退款:退回商品签收后,支付系统退款 // TODO: 2019/5/8 sin 事务一致性 [重要] + + CommonResult dataDictResult = dataDictService + .getDataDict(DictKeyConstants.ORDER_RETURN_REASON, orderReturnDO.getReason()); + + if (dataDictResult.isError()) { + return ServiceExceptionUtil.error(OrderErrorCodeEnum.DICT_SERVER_INVOKING_FAIL.getCode()); + } + // 支付退款 + String orderDescription = dataDictResult.getData() + .getDisplayName() + "(" + orderReturnDO.getDescribe() + ")"; + CommonResult payResult = payRefundService.submitRefund( new PayRefundSubmitDTO() .setAppId(PayAppId.APP_ID_SHOP_ORDER) .setOrderId(String.valueOf(orderReturnDO.getOrderId())) .setPrice(orderReturnDO.getRefundPrice()) - .setOrderDescription("") + .setOrderDescription(orderDescription) .setCreateIp(ip) ); @@ -222,9 +238,10 @@ public class OrderReturnServiceImpl implements OrderReturnService { } // 更新 订单退货 信息 - orderReturnMapper.updateByOrderId( + orderReturnMapper.updateById( new OrderReturnDO() .setId(id) + .setClosingTime(new Date()) .setStatus(OrderReturnStatusEnum.RETURN_SUCCESS.getValue()) ); @@ -232,13 +249,16 @@ public class OrderReturnServiceImpl implements OrderReturnService { orderMapper.updateById( new OrderDO() .setId(orderReturnDO.getOrderId()) + .setClosingTime(new Date()) .setStatus(OrderStatusEnum.COMPLETED.getValue()) ); // 更新订单 orderItemMapper.updateByOrderId( orderReturnDO.getOrderId(), - new OrderItemDO().setStatus(OrderStatusEnum.COMPLETED.getValue()) + new OrderItemDO() + .setClosingTime(new Date()) + .setStatus(OrderStatusEnum.COMPLETED.getValue()) ); return CommonResult.success(null); } diff --git a/order/order-service-impl/src/main/resources/mapper/OrderReturnMapper.xml b/order/order-service-impl/src/main/resources/mapper/OrderReturnMapper.xml index d760bf025..a397240f5 100644 --- a/order/order-service-impl/src/main/resources/mapper/OrderReturnMapper.xml +++ b/order/order-service-impl/src/main/resources/mapper/OrderReturnMapper.xml @@ -12,6 +12,7 @@ reason, `describe`, approval_time, + refuse_time, logistics_time, receiver_time, closing_time, @@ -28,13 +29,13 @@ INSERT INTO `order_return` ( service_number, order_id, order_no, order_logistics_id, refund_price, reason, `describe`, - approval_time, logistics_time, receiver_time, closing_time, + approval_time, refuse_time, logistics_time, receiver_time, closing_time, service_type, status, create_time, update_time) VALUES ( #{serviceNumber}, #{orderId}, #{orderNo}, #{orderLogisticsId}, ${refundPrice}, #{reason}, #{describe}, - #{approvalTime}, #{logisticsTime}, #{receiverTime}, #{closingTime}, + #{approvalTime}, #{refuse_time}, #{logisticsTime}, #{receiverTime}, #{closingTime}, #{serviceType}, #{status}, #{createTime}, #{updateTime}) @@ -58,20 +59,20 @@ , approval_time = #{approvalTime} + + , refuse_time = #{refuseTime} + , logistics_time = #{logisticsTime} , receiver_time = #{receiverTime} - - , delivery_time = #{deliveryTime} - , closing_time = #{closingTime} - - , return_type = #{returnType} + + , service_type = #{serviceType} , status = #{status} @@ -88,10 +89,10 @@ - + UPDATE `order_return` - WHERE order_id = #{orderId} + WHERE id = #{id} + + AND status = #{status} + + + AND service_number = #{serviceNumber} + AND order_id = #{orderId} diff --git a/system/system-sdk/src/main/java/cn/iocoder/mall/admin/sdk/interceptor/AdminSecurityInterceptor.java b/system/system-sdk/src/main/java/cn/iocoder/mall/admin/sdk/interceptor/AdminSecurityInterceptor.java index 0954cae9b..9c2d7c894 100644 --- a/system/system-sdk/src/main/java/cn/iocoder/mall/admin/sdk/interceptor/AdminSecurityInterceptor.java +++ b/system/system-sdk/src/main/java/cn/iocoder/mall/admin/sdk/interceptor/AdminSecurityInterceptor.java @@ -67,7 +67,7 @@ public class AdminSecurityInterceptor extends HandlerInterceptorAdapter { } // 校验是否需要已授权 // TODO sin 暂时不校验 - // checkPermission(request, authentication); + checkPermission(request, authentication); // 返回成功 return super.preHandle(request, response, handler); }