12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- 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;
- }
-
- 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;
- }
-
- protected function register($payway = '') {
- $payway = strtolower($payway);
- $_class = '\\huolib\\withdraw\\driver\\'.$this->payway_map[$payway];
- return new $_class();
- }
- }
|