getMemberVoucherList($this->member_info['member_id'], $voucher_state, $this->pagesize); $result = array_merge(array('voucher_list' => $voucher_list), mobile_page($voucher_model->page_info)); ds_json_encode(10000, '', $result); } /** * @api {POST} api/Membervoucher/voucher_private 私密代金券 * @apiVersion 1.0.0 * @apiGroup MemberVoucher * * @apiHeader {String} X-DS-KEY 用户授权token * * @apiSuccess {String} code 返回码,10000为成功 * @apiSuccess {String} message 返回消息 * @apiSuccess {Object} result 返回数据 * @apiSuccess {Object[]} result.voucher_private 代金卷列表 (返回字段参考voucher表、store表、vouchertemplate表) * @apiSuccess {Int} result.page_total 总页数 * @apiSuccess {Boolean} result.hasmore 是否有更多 true是false否 */ public function voucher_private() { $voucher_model = model('voucher'); $condition = array(); $condition[] = array('vouchertemplate_id', '=', input('post.vouchertemplate_id')); $condition[] = array('vouchertemplate_if_private', '=', 1); $vouchertemplate_info = $voucher_model->getVouchertemplateInfo($condition); if (!empty($vouchertemplate_info)) { $vouchertemplate_info['vouchertemplate_startdate'] = date('Y.m.d', $vouchertemplate_info['vouchertemplate_startdate']); $vouchertemplate_info['vouchertemplate_enddate'] = date('Y.m.d', $vouchertemplate_info['vouchertemplate_enddate']); $result['vouchertemplate_info'] = $vouchertemplate_info; ds_json_encode(10000, '', $result); } else { ds_json_encode(10001, lang('param_error')); } } /** * @api {POST} api/Membervoucher/voucher_point 代金券领取 * @apiVersion 1.0.0 * @apiGroup MemberVoucher * * @apiHeader {String} X-DS-KEY 用户授权token * * @apiParam {String} tid 代金券模板id * * @apiSuccess {String} code 返回码,10000为成功 * @apiSuccess {String} message 返回消息 * @apiSuccess {Object} result 返回数据 */ public function voucher_point() { $vid = intval(input('post.tid')); if ($vid <= 0) { ds_json_encode(10001, lang('param_error')); } $voucher_model = model('voucher'); //验证是否可以兑换代金券 $data = $voucher_model->getCanChangeTemplateInfo($vid, $this->member_info['member_id'], $this->member_info['store_id']); if ($data['state'] == false) { ds_json_encode(10001, $data['msg']); } //添加代金券信息 $data = $voucher_model->exchangeVoucher($data['info'], $this->member_info['member_id'], $this->member_info['member_name']); if ($data['state'] == true) { ds_json_encode(10000, $data['msg'], 1); } else { ds_json_encode(10001, $data['msg']); } } }