error = $msg; return false; } public function __construct ($config = []) { if(empty($config['mall_id'])){ throw new \Exception('WithdrawalService mall_id Must have method property'); } if(empty($config['log_id'])){ throw new \Exception('WithdrawalService log_id Must have method property'); } foreach ($config as $index=>$name) { if(!property_exists($this,$index)){ unset($config[$index]); }; } parent::__construct($config); } public function aliToPay() { $list = Withdraw::find()->where(['mall_id'=>$this->mall_id,'id'=>$this->log_id])->all(); if(empty($list)) return $this->error("记录不存在"); foreach ($list as $cash) { if ( $cash['status'] != 1) return $this->error("{$cash['order_no']}记录状态不正确"); } $lock_key = RedisKeyEnum::suffix(RedisKeyEnum::LOCK_USER_CASH , 'alitopay_'.$this->mall_id); $uniqid = uniqid(); // if (!LockHelper::lock($lock_key, $uniqid, 100, 100)) { // \Yii::error('cashForm 获取锁(' . $lock_key . ')失败阻塞,提现打款:cash,操作:save,金额:' . $cash->id); // return $this->error("操作频繁,请稍后重试~"); // } $ids = array_column($list,'id'); $pay_res = GlobalInvoke::exec(GlobalInvoke::INVOKE_WITHDRAW_ALITOPAY_PAY,$cash->mall_id,[ 'ids'=>$ids, 'mall_id'=>$this->mall_id ]); if(!$pay_res['res']){ return $this->error($pay_res['data']); } // 创建打款订单成功,修改成打款中状态 foreach ($list as $cash) { // Withdraw::remit_wait($cash,'支付宝打款中...'); // $res = Withdraw::updateAll(['content'=>Json::encode($content),'status'=>5],['id'=>$cash['id']]); } return $pay_res["data"]; } // 代税宝 public function avoidtaxToPay() { $list = Withdraw::find()->where(['mall_id'=>$this->mall_id,'id'=>$this->log_id])->all(); if(empty($list)) return $this->error("记录不存在"); foreach ($list as $cash) { if ( $cash['status'] != 1) return $this->error("{$cash['order_no']}记录状态不正确"); } // $lock_key = RedisKeyEnum::suffix(RedisKeyEnum::LOCK_USER_CASH , 'avoidtax_'.$this->mall_id); // $uniqid = uniqid(); // if (!LockHelper::lock($lock_key, $uniqid, 100, 100)) { // return $this->error("操作频繁,请稍后重试~"); // } /* 代税宝 业务 start */ $ids = array_column($list,'id'); // addons\AvoidTax\common\service\OrderService $pay_res = GlobalInvoke::exec(GlobalInvoke::INVOKE_WITHDRAW_AVOIDTAX_PAY,$cash->mall_id,[ 'ids'=>$ids, 'mall_id'=>$this->mall_id ]); if(!$pay_res['res']){ return $this->error($pay_res['data']); } /* 代税宝 业务 end */ // 创建打款订单成功,修改成打款中状态 foreach ($list as $cash) { Withdraw::remit_wait($cash,'代税宝打款中...'); } return $pay_res["data"]; } /** * 银典代付 * * @return false|array */ public function yunfastPay() { $list = Withdraw::find()->where(['mall_id' => $this->mall_id, 'id' => $this->log_id])->all(); if(empty($list)) return $this->error('记录不存在'); foreach ($list as $cash) { if ($cash['status'] != 1) return $this->error("{$cash['order_no']}记录状态不正确"); } $ids = array_column($list, 'id'); $success_ids = GlobalInvoke::exec(GlobalInvoke::INVOKE_WITHDRAW_YUNFAST_PAY, $cash->mall_id, [ 'ids' => $ids, 'mall_id' => $this->mall_id ]); return $success_ids; } /** * 银企直联 * * @return void */ public function banktaxToPay() { $list = Withdraw::find() ->where([ 'mall_id' => $this->mall_id, 'id' => $this->log_id, 'type' => 'bank_tax', 'status' => UserWithdrawLog::STATUS_AGREE, ]) ->all(); if (empty($list)) { return $this->error('记录不存在'); } // 合规提现业务 $ids = array_column($list, 'id'); $pay_res = GlobalInvoke::exec(GlobalInvoke::INVOKE_WITHDRAW_BANKTAX_PAY, $this->mall_id, [ 'ids' => $ids, 'mall_id' => $this->mall_id, ]); if (!$pay_res['res']) { return $this->error($pay_res['data']); } // 创建打款订单成功,修改成打款中状态 foreach ($list as $cash) { Withdraw::remit_wait($cash, '银企直联打款中...'); } return $pay_res['data']; } /** * 点薪灵工 * * @return void */ public function linggongToPay($params) { $list = Withdraw::find() ->where([ 'mall_id' => $this->mall_id, 'id' => $this->log_id, 'type' => 'linggong', 'status' => [UserWithdrawLog::STATUS_AGREE, UserWithdrawLog::STATUS_APPLY], ]) ->all(); if (empty($list)) { return $this->error('记录不存在'); } // 合规提现业务 $ids = array_column($list, 'id'); $pay_res = GlobalInvoke::exec(GlobalInvoke::INVOKE_WITHDRAW_LINGGONG_PAY, $this->mall_id, [ 'ids' => $ids, 'mall_id' => $this->mall_id, 'task_id' => $params['task_id'], ]); if (!$pay_res['res']) { return $this->error($pay_res['data']); } // 创建打款订单成功,修改成打款中状态 foreach ($list as $cash) { Withdraw::remit_wait($cash, '点薪灵工打款中...'); } return $pay_res['data']; } }