Blame view

apps/home/models/orders-api.js 6.03 KB
weiqingting authored
1 2 3
/**
 * @author: weiqingting<qingting.wei@yoho.cn>
 */
weiqingting authored
4 5
'use strict';
郝肖肖 authored
6 7 8 9
module.exports = class extends global.yoho.BaseModel {
    constructor(ctx) {
        super(ctx);
    }
陈轩 authored
10
weiqingting authored
11 12
    /**
     * 我的订单-分页
weiqingting authored
13 14 15 16
     * @param type uid
     * @param type page
     * @param type limit
     * @param type type 获取订单类型 type=1全部,type=2待付款,type=3待发货,type=4待收货,type=5待评论(已成功) 7取消
weiqingting authored
17 18
     * @return type
     */
郝肖肖 authored
19 20
    getUserOrders(uid, page, limit, type) {
        let options = {
yyq authored
21
            method: 'app.SpaceOrders.list',
郝肖肖 authored
22 23 24 25 26 27 28 29
            uid: uid,
            type: type,
            page: page,
            limit: limit
        };

        return this.get({data: options});
    }
陈轩 authored
30
weiqingting authored
31 32
    /**
     * 订单详情
weiqingting authored
33 34
     * @param type uid
     * @param type orderCode
weiqingting authored
35 36
     * @return type
     */
郝肖肖 authored
37 38 39 40 41 42
    getOrderDetail(uid, orderCode) {
        let options = {
            method: 'app.SpaceOrders.detail',
            uid: uid,
            order_code: orderCode
        };
陈轩 authored
43
郝肖肖 authored
44 45
        return this.get({data: options});
    }
陈轩 authored
46
weiqingting authored
47 48
    /**
     * 取消订单
weiqingting authored
49 50
     * @param type uid
     * @param type orderCode
weiqingting authored
51 52
     * @return type
     */
郝肖肖 authored
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
    cancelUserOrder(uid, orderCode, reason, reasonId) {
        let options = {
            method: 'app.SpaceOrders.close',
            uid: uid,
            order_code: orderCode
        };

        if (reasonId) {
            Object.assign(options, {
                reasonId: reasonId,
                reasons: reason
            });
        }

        return this.get({data: options});
    }
陈轩 authored
69
weiqingting authored
70 71
    /**
     * 确认订单
weiqingting authored
72 73
     * @param type uid
     * @param type orderCode
weiqingting authored
74 75
     * @return type
     */
郝肖肖 authored
76 77 78 79 80 81 82 83 84
    confirmUserOrder(uid, orderCode) {
        let options = {
            method: 'app.SpaceOrders.confirm',
            uid: uid,
            order_code: orderCode
        };

        return this.get({data: options});
    }
陈轩 authored
85
weiqingting authored
86 87
    /**
     * 获取虚拟订单ticketCode
weiqingting authored
88
     * @param type orderCode
weiqingting authored
89 90
     * @return type
     */
郝肖肖 authored
91 92 93 94 95
    getTicketCode(orderCode) {
        let options = {
            method: 'app.SpaceOrders.getQrByOrderCode',
            order_code: orderCode
        };
yyq authored
96
郝肖肖 authored
97 98
        return this.get({data: options});
    }
陈轩 authored
99
郝肖肖 authored
100
    /**
weiqingting authored
101 102
     * 我的订单-查看物流
     *
weiqingting authored
103 104
     * @param int orderCode 订单号
     * @param int uid 用户ID
weiqingting authored
105 106
     * @return array
     */
郝肖肖 authored
107 108 109 110 111 112 113 114 115
    getLogisticsData(orderCode, uid) {
        let options = {
            method: 'app.express.li',
            order_code: orderCode,
            uid: uid
        };

        return this.get({data: options});
    }
陈轩 authored
116
weiqingting authored
117 118
    /**
     * 获取历史订单
weiqingting authored
119 120 121
     * @param type uid
     * @param type page
     * @param type limit
weiqingting authored
122
     */
郝肖肖 authored
123 124 125 126 127 128 129 130 131 132
    getHistoryOrders(uid, page, limit) {
        let options = {
            method: 'app.SpaceOrders.history',
            uid: uid,
            page: page,
            limit: limit
        };

        return this.get({data: options});
    }
陈轩 authored
133
weiqingting authored
134 135 136
    /**
     * 更新订单的支付方式
     *
weiqingting authored
137 138 139
     * @param int orderCode 订单号
     * @param int payment 支付方式
     * @param int uid 用户ID
weiqingting authored
140 141
     * @return array
     */
郝肖肖 authored
142 143 144 145 146 147 148 149 150 151
    updateOrderPayment(orderCode, payment, uid) {
        let options = {
            method: 'app.SpaceOrders.updateOrdersPaymentByCode',
            order_code: Number(orderCode),
            payment: payment,
            uid: uid
        };

        return this.get({data: options});
    }
陈轩 authored
152
weiqingting authored
153 154 155 156
    /**
     * 取消订单原因列表
     * @return type
     */
htoooth authored
157
    closeReasons(uid) {
郝肖肖 authored
158
        let options = {
htoooth authored
159 160
            method: 'app.SpaceOrders.closeReasons',
            uid
郝肖肖 authored
161 162
        };
周少峰 authored
163 164 165 166 167
        return this.get({data: options,
            param: {
                cache: 86400
            }
        });
郝肖肖 authored
168
    }
陈轩 authored
169
weiqingting authored
170 171
    /**
     * 订单详情页——地址修改
weiqingting authored
172 173
     * @param type order_code
     * @param type address_id
weiqingting authored
174 175
     * @return type
     */
郝肖肖 authored
176 177 178 179 180 181 182 183 184
    updateDeliveryAddress(orderId, userName, areaCode, address, mobile, phone, uid, udid) {
        let options = {
            method: 'app.SpaceOrders.updateDeliveryAddress',
            order_code: orderId,
            user_name: userName,
            area_code: areaCode,
            address: address,
            uid: uid
        };
htoooth authored
185
郝肖肖 authored
186 187 188
        if (mobile) {
            Object.assign(options, {mobile: mobile});
        }
htoooth authored
189
郝肖肖 authored
190 191 192
        if (phone) {
            Object.assign(options, {phone: phone});
        }
htoooth authored
193
郝肖肖 authored
194 195 196
        if (udid) {
            Object.assign(options, {udid: udid});
        }
yyq authored
197
郝肖肖 authored
198 199
        return this.get({data: options});
    }
陈轩 authored
200
weiqingting authored
201 202 203
    /**
     * 查看订单详情
     *
weiqingting authored
204 205 206
     * @param string orderCode 订单号
     * @param int uid 用户ID
     * @param string sessionKey 用户会话
weiqingting authored
207 208
     * @return array
     */
郝肖肖 authored
209 210 211 212 213 214 215
    viewOrderData(orderCode, uid, sessionKey) {
        let options = {
            method: 'app.SpaceOrders.info',
            order_code: orderCode,
            uid: uid,
            session_key: sessionKey
        };
htoooth authored
216
郝肖肖 authored
217 218
        return this.get({data: options});
    }
htoooth authored
219
郝肖肖 authored
220 221 222 223 224 225 226 227 228
    /**
     * 重新加入购物车
     */
    reBuy(uid, orderId) {
        let options = {
            method: 'app.Shopping.readd',
            uid: uid,
            order_code: orderId
        };
htoooth authored
229
郝肖肖 authored
230 231 232 233 234 235 236 237 238 239 240 241 242 243
        return this.get({data: options});
    }

    /**
     * 删除订单数据
     */
    del(uid, gender, channel, orderId) {
        let options = {
            method: 'app.SpaceOrders.delOrderByCode',
            uid: uid,
            gender: gender,
            yh_channel: channel,
            order_code: orderId
        };
htoooth authored
244
郝肖肖 authored
245
        return this.get({data: options});
htoooth authored
246 247
    }
郝肖肖 authored
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266
    /**
     * 申请退款
     */
    refund(uid, orderId, reasonId, reason) {
        let options = {
            method: 'app.SpaceOrders.refundApply',
            uid: uid,
            order_code: orderId
        };

        if (reasonId) {
            options.reason_id = reasonId;
        }

        if (reason) {
            options.reason = reason;
        }

        return this.get({data: options});
htoooth authored
267 268
    }
郝肖肖 authored
269 270 271 272 273 274 275
    /**
     * 申请退款原因
     */
    refundReason() {
        let options = {
            method: 'app.SpaceOrders.refundApplyReasons'
        };
htoooth authored
276
郝肖肖 authored
277 278
        return this.get({data: options});
    }
htoooth authored
279 280
};