diff --git a/app/common/models/Withdraw.php b/app/common/models/Withdraw.php index c2b16f83..903eac43 100644 --- a/app/common/models/Withdraw.php +++ b/app/common/models/Withdraw.php @@ -216,6 +216,9 @@ class Withdraw extends BaseModel const MANUAL_TO_ALIPAY = 3; + // 第三方打款 + const MANUAL_TO_THIRD_PARTY = 4; + /** * 审核通过的收入 ids 集合 * diff --git a/app/common/services/withdraw/PayedService.php b/app/common/services/withdraw/PayedService.php index cd1f2d2b..69bbdf2d 100644 --- a/app/common/services/withdraw/PayedService.php +++ b/app/common/services/withdraw/PayedService.php @@ -25,6 +25,8 @@ use app\common\services\PayFactory; use Illuminate\Support\Facades\DB; use app\common\services\finance\BalanceNoticeService; use app\common\services\finance\MessageService; +use Yunshop\UseStaff\models\ExternalApi; +use Yunshop\UseStaff\models\UseStaff; class PayedService { @@ -668,6 +670,19 @@ class PayedService */ private function manualWithdrawPay() { + if($this->withdrawModel->manual_type == 4){ + // 第三方代发(汇优财) + $staff = UseStaff::getSingleInfo(['uid'=>$this->withdrawModel->member_id]); + $info = [ + 'uid' => $this->withdrawModel->member_id, + 'month' => date("Ym",strtotime($this->withdrawModel->created_at)), + 'member_id' => $staff['member_id'], + 'salary' => $this->withdrawModel->actual_amounts + ]; + $result = (new ExternalApi())->salaryModelOutOrder($info); + if((int)$result['respCode'] === 2) return true; + else throw new ShopException($result['respDesc']); + } return true; } diff --git a/app/frontend/modules/finance/controllers/IncomeWithdrawController.php b/app/frontend/modules/finance/controllers/IncomeWithdrawController.php index c0d182d1..e157d988 100644 --- a/app/frontend/modules/finance/controllers/IncomeWithdrawController.php +++ b/app/frontend/modules/finance/controllers/IncomeWithdrawController.php @@ -30,7 +30,7 @@ use Yunshop\TeamDividend\models\TeamDividendAgencyModel; use Yunshop\TeamDividend\services\withdraw\IncomeWithdrawApply; use app\common\services\finance\Withdraw as WithdrawService; use Yunshop\ShopEsign\common\service\ContractService; - +use Yunshop\UseStaff\models\UseStaff; class IncomeWithdrawController extends ApiController { @@ -866,6 +866,15 @@ class IncomeWithdrawController extends ApiController $incomeWithdrawMode['manual']['wechat'] = $yz_member->wechat; $incomeWithdrawMode['manual']['member_name'] = $member_bank->member_name; $incomeWithdrawMode['manual']['bank_card'] = $member_bank->bank_card; + // 获取第三方代发账号信息 + if (app('plugins')->isEnabled('use-staff')) { + $staff = UseStaff::uniacid() + ->where('uid',$member_id) + ->select(['id','name','card_num']) + ->first(); + $incomeWithdrawMode['manual']['use_staff_name'] = $staff->name ?? ''; + $incomeWithdrawMode['manual']['use_staff_card_num'] = $staff->card_num ? substr_replace($staff->card_num,'******',6,-4) : ''; + } } return $this->successJson('获取数据成功!', $incomeWithdrawMode); } diff --git a/app/frontend/modules/finance/controllers/ManualTypeController.php b/app/frontend/modules/finance/controllers/ManualTypeController.php index ab165b14..bf0d32b2 100644 --- a/app/frontend/modules/finance/controllers/ManualTypeController.php +++ b/app/frontend/modules/finance/controllers/ManualTypeController.php @@ -32,6 +32,10 @@ class ManualTypeController extends ApiController $result['manual_type'] = 'alipay'; $result['status'] = WithdrawManualService::getAlipayStatus(); break; + case 4: + $result['manual_type'] = 'third_party'; + $result['status'] = WithdrawManualService::getThirdPartyStatus(); + break; default: $result['manual_type'] = 'bank'; $result['status'] = WithdrawManualService::getBankStatus(); diff --git a/app/frontend/modules/finance/services/WithdrawManualService.php b/app/frontend/modules/finance/services/WithdrawManualService.php index cdfa3202..bb635aa3 100644 --- a/app/frontend/modules/finance/services/WithdrawManualService.php +++ b/app/frontend/modules/finance/services/WithdrawManualService.php @@ -11,6 +11,7 @@ namespace app\frontend\modules\finance\services; use app\frontend\models\MemberShopInfo; use app\frontend\modules\member\models\MemberBankCard; +use Yunshop\UseStaff\models\UseStaff; class WithdrawManualService { @@ -27,6 +28,10 @@ class WithdrawManualService return $yzMember ? ($yzMember->alipayname && $yzMember->alipay) ? true : false : false; } + public static function getThirdPartyStatus(){ + $staff = UseStaff::select(['name','card_num','status'])->where('uid',\YunShop::app()->getMemberId())->first(); + return $staff && $staff->name && $staff->card_num && (int)$staff->status == 4; + } public static function getBankStatus() { diff --git a/app/frontend/modules/withdraw/services/PayWayValidatorService.php b/app/frontend/modules/withdraw/services/PayWayValidatorService.php index 3587e654..34032f5c 100644 --- a/app/frontend/modules/withdraw/services/PayWayValidatorService.php +++ b/app/frontend/modules/withdraw/services/PayWayValidatorService.php @@ -136,6 +136,9 @@ class PayWayValidatorService case Withdraw::MANUAL_TO_ALIPAY: $result = $this->alipayStatus(); break; + case Withdraw::MANUAL_TO_THIRD_PARTY: + $result = $this->thirdPartyStatus(); + break; default: $result = $this->bankStatus(); } @@ -290,6 +293,14 @@ class PayWayValidatorService } + protected function thirdPartyStatus() + { + if (!WithdrawManualService::getThirdPartyStatus()) { + return '请先完善信息'; + } + return true; + } + protected function getManualType() { $set = Setting::get('withdraw.income'); diff --git a/app/helpers.php b/app/helpers.php index e4806189..76b000ff 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -3904,4 +3904,38 @@ if (!function_exists('getTimeStamp')) { } return [$startTime,$endTime]; } -} \ No newline at end of file +} +// post请求 +if (!function_exists('curlPost')) { + function curlPost($url, $post_data = array(), $timeout = 5, $header = "", $data_type = "") { + $header = empty($header) ? '' : $header; + //支持json数据数据提交 + if($data_type == 'json'){ + $post_string = json_encode($post_data); + }elseif($data_type == 'array') { + $post_string = $post_data; + }elseif(is_array($post_data)){ + $post_string = http_build_query($post_data, '', '&'); + } + + $ch = curl_init(); // 启动一个CURL会话 + curl_setopt($ch, CURLOPT_URL, $url); // 要访问的地址 + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 对认证证书来源的检查 // https请求 不验证证书和hosts + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在 + curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器 + //curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自动跳转 + //curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自动设置Referer + curl_setopt($ch, CURLOPT_POST, true); // 发送一个常规的Post请求 + curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string); // Post提交的数据包 + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); // 设置超时限制防止死循环 + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); + //curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容 + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 获取的信息以文件流的形式返回 + curl_setopt($ch, CURLOPT_HTTPHEADER, $header); //模拟的header头 + $result = curl_exec($ch); + + + curl_close($ch); + return json_decode($result,true); + } +} diff --git a/resources/views/finance/withdraw/withdraw-income.blade.php b/resources/views/finance/withdraw/withdraw-income.blade.php index ded22a0d..65bce828 100644 --- a/resources/views/finance/withdraw/withdraw-income.blade.php +++ b/resources/views/finance/withdraw/withdraw-income.blade.php @@ -522,6 +522,10 @@ 支付宝 +