Change Status Self Hire
對應 legacy API:
/quote_bids/change_status/self_hire/{quote_bid_id}.json快速結論
- 用途:provider 自標已接案。
- actor:provider。
- new API:已補
Endpoint/V1/QuoteBids.php::change_status_self_hire()。 - helper:
PRO360\ActionHelper\QuoteBid\ChangeStatusSelfHireHelper - 測試:
tests/QuoteBidsChangeStatusSelfHireTest.php - 注意:這和
hired不同;hired是 consumer 標記 provider。
New API routing
quote_bids/change_status/self_hire/{quote_bid_id}.json
-> change_status_self_hire/quote_bid_id/{quote_bid_id}
-> Endpoint/V1/QuoteBids.php::change_status_self_hire()Response contract
成功:
{"status":"Success","error":0}失敗:
{"error":625,"status":"您已被對方封鎖,無法進行此操作"}{"error":18,"status":"消費者未回覆前無法標注已接案"}Legacy 規則
成功條件:
- actor 是 provider
- consumer / provider 沒有封鎖聊天
quote_bids.is_want_to_contact_provider = 1quote_bids.quote_status_id = InProgress
成功 side effect:
quote_bids.provider_status_id = Hiredquote_bids.provider_status_on = nowquote_bids.provider_last_read_on = now- 寫 HireVendor activity,
param1 = self_hire - 寫 Fetnet unread
- 送
EventQueue.Self_Hire quote_status_id不改,仍維持InProgresshired_on不寫入
notification:
- email / moengage / push / web_push / sms
- 55688 request 有特殊 template
失敗:
- 若雙方有 blocked chat,回
error=625 - 若 consumer 未回覆或尚未正式聯絡,回
error=18
實作狀態
- 已補 explicit mapping,不依賴 Router fallback。
- 已補 provider actor guard。
- 已補 blocked chat guard。
- 已補
is_want_to_contact_provider = 1+quote_status_id = InProgressguard。 - 已補 provider 狀態更新、HireVendor activity、Fetnet unread、
Self_Hireevent queue。 - 已補 55688 template 分支:email 使用
life55688-180 Vendor Mark Hired Notification,sms 使用life55688-sms.pro_mark_hired。
Verification
docker exec -w /project-data cd63f9147e8d vendor/bin/phpunit tests/QuoteBidsChangeStatusSelfHireTest.php2026-05-14 結果:
OK (4 tests, 39 assertions)覆蓋情境:
- provider 成功 self hire。
- consumer / 非 provider 不能 self hire。
- consumer 尚未聯絡時回
error=18。 - blocked chat 時回
error=625。 - 成功後
quote_status_id保持InProgress,只更新provider_status_id = Hired。 - 成功後可在
event_queue或event_queue_log_*找到Self_Hire。
新舊程式對應
以下行號是本次 migration 實作後的定位,用來追 code review / 後續補差異;若檔案再改動,行號可能會漂移,仍以區塊職責為準。
Legacy PHP 5.6
主要入口:
/Users/mattsu/Documents/Site/get-lancer-php56/app/Plugin/Quotes/Controller/QuoteBidsController.php| legacy 行號 | 職責 |
|---|---|
3695-3696 | 進入 filter == self_hire,且 actor 必須是 provider。 |
3698-3702 | 檢查 blocked chat;被封鎖時回 error=625。 |
3703-3704 | 成功前置條件:is_want_to_contact_provider = 1 且 quote_status_id = InProgress。 |
3706-3712 | 更新 provider_status_id = Hired、provider_status_on、provider_last_read_on,回 Success + error=0。 |
3714-3718 | 建立 hire URL,寫 HireVendor activity,param1 = self_hire。 |
3720-3723 | Fetnet unread counter。 |
3725-3767 | 準備 requestor / provider / request title / security hash / email replace content。 |
3776-3777 | 建立 EventParameterDO,event target user 是 consumer/requestor。 |
3779-3787 | 55688 分支:email template life55688-180 Vendor Mark Hired Notification。 |
3788-3827 | 一般分支:Mark_Self_Hire moengage、push.content.self.hire push/web_push。 |
3829-3855 | SMS hash / URL / template;一般 sms.pro_mark_hired,55688 life55688-sms.pro_mark_hired。 |
3856-3858 | 寫入 EventQueue.Self_Hire。 |
3860-3862 | consumer 未回覆或尚未聯絡時回 error=18。 |
New PHP 8.2
route / endpoint:
| new 檔案行號 | 職責 |
|---|---|
Lib/Common/RouterRule/Mapping.php:165-168 | explicit route:quote_bids/change_status/self_hire/{id}.json -> change_status_self_hire。 |
Endpoint/V1/QuoteBids.php:2964-2973 | API action:驗 session、取 quote_bid_id,呼叫 ChangeStatusSelfHireHelper。 |
helper:
Lib/ActionHelper/QuoteBid/ChangeStatusSelfHireHelper.php| new 行號 | 對應 legacy | 職責 |
|---|---|---|
39-57 | 3695-3696 | 讀 bid/request,確認 actor 是 provider;不符合回 error=1。 |
59-64 | 3698-3702 | blocked chat guard;回 error=625。 |
66-71 | 3703-3704, 3860-3862 | 檢查 consumer 已聯絡且 bid 仍是 InProgress;不符合回 error=18。 |
73-79 | 3706-3709 | 只更新 provider lifecycle 欄位,不改 quote_status_id,不寫 hired_on。 |
81-93 | 3714-3718 | 建立短網址,寫 HireVendor activity,param1 = self_hire。 |
95 | 3720-3723 | Fetnet unread counter。 |
96, 110-235 | 3725-3858 | 組 notification payload 並寫 Self_Hire event。 |
98-101 | 3711-3712 | 成功 response:{"status":"Success","error":0}。 |
102-107 | legacy 各錯誤分支 | 統一 error response。 |
notification payload 對照:
| new 行號 | 對應 legacy | 職責 |
|---|---|---|
120-131 | 3725-3734 | 讀 consumer、service、語系、request title、provider name、security hash。 |
133-152 | 3750-3767 | 建立 email replace content,補推薦 feature。 |
154-156 | 3776-3777 | 建立 EventTaskDO,top-level 只設定 consumer/requestor user_id;quote_service_id / quote_bid_id / quote_request_id 保持 legacy 的 null,實際 bid/request id 放在各 task payload 內。 |
160-182 | 3779-3787 | 55688 email 分支。 |
184-192 | 3792-3800 | 一般 moengage Mark_Self_Hire。 |
194-217 | 3802-3827 | 一般 push / web_push push.content.self.hire。 |
220-233 | 3829-3855 | SMS template 與短網址。 |
235 | 3856-3858 | EventQueue::insertEvent('Self_Hire', ...)。 |
tests:
| test 行號 | 職責 |
|---|---|
tests/QuoteBidsChangeStatusSelfHireTest.php:102-145 | 成功路徑:response、bid 狀態、activity、event payload。 |
tests/QuoteBidsChangeStatusSelfHireTest.php:148-159 | actor 必須是 provider。 |
tests/QuoteBidsChangeStatusSelfHireTest.php:162-176 | consumer 未聯絡前回 error=18。 |
tests/QuoteBidsChangeStatusSelfHireTest.php:179-197 | blocked chat 回 error=625。 |