~~~
<?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 图片处理增强类 支持缩略图在线显示
- 附件十三 微信推送消息接口类库源码
- 附件十三 微信推送消息接口类库源码 之 基类
- 附件十四 存储微信昵称的处理方法