当前位置:Gxlcms > PHP教程 > PHP/THINKPHP创建优惠券码

PHP/THINKPHP创建优惠券码

时间:2021-07-01 10:21:17 帮助过:18人阅读

namespaceAddons\Coupon\Controller;
useHome\Controller\AddonsController;

classWapControllerextendsAddonsController{protected$model;
    publicfunction__construct() {$GLOBALS ['is_wap'] = true;

        parent::__construct ();
        $uid= get_uid_by_openid();
        $this->model = getModelByName ('coupon');
        $this->model || $this->error ( 'model is not found!' );
    }

    /*
     * Create coupon code
     * 
     * @param  $namespace string
     * @return $guid string 
     * @author sun
     */privatefunctioncreate_guid($namespace = '') {static$guid = '';
        $uid = uniqid("", true);
        $data = $namespace;
        $data .= $_SERVER['REQUEST_TIME'];
        $data .= $_SERVER['HTTP_USER_AGENT'];
        $data .= $_SERVER['LOCAL_ADDR'];
        $data .= $_SERVER['LOCAL_PORT'];
        $data .= $_SERVER['REMOTE_ADDR'];
        $data .= $_SERVER['REMOTE_PORT'];
        $hash = strtoupper(hash('ripemd128', $uid . $guid . md5($data)));
        // test str combination$guid =
        substr($hash, 0, 6) .
        '-' .
        substr($hash, 8, 4) .
        '-' .
        substr($hash, 12, 4) .
        '-' .
        substr($hash, 16, 4) .
        '-' .
        substr($hash, 20, 8);
        return$guid;
    }

}


// end

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('
  • ').text(i)); }; $numbering.fadeIn(1700); }); });

    以上就介绍了PHP/THINKPHP创建优惠券码,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

  • 人气教程排行