where('role_id', $roleId) ->where('channel', 'huifu') ->find(); $now = time(); if ($existing) { $existing->receiver_type = 'HUIFU_ID'; $existing->receiver_account = $row['huifu_id']; $existing->receiver_name = $name; $existing->status = 'normal'; $existing->updatetime = $now; $existing->save(); self::bindHuifuSplitReceiver($row); return $existing; } $created = Receiver::create([ 'role_type' => $row['role_type'], 'role_id' => $roleId, 'channel' => 'huifu', 'receiver_type' => 'HUIFU_ID', 'receiver_account' => $row['huifu_id'], 'receiver_name' => $name, 'relation_type' => 'USER', 'wx_status' => 0, 'status' => 'normal', 'createtime' => $now, 'updatetime' => $now, ]); self::bindHuifuSplitReceiver($row); return $created; } /** * 进件通过后向汇付主商户提交 split/config,绑定子户为分账接收方 */ protected static function bindHuifuSplitReceiver(Onboard $row) { if (!class_exists('\\addons\\shopro_huifu\\library\\split\\HuifuMerchantSplitService')) { return; } try { (new \addons\shopro_huifu\library\split\HuifuMerchantSplitService())->bindOnboardReceiver($row); } catch (\Throwable $e) { \think\Log::error('[shopro_huifu] onboard split bind: ' . $e->getMessage()); } } public static function bindOnboardId($roleType, $roleRefId, $onboardId) { if ($roleType === 'promoter') { Db::name('shopro_commission_agent')->where('user_id', $roleRefId)->update(['huifu_onboard_id' => $onboardId]); return; } if ($roleType === 'regional_agent') { Db::name('shopro_regional_agent')->where('id', $roleRefId)->update(['huifu_onboard_id' => $onboardId]); } } }