~~~
<?php
/**
* Created by PhpStorm.
* User: Mikkle
* QQ:776329498
* Date: 2018/4/3
* Time: 17:25
*/
namespace app\base\service;
use app\base\base\RedisInfoBase;
use app\base\options\Fields;
use mikkle\tp_wxpay\Wxpay;
use think\Exception;
use think\facade\Build;
use think\facade\Config;
use think\facade\Env;
use think\facade\Log;
class ChannelCenter extends RedisInfoBase
{
protected $table="mk_payment_channel"; //數據表的
protected $pk = "channel_id"; //數據表的主鍵
protected $debugHost = "http://pm.******";
protected $releaseHost = "http://pm.*********";
protected $wxpay;
protected $wxpayUnifiedOrder;
protected $wxpayJsapi;
protected $wxpayNotifyUrl ="/weixin/api.callback/callbackWxPay";
protected $wxpayError;
protected $isDebug=true;
public function _initialize()
{
$this->initLoadTableData();
}
public function initLoadTableData(){
//判斷數據存在 并設置檢查周期10分鐘
if (!$this->checkLock("dataExists") && !$this->checkTableDataExists()){
throw new Exception("相關渠道數據不存在");
}else{
//設置檢查鎖10分鐘
$this->setLock("dataExists",600);
}
//如果數據不存在 初始化讀取數據
if (!$this->checkExists()){
$this->initTableData();
}
}
public function getWxpayOptions($refresh=false){
$refresh && $this->initTableData();
$options = $this->getInfoList([
"wxpay_app_id" ,"wxpay_secret","wxpay_mch_id","wxpay_key","ca_path","wxpay_cert_path","wxpay_cert_key_path","wxpay_callback_url"
]);
return !empty( $options["wxpay_app_id"] ) ?[
"appid"=>$options["wxpay_app_id"],
'secret' => $options["wxpay_secret"],
'mch_id'=>$options["wxpay_mch_id"],
'key'=>$options["wxpay_key"],
'ca_path'=>$options["ca_path"] ? Env::get('root_path').$options["ca_path"] : "",
'cert_path'=>$options["wxpay_cert_path"] ? Env::get('root_path').$options["wxpay_cert_path"] : "",
'key_path'=>$options["wxpay_cert_key_path"] ? Env::get('root_path').$options["wxpay_cert_key_path"] : "",
"callback_url"=>$options["wxpay_callback_url"],
] : [ ] ;
}
protected function getWechatOptions(){
$options = $this->getInfoList([
"wxpay_app_id" ,"wxpay_secret"
]);
return [
'appid'=>$options["wxpay_app_id"],
'appsecret'=>$options["wxpay_secret"],
];
}
/**
* title
* description wxpay
* User: Mikkle
* QQ:776329498
* @return Wxpay
*/
public function wxpay(){
if (isset($this->wxpay )){
return $this->wxpay;
}
$this->wxpay = Wxpay::instance($this->getWxpayOptions());
return $this->wxpay ;
}
public function wxpayUnifiedOrder(){
if (isset($this->wxpayUnifiedOrder)){
return $this->wxpayUnifiedOrder;
}
$this->wxpayUnifiedOrder =$this->wxpay()->unifiedOrder();
return $this->wxpayUnifiedOrder;
}
public function wxpayJsapi(){
if (isset($this->wxpayJsapi)){
return $this->wxpayJsapi;
}
$this->wxpayJsapi =$this->wxpay()->jsApi();
return $this->wxpayJsapi;
}
protected function getWxpayNotifyUrl(){
$url = (Config::get("app_status")=="debug" ? $this->debugHost :$this->releaseHost) . $this->wxpayNotifyUrl;
return $url ."/".Fields::$channelId."/".$this->infoId;
}
public function getWxpayPrepayId($param){
$param["body"]=" ";
$param["notify_url"] = $this->getWxpayNotifyUrl();
$this->isDebug && Log::notice($param);
$prepayId = $this->wxpayUnifiedOrder()->setParam($param )->getPrepayId();
if ($prepayId == false){
$this->isDebug && Log::notice($this->wxpayUnifiedOrder()->getResponse());
$this->wxpayError = $this->wxpayUnifiedOrder()->getResponseMsg() ;
}
return $prepayId;
}
public function getWxpayPayUrl($param,$type="MWEB"){
if ($type =="NATIVE"){
$param["trade_type"] ="NATIVE";
}else{
$param["trade_type"] ="MWEB";
}
$param["body"]=" ";
$param["notify_url"] = $this->getWxpayNotifyUrl();
$this->isDebug && Log::notice($param);
$result = $this->wxpayUnifiedOrder()->setParam($param )->getPayUrl();
if ($result == false){
$this->isDebug && Log::notice($this->wxpayUnifiedOrder()->getResponse());
$this->wxpayError = $this->wxpayUnifiedOrder()->getResponseMsg() ;
}
return $result;
}
public function getWxpayGetJsapiPayParams($param){
$param["trade_type"]="JSAPI" ; /**交易類型 NATIVE MWEB JSAPI*/
$prepayId = $this->getWxpayPrepayId( $param );
if ( $prepayId ==false ){
return false ;
}
$payParams = $this->wxpayJsapi()->getJsPayParamsByPrepayId($prepayId) ;
if ($payParams == false){
$this->wxpayError = $this->wxpayUnifiedOrder()->getResponseMsg() ;
}
return $payParams;
}
public function getWxpayError(){
return $this->wxpayError;
}
public function getRsaPublicCert(){
return $this->getInfoFieldValue("wxpay_ras_public_key");
}
protected function refreshWxpayRsaPublicCert(){
$cert = $this->wxpay()->RsaPublicKey()->getRsaPublicKey();
if ($cert){
$this->setInfoFieldValue("wxpay_ras_public_key_",$cert);
$this->updateTableData(["wxpay_ras_public_key_pkcs#1"]);
}
return $this->getInfoFieldValue( "wxpay_ras_public_key_pkcs#1" );
}
}
~~~
~~~
<?php
/**
* Created by PhpStorm.
* User: Mikkle
* QQ:776329498
* Date: 2018/5/25
* Time: 9:07
*/
namespace app\base\service;
use app\base\options\Fields;
use app\base\options\Functions;
use app\base\options\Rands;
use app\base\options\Tables;
use think\Db;
use think\Exception;
use think\facade\Hook;
use think\facade\Log;
class BalanceCenter
{
static protected $instance;
protected $vendorId;
protected $vendorCenter;
protected $error;
public static function instance($info_id)
{
$sn = md5(json_encode($info_id));
if (self::$instance[$sn]){
return self::$instance[$sn];
}
return new static($info_id);
}
public function __construct($vendorId = "")
{
if (!empty($vendorId)) {
$this->setVendorId($vendorId);
}
}
public function setVendorId($vendorId="")
{
if (!empty($vendorId) && is_numeric( $vendorId ) && $this->checkVendorId( $vendorId ) ) {
$this->vendorId = $vendorId ;
}
return $this;
}
protected function checkVendorId($infoId)
{
return AuthCenter::authVendorId($infoId);
}
public function wxPayToUser($data){
if ( ! $this->vendorId ){
$this->error = "未設置商戶ID或設置信息錯誤" ;
return false;
}
if ( !isset( $data[Fields::$vendorId]) || ! $this->checkVendorId($data[Fields::$vendorId]) ){
$this->error = "未設置轉入商戶ID或設置信息錯誤" ;
return false;
}
if ( !isset( $data[Fields::$systemId]) || !AuthCenter::authVendorIdAttachSystem ($data[Fields::$vendorId] , $data[Fields::$systemId]) ){
$this->error = "SystemId 不存在" ;
return false;
}
if ( !isset( $data[Fields::$amount]) || empty($data[Fields::$amount]) ){
$this->error = "余額 不存在" ;
return false;
}
if ( !isset( $data[Fields::$openid]) || empty($data[Fields::$vendorId]) ){
$this->error = "OPENID 不存在" ;
return false;
}
$channelId = DataCenter::getWxpayChannelIdBySystemId( $data[Fields::$systemId] );
$withdrawNum = Rands::createWithdrawSerialNumber();
$vendorInfo = DataCenter::getVendorInfoByVendorId($data[Fields::$vendorId]);
if ($data[Fields::$amount] >$vendorInfo[Fields::$vendorAmount] ){
$this->error = "商戶的余款不足" ;
return false;
}
if ($data[Fields::$amount] >1000 ){
$this->error = "Debug測試提現金額不能大于 10元" ;
return false;
}
$time = time();
$withdrawData =[
Fields::$withdrawNum => $withdrawNum,
Fields::$withdrawType => 1,
Fields::$systemId =>$data[Fields::$systemId],
Fields::$vendorId =>$data[Fields::$vendorId],
"wx_".Fields::$openid =>$data[Fields::$openid],
Fields::$amount =>$data[Fields::$amount],
Fields::$withdrawTime =>Rands::getTimeString($time),
Fields::$status=>0,
Fields::$createTime => $time,
];
$channelCenter = ChannelCenter::instance($channelId);
$payCenter = $channelCenter->wxpay()->Transfers();
$result = $payCenter->setParam([
"partner_trade_no"=>$withdrawData[Fields::$withdrawNum],
"openid"=>$withdrawData["wx_".Fields::$openid],
"check_name"=>"NO_CHECK",
"amount"=>$withdrawData[Fields::$amount],
"desc"=>"測試"
])->payToUser();
if (! $result || !is_array($result ) || ! isset( $result["result_code"]) || $result["result_code"] != "SUCCESS" ){
Db::table(Tables::$paymentSystemVendorWithdraw ) ->insert( $withdrawData);
$this->error = "提交提現記錄失敗" ;
return false;
}
if (! isset( $result["payment_no"]) || ! isset( $result["payment_time"] )){
Log::notice($result);
Db::table(Tables::$paymentSystemVendorWithdraw ) ->insert( $withdrawData);
$this->error = "提交提現記錄解析返回數據出錯" ;
return false;
}
$withdrawData["payment_no"] =$result["payment_no"];
$withdrawData["payment_time"] =$result["payment_time"];
$withdrawData[Fields::$status] =1;
if (! Db::table(Tables::$paymentSystemVendorWithdraw ) ->insert( $withdrawData)){
Log::notice($withdrawData);
$this->error = "存儲提現信息失敗" ;
Hook::listen("payment_error",$withdrawData);
return false;
}
if ($this->completeWxPayToUser( $withdrawData )){
return true;
}else{
$this->error = "存儲提現信息失敗" ;
Hook::listen("payment_error",$withdrawData);
return false;
}
}
public function completeWxPayToUser($data){
//獲取當前的收費員的帳號余額和版本號
$vendorAmount = Db::table(Tables::$paymentSystemVendor)
->where([Fields::$vendorId =>$data[Fields::$vendorId],Fields::$status=>1])
->field([Fields::$vendorId,Fields::$vendorAmount,Fields::$vendorAmountVersion])->find();
if (!is_numeric($vendorAmount[Fields::$vendorAmount]) || !is_numeric($vendorAmount[Fields::$vendorAmountVersion]) ){
throw new Exception("商戶的余款數據不正確");
}
$amount = (int)$vendorAmount[Fields::$vendorAmount];
$newAmount = $amount - (int)$data[Fields::$amount];
$version = (int)$vendorAmount[Fields::$vendorAmountVersion];
//收費員賬戶流水表信息
$vendorIncomeDate = [
Fields::$incomeNum=>Rands::createIncomeSerialNumber(),
Fields::$systemId=>$data[Fields::$systemId],
Fields::$vendorId=>$data[Fields::$vendorId],
Fields::$incomeType=>2, //流水類型 1 清算 2 提現 3 轉入 4轉出 5 沖正
Fields::$incomeMode=>2 , //流水模式 1 進賬 2 出賬
Fields::$money =>$data[Fields::$amount] ,
Fields::$vendorAmount =>$newAmount,
Fields::$originalVendorAmount =>$amount,
Fields::$vendorAmountVersion => $version+1,
Fields::$withdrawNum=>$data[Fields::$withdrawNum],
Fields::$desc=>"提現清算:{$data[Fields::$withdrawNum]} 轉入",
Fields::$status=>1,
Fields::$incomeTime=>$data[Fields::$withdrawTime],
Fields::$createTime=>$data[Fields::$createTime],
];
try{
//多表處理 開啟事務
Db::startTrans();
//升級收費員余額 加入了樂觀鎖判斷
if (!Db::table(Tables::$paymentSystemVendor)
->where([Fields::$vendorId=>$data[Fields::$vendorId],Fields::$vendorAmountVersion =>$version ])
->update([Fields::$vendorAmount=>$newAmount,Fields::$vendorAmountVersion=>$version+1])
){
throw new Exception("商戶的余額信息已經變動,請重試");
}
//插入商戶金額流水信息
if (!Db::table(Tables::$paymentSystemIncome)->insert($vendorIncomeDate)){
throw new Exception("插入商戶金額流水信息失敗");
}
Db::commit();
return true;
}catch (Exception $e){
$this->error = $e->getMessage();
Log::error($e->getMessage());
Db::rollback();
return false;
}
}
public function vendorTransfer($inVendorId,$mount){
if ( ! $this->vendorId ){
$this->error = "未設置商戶ID或設置信息錯誤" ;
return false;
}
if ( ! $this->checkVendorId($inVendorId) ){
$this->error = "未設置轉入商戶ID或設置信息錯誤" ;
return false;
}
$transferData =[
"out_vendor"=>$this->vendorId,
"in_vendor"=>$inVendorId,
"amount"=>$mount
];
if ($this->completeTransfer( $transferData )){
return true;
}else{
return false;
}
}
protected function completeTransfer($data){
//獲取當前的收費員的帳號余額和版本號
$vendorOut = Db::table(Tables::$paymentSystemVendor)
->where([Fields::$vendorId =>$data["out_vendor"],Fields::$status=>1])
->field([Fields::$systemId,Fields::$vendorId,Fields::$vendorName,Fields::$vendorAmount,Fields::$vendorAmountVersion])->find();
if (!is_numeric($vendorOut[Fields::$vendorAmount]) || !is_numeric($vendorOut[Fields::$vendorAmountVersion]) ){
throw new Exception("商戶的余款數據不正確");
}
if ($data["amount"] >$vendorOut[Fields::$vendorAmount] ){
throw new Exception("商戶的余款不足");
}
$vendorIn = Db::table(Tables::$paymentSystemVendor)
->where([Fields::$vendorId =>$data["in_vendor"],Fields::$status=>1])
->field([Fields::$systemId,Fields::$vendorId,Fields::$vendorName,Fields::$vendorAmount,Fields::$vendorAmountVersion])->find();
if ($vendorOut[Fields::$systemId] !=$vendorIn[Fields::$systemId] ){
throw new Exception("不容許跨平臺間的商戶轉賬");
}
$amountOut = (int)$vendorOut[Fields::$vendorAmount];
$newAmountOut =$amountOut - (int)$data["amount"] ;
$versionOut = (int)$vendorOut[Fields::$vendorAmountVersion];
$amountIn= (int)$vendorIn[Fields::$vendorAmount];
$newAmountIn =$amountIn + (int)$data["amount"] ;
$versionIn= (int)$vendorIn[Fields::$vendorAmountVersion];
$time =time();
$transferNum = Rands::createTransferSerialNumber();
$transferData = [
"transfer_num" => $transferNum,
"system_id"=>$vendorOut[Fields::$systemId],
"out_vendor_id"=>$data["out_vendor"],
"out_vendor_name"=>$vendorOut[Fields::$vendorName],
"in_vendor_id"=>$data["in_vendor"],
"in_vendor_name"=>$vendorIn[Fields::$vendorName],
"amount"=>$data["amount"],
"transfer_time"=>Rands::getDateString( $time ),
"status"=>1,
"create_time"=>$time,
];
//商戶出賬流水表信息
$vendorIncomeDateOut = [
Fields::$incomeNum=>Rands::createIncomeSerialNumber(),
Fields::$systemId=>$vendorOut[Fields::$systemId],
Fields::$vendorId=>$vendorOut[Fields::$vendorId],
Fields::$incomeType=>4, //流水類型 1 清算 2 提現 3 轉入 4轉出 5 沖正
Fields::$incomeMode=>2 , //流水模式 1 進賬 2 出賬
Fields::$money =>$data["amount"],
Fields::$vendorAmount =>$newAmountOut,
Fields::$originalVendorAmount =>$amountOut,
Fields::$vendorAmountVersion => $versionOut+1,
Fields::$transferNum=>$transferNum,
Fields::$desc=>"商戶內轉賬:{$data[Fields::$balanceNum]} 的轉出付款",
Fields::$status=>1,
Fields::$incomeTime=>Rands::getDateString( $time ),
Fields::$createTime=>$time,
];
//商戶入賬賬戶流水表信息
$vendorIncomeDateIn = [
Fields::$incomeNum=>Rands::createIncomeSerialNumber(),
Fields::$systemId=>$vendorIn[Fields::$systemId],
Fields::$vendorId=>$vendorIn[Fields::$vendorId],
Fields::$incomeType=>3, //流水類型 1 清算 2 提現 3 轉入 4轉出 5 沖正
Fields::$incomeMode=>1 , //流水模式 1 進賬 2 出賬
Fields::$money =>$data["amount"],
Fields::$vendorAmount =>$newAmountIn,
Fields::$originalVendorAmount =>$amountIn,
Fields::$vendorAmountVersion => $versionIn+1,
Fields::$transferNum=>$transferNum,
Fields::$desc=>"商戶內轉賬:{$data[Fields::$balanceNum]} 的轉入付款",
Fields::$status=>1,
Fields::$incomeTime=>Rands::getDateString( $time ),
Fields::$createTime=>$time,
];
try{
//多表處理 開啟事務
Db::startTrans();
//升級商戶余額 加入了樂觀鎖判斷 出賬
if (!Db::table(Tables::$paymentSystemVendor)
->where([Fields::$vendorId=>$vendorOut[Fields::$vendorId],Fields::$vendorAmountVersion =>$versionOut ])
->update([Fields::$vendorAmount=>$newAmountOut,Fields::$vendorAmountVersion=>$versionOut+1])
){
throw new Exception("出賬商戶的余額信息已經變動,請重試");
}
//升級商戶余額 加入了樂觀鎖判斷 入賬
if (!Db::table(Tables::$paymentSystemVendor)
->where([Fields::$vendorId=>$vendorIn[Fields::$vendorId],Fields::$vendorAmountVersion =>$versionIn ])
->update([Fields::$vendorAmount=>$newAmountIn,Fields::$vendorAmountVersion=>$versionIn+1])
){
throw new Exception("入賬商戶的余額信息已經變動,請重試");
}
//插入結算流水信息
if (!Db::table(Tables::$paymentSystemVendorTransfer)->insert($transferData)){
throw new Exception("插入結算流水信息失敗");
}
//插入商戶金額流水信息
if (!Db::table(Tables::$paymentSystemIncome)->insert($vendorIncomeDateOut)){
throw new Exception("插入商戶出賬金額流水信息失敗");
}
//插入商戶金額流水信息
if (!Db::table(Tables::$paymentSystemIncome)->insert($vendorIncomeDateIn)){
throw new Exception("插入商戶入賬金額流水信息失敗");
}
Db::commit();
return true;
}catch (Exception $e){
$this->error = $e->getMessage();
Log::error($e->getMessage());
Db::rollback();
return false;
}
}
public function balancePay($payNum){
if ( ! $this->vendorId ){
$this->error = "未設置商戶ID或設置信息錯誤" ;
return false;
}
$payInfo = DataCenter::getPayInfoByPayNum($payNum);
if ( empty( $payInfo ) || $payInfo[Fields::$status]>1){
$this->error = "付款信息不存在或者已經結算" ;
return false;
}
$this->vendorCenter =VendorCenter::instance( $this->vendorId );
$balanceRate = $this->vendorCenter->getInfoFieldValue("balance_rate");
if ( !Functions::checkBalanceRate( $balanceRate )){
$this->error = "結算手續費不合法" ;
return false;
}
$balanceNum = Rands::createBalanceSerialNumber();
//手續費 四舍五入 取整分
$balanceCharge = round ($payInfo[Fields::$payMoney] * $balanceRate );
$time =time() ;
$balanceData = [
Fields::$balanceNum => $balanceNum,
Fields::$systemId => $payInfo[Fields::$systemId],
Fields::$vendorId => $payInfo[Fields::$vendorId],
Fields::$channelId => $payInfo[Fields::$channelId],
Fields::$wxBillNum => $payInfo[Fields::$wxBillNum],
Fields::$billNum => $payInfo[Fields::$billNum],
Fields::$payNum => $payInfo[Fields::$payNum],
Fields::$payMoney => $payInfo[Fields::$payMoney],
Fields::$balanceRate =>$balanceRate,
Fields::$balanceCharge => $balanceCharge,
Fields::$balanceMoney=> $payInfo[Fields::$payMoney] - $balanceCharge,
Fields::$status=>1,
Fields::$balanceTime => Rands::getTimeString( $time),
Fields::$createTime => $time,
];
if ($this->completeBalance( $balanceData )){
return true;
}else{
return false;
}
}
protected function completeBalance($data){
//獲取當前的收費員的帳號余額和版本號
$vendorAmount = Db::table(Tables::$paymentSystemVendor)
->where([Fields::$vendorId =>$data[Fields::$vendorId],Fields::$status=>1])
->field([Fields::$vendorId,Fields::$vendorAmount,Fields::$vendorAmountVersion])->find();
if (!is_numeric($vendorAmount[Fields::$vendorAmount]) || !is_numeric($vendorAmount[Fields::$vendorAmountVersion]) ){
throw new Exception("商戶的余款數據不正確");
}
$amount = (int)$vendorAmount[Fields::$vendorAmount];
$newAmount = $amount + (int)$data[Fields::$balanceMoney];
$version = (int)$vendorAmount[Fields::$vendorAmountVersion];
//收費員賬戶流水表信息
$vendorIncomeDate = [
Fields::$incomeNum=>Rands::createIncomeSerialNumber(),
Fields::$systemId=>$data[Fields::$systemId],
Fields::$vendorId=>$data[Fields::$vendorId],
Fields::$incomeType=>1, //流水類型 1 清算 2 提現 3 轉入 4轉出 5 沖正
Fields::$incomeMode=>1 , //流水模式 1 進賬 2 出賬
Fields::$money =>$data[Fields::$balanceMoney] ,
Fields::$vendorAmount =>$newAmount,
Fields::$originalVendorAmount =>$amount,
Fields::$vendorAmountVersion => $version+1,
Fields::$balanceNum=>$data[Fields::$balanceNum],
Fields::$desc=>"付款清算:{$data[Fields::$balanceNum]} 轉入",
Fields::$status=>1,
Fields::$incomeTime=>$data[Fields::$balanceTime],
Fields::$createTime=>$data[Fields::$createTime],
];
try{
//多表處理 開啟事務
Db::startTrans();
//升級收費員余額 加入了樂觀鎖判斷
if (!Db::table(Tables::$paymentSystemVendor)
->where([Fields::$vendorId=>$data[Fields::$vendorId],Fields::$vendorAmountVersion =>$version ])
->update([Fields::$vendorAmount=>$newAmount,Fields::$vendorAmountVersion=>$version+1])
){
throw new Exception("商戶的余額信息已經變動,請重試");
}
//升級付款表為已經結算狀態
if (!Db::table(Tables::$paymentPay)->where([
Fields::$payNum=>$data[Fields::$payNum],Fields::$status=>1,
])->update([Fields::$status=>2,Fields::$balanceTime=>$data[Fields::$createTime]])){
throw new Exception("升級付款表失敗");
}
//插入結算流水信息
if (!Db::table(Tables::$paymentPayBalance)->insert($data)){
throw new Exception("插入結算流水信息失敗");
}
//插入商戶金額流水信息
if (!Db::table(Tables::$paymentSystemIncome)->insert($vendorIncomeDate)){
throw new Exception("插入商戶金額流水信息失敗");
}
Db::commit();
return true;
}catch (Exception $e){
$this->error = $e->getMessage();
Log::error($e->getMessage());
Db::rollback();
return false;
}
}
public function getError(){
return $this->error;
}
}
~~~
~~~
<?php
/**
* Created by PhpStorm.
* User: Mikkle
* QQ:776329498
* Date: 2018/5/18
* Time: 9:49
*/
namespace app\base\service;
use app\base\base\RedisInfoBase;
use app\base\options\Fields;
use app\base\options\Rands;
use app\base\options\Tables;
use app\worker\push\PushPayMessageHandle;
use think\Db;
use think\Exception;
use think\facade\Hook;
use think\facade\Log;
class BillCenter extends RedisInfoBase
{
protected $table="mk_payment_bill"; //數據表的
protected $pk = "out_trade_no"; //數據表的主鍵
public function completeBillByWxPayCallback($data){
if (Db::table(Tables::$paymentPay)->where([Fields::$wxBillNum=>$this->infoId])->count()>0){
$this->addError("已經處理過本條付款信息");
return false ;
}
$payNum= Rands::createPaySerialNumber();
$billInfo =$this->getInfoList( [
Fields::$systemId,Fields::$channelId,Fields::$channelType,Fields::$billNum,Fields::$notifyUrl,Fields::$vendorId
]);
$time = time();
$payData =[
Fields::$payNum =>$payNum,
Fields::$systemId => $billInfo[Fields::$systemId],
Fields::$vendorId=>$billInfo[Fields::$vendorId],
Fields::$wxBillNum=>$this->infoId,
Fields::$billNum=>$billInfo[Fields::$billNum],
Fields::$channelId => $billInfo[Fields::$channelId],
Fields::$channelType => $billInfo[Fields::$channelType],
Fields::$tradeType=>$data[Fields::$tradeType],
Fields::$payMoney => $data[Fields::$payMoney],
Fields::$payTime=>$data["time_end"],
Fields::$status=>1,
Fields::$createTime => $time,
];
$billData =[
Fields::$status=>2,
Fields::$payMoney => $data[Fields::$payMoney],
Fields::$payTime=>$data["time_end"],
Fields::$payStatus=>2,
Fields::$status=>2,
Fields::$completeTime => $time,
];
if ($this->saveCompleteBillData($payData,$billData)){
//更新流水信息
$this->setInfoArray($billData);
$this->setExpire(3600*24*7);
$this->pushPayMessage($billInfo[Fields::$notifyUrl],$payData);
$hookData = [Fields::$payNum =>$payNum,Fields::$vendorId=>$billInfo[Fields::$vendorId]];
Hook::listen(Fields::$hookCompletePay, $hookData);
//更新帳號余額
return true;
}else{
return false;
}
}
protected function saveCompleteBillData($payData,$billData){
try{
//多表處理 開啟事務
Db::startTrans();
//插入付款流水信息
if (!Db::table(Tables::$paymentPay)->insert($payData)){
throw new Exception("插入付款流水信息失敗");
}
$map = [
[Fields::$wxBillNum, "=", $this->infoId],
[Fields::$status, "<>", 2]
];
if (!Db::table(Tables::$paymentBill)->where($map)->update($billData)){
Log::notice($map);
Log::notice($billData);
throw new Exception("完成賬單信息失敗");
}
Db::commit();
return true;
}catch (Exception $e){
Db::rollback();
Log::error($e->getMessage());
return false;
}
}
public function pushPayMessage($url,$pushData){
unset($pushData[Fields::$createTime]);
unset($pushData[Fields::$status]);
unset($pushData[Fields::$wxBillNum]);
$data =[
"url"=>$url,
"result"=>$pushData,
];
return PushPayMessageHandle::add( $data );
}
}
~~~
~~~
<?php
/**
* Created by PhpStorm.
* User: Mikkle
* QQ:776329498
* Date: 2018/5/25
* Time: 9:07
*/
namespace app\base\service;
use app\base\options\Fields;
use app\base\options\Functions;
use app\base\options\Rands;
use app\base\options\Tables;
use think\Db;
use think\Exception;
use think\facade\Hook;
use think\facade\Log;
class BalanceCenter
{
static protected $instance;
protected $vendorId;
protected $vendorCenter;
protected $error;
public static function instance($info_id)
{
$sn = md5(json_encode($info_id));
if (self::$instance[$sn]){
return self::$instance[$sn];
}
return new static($info_id);
}
public function __construct($vendorId = "")
{
if (!empty($vendorId)) {
$this->setVendorId($vendorId);
}
}
public function setVendorId($vendorId="")
{
if (!empty($vendorId) && is_numeric( $vendorId ) && $this->checkVendorId( $vendorId ) ) {
$this->vendorId = $vendorId ;
}
return $this;
}
protected function checkVendorId($infoId)
{
return AuthCenter::authVendorId($infoId);
}
public function wxPayToUser($data){
if ( ! $this->vendorId ){
$this->error = "未設置商戶ID或設置信息錯誤" ;
return false;
}
if ( !isset( $data[Fields::$vendorId]) || ! $this->checkVendorId($data[Fields::$vendorId]) ){
$this->error = "未設置轉入商戶ID或設置信息錯誤" ;
return false;
}
if ( !isset( $data[Fields::$systemId]) || !AuthCenter::authVendorIdAttachSystem ($data[Fields::$vendorId] , $data[Fields::$systemId]) ){
$this->error = "SystemId 不存在" ;
return false;
}
if ( !isset( $data[Fields::$amount]) || empty($data[Fields::$amount]) ){
$this->error = "余額 不存在" ;
return false;
}
if ( !isset( $data[Fields::$openid]) || empty($data[Fields::$vendorId]) ){
$this->error = "OPENID 不存在" ;
return false;
}
$channelId = DataCenter::getWxpayChannelIdBySystemId( $data[Fields::$systemId] );
$withdrawNum = Rands::createWithdrawSerialNumber();
$vendorInfo = DataCenter::getVendorInfoByVendorId($data[Fields::$vendorId]);
if ($data[Fields::$amount] >$vendorInfo[Fields::$vendorAmount] ){
$this->error = "商戶的余款不足" ;
return false;
}
if ($data[Fields::$amount] >1000 ){
$this->error = "Debug測試提現金額不能大于 10元" ;
return false;
}
$time = time();
$withdrawData =[
Fields::$withdrawNum => $withdrawNum,
Fields::$withdrawType => 1,
Fields::$systemId =>$data[Fields::$systemId],
Fields::$vendorId =>$data[Fields::$vendorId],
"wx_".Fields::$openid =>$data[Fields::$openid],
Fields::$amount =>$data[Fields::$amount],
Fields::$withdrawTime =>Rands::getTimeString($time),
Fields::$status=>0,
Fields::$createTime => $time,
];
$channelCenter = ChannelCenter::instance($channelId);
$payCenter = $channelCenter->wxpay()->Transfers();
$result = $payCenter->setParam([
"partner_trade_no"=>$withdrawData[Fields::$withdrawNum],
"openid"=>$withdrawData["wx_".Fields::$openid],
"check_name"=>"NO_CHECK",
"amount"=>$withdrawData[Fields::$amount],
"desc"=>"測試"
])->payToUser();
if (! $result || !is_array($result ) || ! isset( $result["result_code"]) || $result["result_code"] != "SUCCESS" ){
Db::table(Tables::$paymentSystemVendorWithdraw ) ->insert( $withdrawData);
$this->error = "提交提現記錄失敗" ;
return false;
}
if (! isset( $result["payment_no"]) || ! isset( $result["payment_time"] )){
Log::notice($result);
Db::table(Tables::$paymentSystemVendorWithdraw ) ->insert( $withdrawData);
$this->error = "提交提現記錄解析返回數據出錯" ;
return false;
}
$withdrawData["payment_no"] =$result["payment_no"];
$withdrawData["payment_time"] =$result["payment_time"];
$withdrawData[Fields::$status] =1;
if (! Db::table(Tables::$paymentSystemVendorWithdraw ) ->insert( $withdrawData)){
Log::notice($withdrawData);
$this->error = "存儲提現信息失敗" ;
Hook::listen("payment_error",$withdrawData);
return false;
}
if ($this->completeWxPayToUser( $withdrawData )){
return true;
}else{
$this->error = "存儲提現信息失敗" ;
Hook::listen("payment_error",$withdrawData);
return false;
}
}
public function completeWxPayToUser($data){
//獲取當前的收費員的帳號余額和版本號
$vendorAmount = Db::table(Tables::$paymentSystemVendor)
->where([Fields::$vendorId =>$data[Fields::$vendorId],Fields::$status=>1])
->field([Fields::$vendorId,Fields::$vendorAmount,Fields::$vendorAmountVersion])->find();
if (!is_numeric($vendorAmount[Fields::$vendorAmount]) || !is_numeric($vendorAmount[Fields::$vendorAmountVersion]) ){
throw new Exception("商戶的余款數據不正確");
}
$amount = (int)$vendorAmount[Fields::$vendorAmount];
$newAmount = $amount - (int)$data[Fields::$amount];
$version = (int)$vendorAmount[Fields::$vendorAmountVersion];
//收費員賬戶流水表信息
$vendorIncomeDate = [
Fields::$incomeNum=>Rands::createIncomeSerialNumber(),
Fields::$systemId=>$data[Fields::$systemId],
Fields::$vendorId=>$data[Fields::$vendorId],
Fields::$incomeType=>2, //流水類型 1 清算 2 提現 3 轉入 4轉出 5 沖正
Fields::$incomeMode=>2 , //流水模式 1 進賬 2 出賬
Fields::$money =>$data[Fields::$amount] ,
Fields::$vendorAmount =>$newAmount,
Fields::$originalVendorAmount =>$amount,
Fields::$vendorAmountVersion => $version+1,
Fields::$withdrawNum=>$data[Fields::$withdrawNum],
Fields::$desc=>"提現清算:{$data[Fields::$withdrawNum]} 轉入",
Fields::$status=>1,
Fields::$incomeTime=>$data[Fields::$withdrawTime],
Fields::$createTime=>$data[Fields::$createTime],
];
try{
//多表處理 開啟事務
Db::startTrans();
//升級收費員余額 加入了樂觀鎖判斷
if (!Db::table(Tables::$paymentSystemVendor)
->where([Fields::$vendorId=>$data[Fields::$vendorId],Fields::$vendorAmountVersion =>$version ])
->update([Fields::$vendorAmount=>$newAmount,Fields::$vendorAmountVersion=>$version+1])
){
throw new Exception("商戶的余額信息已經變動,請重試");
}
//插入商戶金額流水信息
if (!Db::table(Tables::$paymentSystemIncome)->insert($vendorIncomeDate)){
throw new Exception("插入商戶金額流水信息失敗");
}
Db::commit();
return true;
}catch (Exception $e){
$this->error = $e->getMessage();
Log::error($e->getMessage());
Db::rollback();
return false;
}
}
public function vendorTransfer($inVendorId,$mount){
if ( ! $this->vendorId ){
$this->error = "未設置商戶ID或設置信息錯誤" ;
return false;
}
if ( ! $this->checkVendorId($inVendorId) ){
$this->error = "未設置轉入商戶ID或設置信息錯誤" ;
return false;
}
$transferData =[
"out_vendor"=>$this->vendorId,
"in_vendor"=>$inVendorId,
"amount"=>$mount
];
if ($this->completeTransfer( $transferData )){
return true;
}else{
return false;
}
}
protected function completeTransfer($data){
//獲取當前的收費員的帳號余額和版本號
$vendorOut = Db::table(Tables::$paymentSystemVendor)
->where([Fields::$vendorId =>$data["out_vendor"],Fields::$status=>1])
->field([Fields::$systemId,Fields::$vendorId,Fields::$vendorName,Fields::$vendorAmount,Fields::$vendorAmountVersion])->find();
if (!is_numeric($vendorOut[Fields::$vendorAmount]) || !is_numeric($vendorOut[Fields::$vendorAmountVersion]) ){
throw new Exception("商戶的余款數據不正確");
}
if ($data["amount"] >$vendorOut[Fields::$vendorAmount] ){
throw new Exception("商戶的余款不足");
}
$vendorIn = Db::table(Tables::$paymentSystemVendor)
->where([Fields::$vendorId =>$data["in_vendor"],Fields::$status=>1])
->field([Fields::$systemId,Fields::$vendorId,Fields::$vendorName,Fields::$vendorAmount,Fields::$vendorAmountVersion])->find();
if ($vendorOut[Fields::$systemId] !=$vendorIn[Fields::$systemId] ){
throw new Exception("不容許跨平臺間的商戶轉賬");
}
$amountOut = (int)$vendorOut[Fields::$vendorAmount];
$newAmountOut =$amountOut - (int)$data["amount"] ;
$versionOut = (int)$vendorOut[Fields::$vendorAmountVersion];
$amountIn= (int)$vendorIn[Fields::$vendorAmount];
$newAmountIn =$amountIn + (int)$data["amount"] ;
$versionIn= (int)$vendorIn[Fields::$vendorAmountVersion];
$time =time();
$transferNum = Rands::createTransferSerialNumber();
$transferData = [
"transfer_num" => $transferNum,
"system_id"=>$vendorOut[Fields::$systemId],
"out_vendor_id"=>$data["out_vendor"],
"out_vendor_name"=>$vendorOut[Fields::$vendorName],
"in_vendor_id"=>$data["in_vendor"],
"in_vendor_name"=>$vendorIn[Fields::$vendorName],
"amount"=>$data["amount"],
"transfer_time"=>Rands::getDateString( $time ),
"status"=>1,
"create_time"=>$time,
];
//商戶出賬流水表信息
$vendorIncomeDateOut = [
Fields::$incomeNum=>Rands::createIncomeSerialNumber(),
Fields::$systemId=>$vendorOut[Fields::$systemId],
Fields::$vendorId=>$vendorOut[Fields::$vendorId],
Fields::$incomeType=>4, //流水類型 1 清算 2 提現 3 轉入 4轉出 5 沖正
Fields::$incomeMode=>2 , //流水模式 1 進賬 2 出賬
Fields::$money =>$data["amount"],
Fields::$vendorAmount =>$newAmountOut,
Fields::$originalVendorAmount =>$amountOut,
Fields::$vendorAmountVersion => $versionOut+1,
Fields::$transferNum=>$transferNum,
Fields::$desc=>"商戶內轉賬:{$data[Fields::$balanceNum]} 的轉出付款",
Fields::$status=>1,
Fields::$incomeTime=>Rands::getDateString( $time ),
Fields::$createTime=>$time,
];
//商戶入賬賬戶流水表信息
$vendorIncomeDateIn = [
Fields::$incomeNum=>Rands::createIncomeSerialNumber(),
Fields::$systemId=>$vendorIn[Fields::$systemId],
Fields::$vendorId=>$vendorIn[Fields::$vendorId],
Fields::$incomeType=>3, //流水類型 1 清算 2 提現 3 轉入 4轉出 5 沖正
Fields::$incomeMode=>1 , //流水模式 1 進賬 2 出賬
Fields::$money =>$data["amount"],
Fields::$vendorAmount =>$newAmountIn,
Fields::$originalVendorAmount =>$amountIn,
Fields::$vendorAmountVersion => $versionIn+1,
Fields::$transferNum=>$transferNum,
Fields::$desc=>"商戶內轉賬:{$data[Fields::$balanceNum]} 的轉入付款",
Fields::$status=>1,
Fields::$incomeTime=>Rands::getDateString( $time ),
Fields::$createTime=>$time,
];
try{
//多表處理 開啟事務
Db::startTrans();
//升級商戶余額 加入了樂觀鎖判斷 出賬
if (!Db::table(Tables::$paymentSystemVendor)
->where([Fields::$vendorId=>$vendorOut[Fields::$vendorId],Fields::$vendorAmountVersion =>$versionOut ])
->update([Fields::$vendorAmount=>$newAmountOut,Fields::$vendorAmountVersion=>$versionOut+1])
){
throw new Exception("出賬商戶的余額信息已經變動,請重試");
}
//升級商戶余額 加入了樂觀鎖判斷 入賬
if (!Db::table(Tables::$paymentSystemVendor)
->where([Fields::$vendorId=>$vendorIn[Fields::$vendorId],Fields::$vendorAmountVersion =>$versionIn ])
->update([Fields::$vendorAmount=>$newAmountIn,Fields::$vendorAmountVersion=>$versionIn+1])
){
throw new Exception("入賬商戶的余額信息已經變動,請重試");
}
//插入結算流水信息
if (!Db::table(Tables::$paymentSystemVendorTransfer)->insert($transferData)){
throw new Exception("插入結算流水信息失敗");
}
//插入商戶金額流水信息
if (!Db::table(Tables::$paymentSystemIncome)->insert($vendorIncomeDateOut)){
throw new Exception("插入商戶出賬金額流水信息失敗");
}
//插入商戶金額流水信息
if (!Db::table(Tables::$paymentSystemIncome)->insert($vendorIncomeDateIn)){
throw new Exception("插入商戶入賬金額流水信息失敗");
}
Db::commit();
return true;
}catch (Exception $e){
$this->error = $e->getMessage();
Log::error($e->getMessage());
Db::rollback();
return false;
}
}
public function balancePay($payNum){
if ( ! $this->vendorId ){
$this->error = "未設置商戶ID或設置信息錯誤" ;
return false;
}
$payInfo = DataCenter::getPayInfoByPayNum($payNum);
if ( empty( $payInfo ) || $payInfo[Fields::$status]>1){
$this->error = "付款信息不存在或者已經結算" ;
return false;
}
$this->vendorCenter =VendorCenter::instance( $this->vendorId );
$balanceRate = $this->vendorCenter->getInfoFieldValue("balance_rate");
if ( !Functions::checkBalanceRate( $balanceRate )){
$this->error = "結算手續費不合法" ;
return false;
}
$balanceNum = Rands::createBalanceSerialNumber();
//手續費 四舍五入 取整分
$balanceCharge = round ($payInfo[Fields::$payMoney] * $balanceRate );
$time =time() ;
$balanceData = [
Fields::$balanceNum => $balanceNum,
Fields::$systemId => $payInfo[Fields::$systemId],
Fields::$vendorId => $payInfo[Fields::$vendorId],
Fields::$channelId => $payInfo[Fields::$channelId],
Fields::$wxBillNum => $payInfo[Fields::$wxBillNum],
Fields::$billNum => $payInfo[Fields::$billNum],
Fields::$payNum => $payInfo[Fields::$payNum],
Fields::$payMoney => $payInfo[Fields::$payMoney],
Fields::$balanceRate =>$balanceRate,
Fields::$balanceCharge => $balanceCharge,
Fields::$balanceMoney=> $payInfo[Fields::$payMoney] - $balanceCharge,
Fields::$status=>1,
Fields::$balanceTime => Rands::getTimeString( $time),
Fields::$createTime => $time,
];
if ($this->completeBalance( $balanceData )){
return true;
}else{
return false;
}
}
protected function completeBalance($data){
//獲取當前的收費員的帳號余額和版本號
$vendorAmount = Db::table(Tables::$paymentSystemVendor)
->where([Fields::$vendorId =>$data[Fields::$vendorId],Fields::$status=>1])
->field([Fields::$vendorId,Fields::$vendorAmount,Fields::$vendorAmountVersion])->find();
if (!is_numeric($vendorAmount[Fields::$vendorAmount]) || !is_numeric($vendorAmount[Fields::$vendorAmountVersion]) ){
throw new Exception("商戶的余款數據不正確");
}
$amount = (int)$vendorAmount[Fields::$vendorAmount];
$newAmount = $amount + (int)$data[Fields::$balanceMoney];
$version = (int)$vendorAmount[Fields::$vendorAmountVersion];
//收費員賬戶流水表信息
$vendorIncomeDate = [
Fields::$incomeNum=>Rands::createIncomeSerialNumber(),
Fields::$systemId=>$data[Fields::$systemId],
Fields::$vendorId=>$data[Fields::$vendorId],
Fields::$incomeType=>1, //流水類型 1 清算 2 提現 3 轉入 4轉出 5 沖正
Fields::$incomeMode=>1 , //流水模式 1 進賬 2 出賬
Fields::$money =>$data[Fields::$balanceMoney] ,
Fields::$vendorAmount =>$newAmount,
Fields::$originalVendorAmount =>$amount,
Fields::$vendorAmountVersion => $version+1,
Fields::$balanceNum=>$data[Fields::$balanceNum],
Fields::$desc=>"付款清算:{$data[Fields::$balanceNum]} 轉入",
Fields::$status=>1,
Fields::$incomeTime=>$data[Fields::$balanceTime],
Fields::$createTime=>$data[Fields::$createTime],
];
try{
//多表處理 開啟事務
Db::startTrans();
//升級收費員余額 加入了樂觀鎖判斷
if (!Db::table(Tables::$paymentSystemVendor)
->where([Fields::$vendorId=>$data[Fields::$vendorId],Fields::$vendorAmountVersion =>$version ])
->update([Fields::$vendorAmount=>$newAmount,Fields::$vendorAmountVersion=>$version+1])
){
throw new Exception("商戶的余額信息已經變動,請重試");
}
//升級付款表為已經結算狀態
if (!Db::table(Tables::$paymentPay)->where([
Fields::$payNum=>$data[Fields::$payNum],Fields::$status=>1,
])->update([Fields::$status=>2,Fields::$balanceTime=>$data[Fields::$createTime]])){
throw new Exception("升級付款表失敗");
}
//插入結算流水信息
if (!Db::table(Tables::$paymentPayBalance)->insert($data)){
throw new Exception("插入結算流水信息失敗");
}
//插入商戶金額流水信息
if (!Db::table(Tables::$paymentSystemIncome)->insert($vendorIncomeDate)){
throw new Exception("插入商戶金額流水信息失敗");
}
Db::commit();
return true;
}catch (Exception $e){
$this->error = $e->getMessage();
Log::error($e->getMessage());
Db::rollback();
return false;
}
}
public function getError(){
return $this->error;
}
}
~~~
- 序言及更新日志
- 前言一 開發PHP必備的環境(你可以不看)
- LinUX系統ThinkPHP5鏈接MsSQL數據庫的pdo_dblib擴展
- centos7.2掛載硬盤攻略
- Centos系統Redis安裝及Redis的PHP擴展安裝
- Centos系統增加Swap(系統交換區)的方法
- 前言二 開發PHP軟件配置和介紹(你依然可以不看)
- 數據庫SQL文件
- 本地Git(版本控制)的搭建
- GIT遠程倉庫的克隆和推送
- Git常用命令
- PHP面向對象思想實戰經驗領悟
- PHP面向對象實戰----命名空間
- PHP面向對象實戰----繼承
- 基類實戰--底層方法封裝
- 基類實戰--構造函數實戰
- 基類實戰--析構函數的使用
- TP5實戰開發前篇---控制器(controller)
- 控制器中Request類的使用
- 控制器中基類的使用
- TP5實戰開發前篇---模型篇(model)
- TP5實戰開發前篇---驗證器篇(Validate)
- TP5實戰課程入門篇---花拳繡腿
- 模塊以及類的文件的建立
- Api開發------單條信息顯示
- Api開發---單條信息復雜關聯顯示
- Api開發---查詢信息緩存Cache的應用
- TP5實戰技巧---開發思路 引路造橋
- TP5實戰技巧---整合基類 化繁為簡
- TP5實戰課程入門篇---數據操作
- Api開發---數據的添加和修改
- API開發---快速開發API通用接口
- TP5專用微信sdk使用教程
- THINKPHP5微信SDK更新記錄及升級指導
- TP5專用SDK 微信參數配置方法
- 微信公眾號推送接口對接教程
- 微信推送接口對接示例含掃描登錄微信端部分
- TP5專用微信支付SDK使用簡介
- TP5專用支付寶支付SDK使用說明
- 使用NW將開發的網站打包成桌面應用
- TP5高階實戰課程 進階篇概述
- 進階篇一 實戰開發之習慣及要求
- 進階篇二 實戰開發之控制器
- 控制器基類之控制器基類使用方法
- 控制器基類之控制器基類常用方法分享
- 控制器基類之構造函數的使用方法
- 進階篇三 實戰開發之權限控制
- TP5實戰源碼 --- 全局用戶信息驗證類Auth
- TP5實戰源碼 --- 微信Auth實戰開發源碼
- 進階篇四 實戰開發之模型
- 模型基類之模型基類的用途
- 模型基類之常用數據處理方法
- 模型邏輯層之實戰代碼(含事務)
- 模型實戰開發之模型常用方法
- 模型實戰源碼 --- 樂觀鎖的應用
- 模型實戰技巧---Model事件功能的使用
- 模型事件實戰應用---數據庫操作日志
- 進階篇五 實戰開發之緩存(Cache)
- TP5實戰源碼---應用緩存獲取城市信息
- TP5實戰源碼---應用緩存獲取分類詳情
- 進階篇六 TP5類庫的封裝和使用
- DataEdit快捷操作類庫
- ShowCode快捷使用類庫
- 阿里大于 短信API接口 TP5專用類庫
- DatabaseUpgrade數據庫對比及更新類庫
- AuthWeb權限類使用說明
- 進階篇七 服務層的應用
- 服務層源碼示例
- 服務層基類源碼
- 進階篇八 應用層Redis數據處理基類
- Redis服務層基類源碼
- 進階篇九 使用Redis類庫處理一般的搶購(秒殺)活動示例
- 進階篇十 某大型項目應用本Redis類源碼示例(含事務 樂觀鎖)
- 進階篇十一 邏輯層的應用
- 邏輯層基類源碼
- 進階篇 服務層代碼示例
- 高階實戰課程 進階篇持續新增中
- 高階篇一 TP5命令行之守護任務源碼
- TP5實戰源碼 --- 命令行
- TP5實戰源碼 --- 通過shell建立PHP守護程序
- 高階篇二 使用Redis隊列發送微信模版消息
- 高階篇二 之 Worker隊列基類源碼
- 高階篇三 TP5實戰之Redis緩存應用
- Redis實戰源碼之Hash專用類庫源碼
- Redis實戰源碼之Model類結合
- Redis實戰源碼之模型Hash基類源碼
- Redis實戰源碼之Hash查詢使用技巧
- Redis實戰源碼之 shell腳本中redis賦值和取值
- 高階篇四 Swoole的實戰應用
- swoole基類代碼
- Swoole擴展WebsocketServer專用類
- 基于Swoole的多Room聊天室的程序
- Swoole守護服務shell源碼
- 高階篇五 命令行異步多進程隊列類的應用
- tp_worker類源碼
- WorkerBase
- WorkerCommand
- WorkerRedis
- Redis類
- CycleWorkBase
- WorkerHookBase異步鉤子
- 隊列日志SQL
- 高階篇六 定時執行隊列類庫以及使用方法
- 定時隊列類庫源碼
- 高階篇七 異步執行循環隊列類庫以及使用教程
- CycleWorkBase源碼
- 高階實戰課程 進階篇持續新增中
- Extend便捷類庫源碼庫
- 阿里相關類庫
- SendSms--驗證碼API接口文件
- 權限相關類庫目錄
- AuthWeb 權限驗證類庫
- Redis便捷操作類庫(20171224更新)
- Redis
- Tools工具類庫集
- Curl類庫
- DataEdit
- Rand類庫
- ShowCode類庫
- Upload類庫
- 附件集合
- 附件一:微信支付 實戰開發源碼
- 微信支付類庫源代碼
- Common_util_pub.php
- DownloadBill_pub.php
- JsApi_pub.php
- NativeCall_pub.php
- NativeLink_pub.php
- OrderQuery_pub.php
- Refund_pub.php
- RefundQuery_pub.php
- SDKRuntimeException.php
- ShortUrl_pub.php
- UnifiedOrder_pub.php
- Wxpay_client_pub.php
- Wxpay_server_pub.php
- WxPayConf_pub.php
- 微信支付回調頁面源碼
- 附件二 順豐快遞BSP接口實戰開發源碼
- 順豐快遞BSP接口實戰開發源碼
- 順豐BSP基類
- 順豐BSP基礎代碼
- 順豐BSP下單接口
- 順豐BSP查單接口
- 順豐BSP確認/取消接口
- 附件三 APP注冊登陸接口源碼(含融云平臺接口)
- 附件四 TP5訂單Model(含事務 獲取器 修改器等方法)
- 附錄五 RSA加密解密
- Rsa文件源碼
- 附件六 阿里大于短信接口
- 附件七 AES加解密類
- AES加解密類源碼
- 附件八 TP5路由設置源碼
- 附件九 TP5 Excel導入導出下載便捷類庫
- Excel類庫TP5源碼
- 附件十 TP5便捷操作Redis類庫源碼
- TP5源碼 Redis操作便捷類庫
- 附件十一 TP5源碼 上傳文件入庫類源碼
- 上傳類Upload源碼
- Upload類上傳配置文件
- 存儲圖像文件的數據庫SQL文件
- 存儲文件的數據庫SQL文件
- 附件十二 TP5 圖片處理增強類 支持縮略圖在線顯示
- 附件十三 微信推送消息接口類庫源碼
- 附件十三 微信推送消息接口類庫源碼 之 基類
- 附件十四 存儲微信昵稱的處理方法