import { message } from 'antd'; import { routerRedux } from 'dva/router'; import { queryTerminalBuyMsg, queryOrderList, queryOrderItem, querySubOrderItem, createOrderItem, invalidOrderItem, payOrderItem, sendOrderItem, receiveOrderItem, } from '../services/trade'; export default { namespace: 'trade', state: { list: [], pageNo: 1, pageSize: 15, totalSize: 0, currentItem: {}, }, effects: { *fetchTerminalBuyMsg({ payload }, { call, put }) { const response = yield call(queryTerminalBuyMsg, payload); if (response.success) { message.success('加载终端购物车列表成功'); yield put({ type: 'querySuccess', payload: { list: response.data || [], }, }); } }, *createOrderItem({ payload }, { call }) { const response = yield call(createOrderItem, payload); if (response.success) { message.success('创建订单成功'); } }, }, reducers: { querySuccess(state, action) { return { ...state, ...action.payload, }; }, fixList(state, action) { return { ...state, ...action.payload, }; }, fixCurrentItem(state, action) { const { currentItem } = state; return { ...state, currentItem: { ...currentItem, ...action.payload, }, }; }, cleanState(state) { return { ...state, currentItem: {}, list: [], }; }, }, };