示例#1
0
 public function Queryorder($transaction_id)
 {
     $input = new WxPayOrderQuery();
     $input->SetTransaction_id($transaction_id);
     $result = WxPayApi::orderQuery($input);
     if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") {
         return true;
     }
     return false;
 }
示例#2
0
 public static function sendRedpack($gh_id, $openid, $mobile, $category = self::CATEGORY_SMS)
 {
     //        U::yjhu_w('sendRedpack begins.');
     $log = self::findOne(['gh_id' => $gh_id, 'openid' => $openid, 'mobile' => $mobile, 'category' => $category]);
     if (empty($log)) {
         $log = new self();
         $log->gh_id = $gh_id;
         $log->openid = $openid;
         $log->mobile = $mobile;
         $log->category = $category;
         $log->amount = self::redpackAmount($category);
         if (WxPayApi::sendRedPack($openid, $log->amount, '会员首次关注红包')) {
             $log->sendtime = time();
             $log->save(false);
             //                U::yjhu_w('sendRedpack ends.');
             return true;
         }
     }
     return false;
 }
示例#3
0
 public function actionCash($openid, $amount)
 {
     $result = \app\models\wxpay\WxPayApi::sendCash($openid, $amount, '发展会员奖金');
     var_dump($result);
 }
示例#4
0
 public function NotifyProcess($data, &$msg)
 {
     //Log::DEBUG("call back:" . json_encode($data));
     U::W([__METHOD__, $data, $msg]);
     /*
             $data => Array
             (
             [appid] => wx79c2bf0249ede62a
             [is_subscribe] => Y
             [mch_id] => 1220047701
             [nonce_str] => bfegWC2eAXolkxj8
             [openid] => oSHFKs9_gq4Ve6sHdQ86mJh1U3ZQ
             [product_id] => 123456789
             [sign] => 6D81DBD2229DC244D9E94E6BD24EF5B3
             )
     */
     if (!array_key_exists("openid", $data) || !array_key_exists("product_id", $data)) {
         $msg = "回调数据异常";
         return false;
     }
     $openid = $data["openid"];
     $product_id = $data["product_id"];
     $result = $this->unifiedorder($openid, $product_id);
     if (!array_key_exists("appid", $result) || !array_key_exists("mch_id", $result) || !array_key_exists("prepay_id", $result)) {
         $msg = "统一下单失败";
         return false;
     }
     $this->SetData("appid", $result["appid"]);
     $this->SetData("mch_id", $result["mch_id"]);
     $this->SetData("nonce_str", WxPayApi::getNonceStr());
     $this->SetData("prepay_id", $result["prepay_id"]);
     $this->SetData("result_code", "SUCCESS");
     $this->SetData("err_code_des", "OK");
     return true;
 }