12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- /**
- * Withdraw.php UTF-8
- * 提现基类
- *
- * @date : 2018/7/4 10:33
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : wuyonghong <wyh@huosdk.com>
- * @version : Beibao 1.0
- */
- namespace huolib\withdraw;
- use huolib\status\OrderStatus;
- use think\Exception;
- use think\Log;
- class Withdraw {
- static $ins;
- private $payway_map
- = [
- 'default' => 'Mobile',
- 'alipay' => 'Alipay',
- 'wxpay' => 'Wxpay',
- 'mobile' => 'Mobile',
- ];
- public static function ins() {
- if (self::$ins == null) {
- self::$ins = new self();
- }
- return self::$ins;
- }
- /**
- * @param string $payway
- *
- * @return mixed
- * @throws Exception
- */
- public function get($payway = '') {
- if (empty($payway)) {
- return $this->register('default');
- }
- $_pay_obj = $this->register($payway);
- if (!isset($_pay_obj)) {
- Log::write(
- "func=".__FUNCTION__."&class=".__CLASS__."&errmsg=registerError&payway=".$payway
- .'objName='.$this->payway_map[$payway], 'info'
- );
- throw new Exception(OrderStatus::getMsg(OrderStatus::PAYWAY_INCORRECT), OrderStatus::PAYWAY_INCORRECT);
- }
- return $_pay_obj;
- }
- /**
- * @param string $payway
- *
- * @return mixed
- */
- protected function register($payway = '') {
- $payway = strtolower($payway);
- $_class = '\\huolib\\withdraw\\driver\\'.$this->payway_map[$payway];
- return new $_class();
- }
- }
|