<?php

namespace app\api\controller;

use think\facade\Lang;

/**
 * ============================================================================
 * 
 * ============================================================================
 * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司，并保留所有权利。
 * 网站地址: https://www.valimart.net/
 * ----------------------------------------------------------------------------
 * 
 * ============================================================================
 * 到货通知控制器
 */
class MemberArrivalnotice extends MobileMember {

    public function initialize() {
        parent::initialize(); // TODO: Change the autogenerated stub
        Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/member_arrivalnotice.lang.php');
    }

    /**
     * @api {POST} api/MemberArrivalnotice/get_list 消息列表
     * @apiVersion 1.0.0
     * @apiGroup MemberArrivalnotice
     *
     * @apiHeader {String} X-DS-KEY 用户授权token
     * 
     * @apiParam {Int} page 页码
     * @apiParam {Int} per_page 每页数量
     *
     * @apiSuccess {String} code 返回码,10000为成功
     * @apiSuccess {String} message  返回消息
     * @apiSuccess {Object} result  返回数据
     * @apiSuccess {Object[]} result.arrivalnotice_list  到货通知列表
     * @apiSuccess {Int} result.page_total  总页数
     * @apiSuccess {Boolean} result.hasmore  是否有更多 true是false否
     */
    public function get_list() {
        $arrivalnotice_model = model('arrivalnotice');

        $arrivalnotice_list = $arrivalnotice_model->getArrivalNoticeList(array('member_id' => $this->member_info['member_id']), '', '', '', $this->pagesize);


        ds_json_encode(10000, '', array_merge(array('arrivalnotice_list' => $arrivalnotice_list), mobile_page($arrivalnotice_model->page_info)));
    }

    public function del() {
        $arrivalnotice_id = input('param.arrivalnotice_id');
        $arrivalnotice_id_array = ds_delete_param($arrivalnotice_id);
        if ($arrivalnotice_id_array == FALSE) {
            ds_json_encode('10001', lang('param_error'));
        }
        $condition = array(array('member_id', '=', $this->member_info['member_id']));
        $condition[] = array('arrivalnotice_id', 'in', $arrivalnotice_id_array);
        $arrivalnotice_model = model('arrivalnotice');
        //批量删除
        $result = $arrivalnotice_model->delArrivalNotice($condition);
        if ($result) {
            ds_json_encode(10000, lang('ds_common_op_succ'));
        } else {
            ds_json_encode(10001, lang('ds_common_op_fail'));
        }
    }

}
