123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace app\api\controller;
- use think\facade\Lang;
- class Voucher extends MobileMall
- {
- public function initialize()
- {
- parent::initialize();
- }
-
- public function voucher_tpl_list()
- {
- $param = array();
- $param['store_id'] = input('param.store_id');
- $param['gettype'] = input('param.gettype');
- $voucher_model = model('voucher');
- $templatestate_arr = $voucher_model->getTemplateState();
- $voucher_gettype_array = $voucher_model->getVoucherGettypeArray();
- $where = array();
- $where[] = array('vouchertemplate_if_private', '=', 0);
- $where[] = array('vouchertemplate_state', '=', $templatestate_arr['usable'][0]);
- $store_id = intval($param['store_id']);
- if ($store_id > 0) {
- $where[] = array('vouchertemplate_store_id', '=', $store_id);
- }
- $where[] = array('vouchertemplate_gettype', 'in', array($voucher_gettype_array['points']['sign'], $voucher_gettype_array['free']['sign']));
- if ($param['gettype'] && in_array($param['gettype'], array('points', 'free'))) {
- $where[] = array('vouchertemplate_gettype', '=', $voucher_gettype_array[$param['gettype']]['sign']);
- }
- $order = 'vouchertemplate_id asc';
- $voucher_list = $voucher_model->getVouchertemplateList($where, '*', 20, 0, $order);
- if ($voucher_list) {
- foreach ($voucher_list as $k => $v) {
- $v['vouchertemplate_limit'] = floatval($v['vouchertemplate_limit']);
- $v['vouchertemplate_enddate_text'] = $v['vouchertemplate_enddate'] ? @date('Y.m.d', $v['vouchertemplate_enddate']) : '';
- $voucher_list[$k] = $v;
- }
- }
- ds_json_encode(10000, '', array('voucher_list' => $voucher_list));
- }
- }
|