public function getPoster(){
global $_W;
global $_GPC;
$mm = pdo_fetch('select nickname,codetime from ' . tablename('ewei_shop_member') . ' where openid =:openid limit 1', array(':openid' => $_W['openid']));
$path = IA_ROOT . '/addons/ewei_shopv2/data/couponposter/' . $_W['uniacid'] . '/';
if (!(is_dir($path)))
{
load()->func('file');
mkdirs($path);
}
$openid = $_W['openid'];
if($mm['codetime'])$mm['codetime'] = date('Ymd');
$md5 = md5(json_encode(array('openid' => $openid,'version' => 3,'timezone' => $mm['codetime'])));
$file = $md5 . '.jpg';
if(time() > strtotime($mm['codetime']) + 60*60*24*29){
$aa = unlink($path . $file);
}
// var_dump($path . $file);exit;
if (!(is_file($path . $file)))
{
set_time_limit(0);
@ini_set('memory_limit', '256M');
$font = IA_ROOT . '/addons/ewei_shopv2/static/fonts/msyh.ttf';
$target = imagecreatetruecolor(750, 1334);
$bc = imagecolorallocate($target, 0, 3, 51);
$cc = imagecolorallocate($target, 240, 102, 0);
$wc = imagecolorallocate($target, 255, 255, 255);
$yc = imagecolorallocate($target, 255, 255, 0);
$bg = imagecreatefromjpeg(IA_ROOT . '/addons/ewei_shopv2/data/couponposter/poster.jpg');
imagecopy($target, $bg, 0, 0, 0, 0, 750, 1334);
imagedestroy($bg);
// $qrcode_file = tomedia($this->createMyShopQrcode($userinfo['id']));
$qrcode_url = $this->getCode();
$qrcode = $this->createImage($qrcode_url);
// var_dump($qrcode);
$w = imagesx($qrcode);
$h = imagesy($qrcode);
imagecopyresized($target, $qrcode, 215, 600, 0, 0, 320, 320, $w, $h);
imagedestroy($qrcode);
$str1 = $this->getWords($mm['nickname'],3);
imagettftext($target, 22, 0, 180, 302, $bc, $font, $str1);
$str2 = date("Y-m-d",strtotime("+30 day"));
imagettftext($target, 18, 0, 420, 398, $bc, $font, $str2);
imagejpeg($target, $path . $file);
imagedestroy($target);
}
$srcc = $_W['siteroot'] . 'addons/ewei_shopv2/data/couponposter/' . $_W['uniacid'] . '/' . $file;
$arr = array('code' => 1, 'src' => $srcc);
show_json(1, $arr);
}