Ejemplo n.º 1
0
 static function pic_convert($side, $data, $design_id, $app_id, $bucket = "open-edit")
 {
     $retun["side"] = $side;
     pt_log("side ---" . $side);
     if ($design_id && $app_id) {
         $tempfilepath = "/tmp/tempFile/" . $app_id . $design_id . '-' . $side;
         if (!is_dir(dirname($tempfilepath . ".svg"))) {
             mkdir(dirname($tempfilepath . ".svg"), 0777, 1);
         }
         file_put_contents($tempfilepath . ".svg", $data);
         $thumbpath = 'designs/' . $app_id . "/" . $design_id . "/" . $side . ".png";
         try {
             ImgConvert::svg2png($tempfilepath . ".svg", $tempfilepath . ".png", "", 200, 200);
             ImgConvert::gen_thumb($tempfilepath . ".png", $tempfilepath . "_thumb.png");
             AliyunOssApi::oss_upload_file($bucket, $tempfilepath . "_thumb.png", $thumbpath);
             $retun["status"] = 'OK';
             $retun["msg"] = "REPLACE_DOMAIN_WITH/" . $thumbpath;
         } catch (Exception $e) {
             $retun["status"] = 'EERROR';
             $retun["msg"] = $e->getMessage();
         }
     } else {
         $retun["status"] = 'EERROR';
         $retun["msg"] = 'design_id or app_id is null';
     }
     return $retun;
 }
Ejemplo n.º 2
0
 /**
  * 生成微信支付二维码所需URL 如:weixin://wxpay/bizpayurl?pr=FtBh818
  * @param $notify_url
  * @param $order_info
  * @return mixed
  * @throws Exception
  */
 function build_get_wcpay_qrcode_url($notify_url, $order_info, $product_id = '')
 {
     $input = new WxPayUnifiedOrder();
     $input->SetBody($order_info['body']);
     //$input->SetAttach("test");
     //$order_info['order_no'] =  WxPayConfig::MCHID.date("YmdHis");
     $input->SetOut_trade_no($order_info['order_no']);
     $input->SetTotal_fee($order_info['price'] * 100);
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     //$input->SetGoods_tag("test");
     $input->SetNotify_url($notify_url);
     $input->SetTrade_type("NATIVE");
     $input->SetProduct_id($product_id);
     $notify = new NativePay();
     $result = $notify->GetPayUrl($input);
     if (!empty($result['result_code']) && $result['result_code'] == 'FAIL') {
         throw new Exception($result['err_code_des']);
     }
     if (!empty($result["code_url"])) {
         $url = $result["code_url"];
     } else {
         throw new Exception("未知错误");
     }
     pt_log($url);
     return $url;
 }
Ejemplo n.º 3
0
 /**
  * 生成缩略图
  * @param $org_name      原绝对地址
  * @param $dst_name      生成图绝对地址
  * @param int $t_width   生成缩略图宽
  * @param int $t_height  生成缩略图高
  * @return bool
  * @throws Exception
  *
  * convert -page 200x200+0+0 font1111.png -background none  -compose Xor -flatten result.png
  */
 static function gen_thumb($org_name, $dst_name, $t_width = 200, $t_height = 200)
 {
     list($width, $height) = getimagesize($org_name);
     //pt_log($width);
     //pt_log($height);
     $x = 0;
     if ($width < $t_width) {
         $x = ($t_width - $width) / 2;
     }
     $org_path = realpath($org_name);
     $cmd = "convert -page {$t_width}x{$t_height}+{$x}+0 {$org_path} -background none  -compose Xor -flatten {$dst_name}";
     pt_log($cmd);
     system($cmd, $return_var);
     if ($return_var > 0) {
         // convert error
         throw new Exception("文件转换失败");
     }
     return true;
 }
Ejemplo n.º 4
0
 public function NotifyProcess($data, &$msg)
 {
     pt_log("call back:" . json_encode($data));
     $notfiyOutput = array();
     if (!array_key_exists("transaction_id", $data)) {
         $msg = "输入参数不正确";
         return false;
     }
     //查询订单,判断订单真实性
     if (!$this->Queryorder($data["transaction_id"])) {
         $msg = "订单查询失败";
         return false;
     }
     //微信支付订单号
     $transaction_id = $data['transaction_id'];
     //系统订单号
     $order_no = $data['out_trade_no'];
     return true;
 }
Ejemplo n.º 5
0
 /**
  *
  * 通过code从工作平台获取openid机器access_token
  * @param string $code 微信跳转回来带上的code
  *
  * @return openid
  */
 public function GetOpenidFromMp($code)
 {
     $url = $this->__CreateOauthUrlForOpenid($code);
     pt_log($url);
     $curl = new PtCurl();
     $res = $curl->get($url);
     pt_log($res['body']);
     $data = json_decode($res['body'], true);
     $this->data = $data;
     $openid = $data['openid'];
     //echo $openid;
     return $openid;
 }
Ejemplo n.º 6
0
 static function update_activity_product_style($activity_id, $product_id, $product_style_id, $value)
 {
     pt_log(array($activity_id, $product_id, $product_style_id, $value));
     db("open_write")->update("activity_product_styles", array("image" => json_encode($value)), array("activity_id" => $activity_id, "product_id" => $product_id, "product_style_id" => $product_style_id));
 }
Ejemplo n.º 7
0
 function notify_callback()
 {
     $alipay_config['partner'] = ALIPAY_PARTNER;
     $alipay_config['key'] = ALIPAY_KEY;
     $alipay_config['sign_type'] = ALIPAY_SIGN_TYPE;
     $alipay_config['input_charset'] = ALIPAY_INPUT_CHARSET;
     $alipay_config['cacert'] = "";
     $alipay_config['transport'] = 'http';
     //计算得出通知验证结果
     $alipayNotify = new AlipayNotify($alipay_config);
     $verify_result = $alipayNotify->verifyNotify();
     if ($verify_result) {
         //验证成功
         $out_trade_no = $_POST['out_trade_no'];
         //支付宝交易号
         $trade_no = $_POST['trade_no'];
         //交易状态
         $trade_status = $_POST['trade_status'];
         if ($_POST['trade_status'] == 'TRADE_FINISHED') {
             //判断该笔订单是否在商户网站中已经做过处理
             //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
             //如果有做过处理,不执行商户的业务程序
             //注意:
             //该种交易状态只在两种情况下出现
             //1、开通了普通即时到账,买家付款成功后。
             //2、开通了高级即时到账,从该笔交易成功时间算起,过了签约时的可退款时限(如:三个月以内可退款、一年以内可退款等)后。
             pt_log("{$out_trade_no}:TRADE_FINISHED");
         } else {
             if ($_POST['trade_status'] == 'TRADE_SUCCESS') {
                 //判断该笔订单是否在商户网站中已经做过处理
                 //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                 //如果有做过处理,不执行商户的业务程序
                 //注意:
                 //该种交易状态只在一种情况下出现——开通了高级即时到账,买家付款成功后。
                 pt_log("{$out_trade_no}:TRADE_SUCCESS");
             }
         }
         return array("order_no" => $out_trade_no, "price" => $_POST['total_fee'], "trade_no" => $trade_no, 'trade_status' => $trade_status);
     } else {
         //验证失败
         //echo "fail";
         pt_log("alipay notify fail");
         return false;
     }
 }