Skip to content

Instantly share code, notes, and snippets.

@jocoonopa
Last active November 27, 2019 05:22
Show Gist options
  • Save jocoonopa/712c1a0402dc55c043d5124eb44f0037 to your computer and use it in GitHub Desktop.
Save jocoonopa/712c1a0402dc55c043d5124eb44f0037 to your computer and use it in GitHub Desktop.

欄位對應

  • ENTP_CODE => 廠編 => 身分證字號 Contact.identity_no *唯一值
  • ENTP_NAME => 廠名 => 名字 Contact.last_name
  • S_IDNO => 統編 => 姓氏 Contact.first_name
  • ENTP_PHONE => 公司電話 => 公司電話 PhoneNumber[0].number
  • EEXPHONE => 公司分機 => 公司分機 PhoneNumber[0].extension
  • ENTP_MAN_PHONE => 承辦人市話 => PhoneNumber[1].number
  • MEXPHONE => 承辦人分機 => PhoneNumber[1].extension
  • ENTP_MAN_CELLPHONE => 承辦人手機號碼 => PhoneNumber[2].number
  • EMAIL_ADDR => Email EmailContact[0].address
  • ENTP_TYPE_NAME => 供應商類型 => 供應商類型 CzCol.1
  • DISHONOR_YN => 往來狀態 => 往來狀態 CzCol.2 {"0": "正常","1": "跳票","2": "中斷","3": "靜止","4": "退件"} // 請參考 目前動態欄位之資訊
  • AM_USER_ID => AM員編 => AM員編 CzCol.4 // 請參考 目前動態欄位之資訊
  • USER_NAME => AM名稱 => AM名稱 CzCol.5 // 請參考 目前動態欄位之資訊
  • NET_ORDER_OUT_AMT_LEVEL => 供應商等級 CzCol.9 // 請參考 目前動態欄位之資訊
  • ENTP_MAN_SEQ => 承辦人序號 => 電話描述 {承辦人序號}-{承辦人類型}-{承辦人名稱}
  • ENTP_MAN_GB_NAME => 承辦人類型 => 電話描述 {承辦人序號}-{承辦人類型}-{承辦人名稱}
  • ENTP_MAN_NAME => 承辦人名稱 => 電話描述 {承辦人序號}-{承辦人類型}-{承辦人名稱}

目前所有動態欄位之資訊

請求網址

GET https://firstline.localhost/api/v1/cz-col

[
    {
        "id": 2,
        "name": "往來狀態",
        "default": null,
        "description": "",
        "is_allowed_null": true,
        "type": 1,
        "created_at": "2019-10-31 17:58:48",
        "updated_at": "2019-10-31 17:58:48",
        "category_id": 1,
        "creater_id": 1,
        "options": null
    },
    {
        "id": 3,
        "name": "供應商類型",
        "default": null,
        "description": "",
        "is_allowed_null": true,
        "type": 1,
        "created_at": "2019-10-31 17:58:48",
        "updated_at": "2019-10-31 17:58:48",
        "category_id": 1,
        "creater_id": 1,
        "options": null
    },
    {
        "id": 4,
        "name": "AM員編",
        "default": null,
        "description": "",
        "is_allowed_null": true,
        "type": 1,
        "created_at": "2019-10-31 17:58:48",
        "updated_at": "2019-10-31 17:58:48",
        "category_id": 1,
        "creater_id": 1,
        "options": null
    },
    {
        "id": 5,
        "name": "AM名",
        "default": null,
        "description": "",
        "is_allowed_null": true,
        "type": 1,
        "created_at": "2019-10-31 17:58:48",
        "updated_at": "2019-10-31 17:58:48",
        "category_id": 1,
        "creater_id": 1,
        "options": null
    },
    {
        "id": 9,
        "name": "供應商等級",
        "default": null,
        "description": null,
        "is_allowed_null": true,
        "type": 1,
        "created_at": "2019-11-01 12:00:38",
        "updated_at": "2019-11-01 12:00:38",
        "category_id": 1,
        "creater_id": 1,
        "options": []
    }
]

指定動態欄位之資訊

GET https://firstline.localhost/api/v1/cz-col/{cz_col}

{cz_col} 表示動態欄位之 id, 以 9 代入可取得下列資訊

{
    "data": {
        "id": 9,
        "name": "供應商等級",
        "description": null,
        "is_allowed_null": true,
        "default": null,
        "type": 1,
        "options": [],
        "category_id": 1,
        "category": {
            "id": 1,
            "name": "其他資訊",
            "description": "Necessitatibus laborum saepe nostrum ea. Molestias ab officia omnis natus omnis."
        },
        "creater_id": 1,
        "creater": {
            "id": 1,
            "name": "momo ",
            "first_name": "momo",
            "last_name": null,
            "employee_no": "momo",
            "photo_url": null,
            "identity_no": null,
            "job_title_id": -1,
            "department_id": -1,
            "extension_id": -1,
            "extension": null,
            "group_id": null,
            "group": {
                "id": null,
                "name": null,
                "description": null,
                "supervisor_id": null
            },
            "cti_agent_account": null,
            "cti_agent": null,
            "created_at": "2019-10-31 12:42:01",
            "updated_at": "2019-10-31 12:42:01"
        }
    }
}

流程

示意如下

搜尋到的客戶 = 透過身分證尋找客戶()

if null == 搜尋到的客戶:
    新客戶 = 建立客戶(客戶資料)

    對客戶添加電話(新客戶)
    對客戶添加Email(新客戶)

else:
    更新客戶(搜尋到的客戶, 客戶資料)

    電話 = 尋找客戶已註冊的電話(搜尋到的客戶, 電話資料)

    if 電話
        更新電話(電話, 電話資料)
    else
        對客戶添加電話(搜尋到的客戶, 電話資料)

    email = 尋找客戶已註冊的Email(搜尋到的客戶, email資料)

    if email
        更新Email(搜尋到的客戶, email資料)
    else
        對客戶添加Email(搜尋到的客戶, email資料)

客戶

透過身分證尋找客戶

請求網址 GET https://firstline.localhost/api/v1/contact

參數

{
    "identity_no": "A0058"
}

response

如果 data 為空陣列[],表示沒有符合的搜尋結果

{
    "data": [
        {
            "id": 1,
            "name": "富邦集團",
            "first_name": "富邦集團",
            "last_name": null,
            "membership_no": null,
            "identity_no": "A0058",
            "gender": null,
            "birth_at": null,
            "profile_id": 1,
            "profile": {
                "id": 1,
                "phones": []
            },
            "sponsor_id": null,
            "disturb_setting": null,
            "file_entities_count": 0,
            "created_at": "2019-11-14 16:34:30",
            "updated_at": "2019-11-14 16:34:30"
        }
    ],
    "links": {
        "first": "https://firstline.localhost/api/v1/contact?page=1",
        "last": "https://firstline.localhost/api/v1/contact?page=1",
        "prev": null,
        "next": null
    },
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 1,
        "path": "https://firstline.localhost/api/v1/contact",
        "per_page": 15,
        "to": 1,
        "total": 1
    }
}

建立客戶

請求網址 POST https://firstline.localhost/api/v1/contact

參數

{
    "first_name": "88888888",
    "last_name": "富邦媒體科技股份有限公司",
    "identity_no": "A0058",
    "cz_cols": [
        {
            "id": 1, // 供應商類型
            "value": "一般供應商",
        },
        {
            "id": 2, // 往來狀態
            "value": "正常",
        },
        {
            "id": 4, // AM員編
            "value": "07777",
        },
        {
            "id": 5, // AM名稱
            "value": "凌凌七",
        },
        {
            "id": 9, // 供應商等級
            "value": "AA",
        },
    ]
}

response

{
    "id": 1,
    "name": "88888888 富邦媒體科技股份有限公司",
    "first_name": "88888888",
    "last_name": "富邦媒體科技股份有限公司",
    "membership_no": null,
    "identity_no": "A0058",
    "gender": null,
    "birth_at": null,
    "profile_id": 1,
    "profile": {
        "id": 1,
        "phones": []
    },
    "sponsor_id": null,
    "disturb_setting": null,
    "file_entities_count": 0,
    "created_at": "2019-11-14 16:34:30",
    "updated_at": "2019-11-14 16:34:30"
}

更新客戶

請求網址

和新增不同的地方在於 /contact => /contact/1

PUT https://firstline.localhost/api/v1/contact/1

參數

{
    "first_name": "88888888",
    "last_name": "富邦媒體科技股份有限公司",
    "identity_no": "A0058",
    "cz_cols": [
        {
            "id": 1, // 供應商類型
            "value": "一般供應商",
        },
        {
            "id": 2, // 往來狀態
            "value": "正常",
        },
        {
            "id": 4, // AM員編
            "value": "07777",
        },
        {
            "id": 5, // AM名稱
            "value": "凌凌七",
        },
        {
            "id": 9, // 供應商等級
            "value": "AA",
        },
    ]
}

response

{
    "id": 1,
    "name": "88888888 富邦媒體科技股份有限公司",
    "first_name": "88888888",
    "last_name": "富邦媒體科技股份有限公司",
    "membership_no": null,
    "identity_no": "A0058",
    "gender": null,
    "birth_at": null,
    "profile_id": 1,
    "profile": {
        "id": 1,
        "phones": []
    },
    "sponsor_id": null,
    "disturb_setting": null,
    "file_entities_count": 0,
    "created_at": "2019-11-14 16:34:30",
    "updated_at": "2019-11-14 17:34:30"
}

電話

尋找客戶已註冊的電話

請求網址

GET https://firstline.localhost/api/v1/phone-number

參數

{
    "contact_id": 1,
    "type": 0,
    "description": "001 - 負責人 - 林啟峰"
}

response

如果 data 為空陣列[],表示沒有符合的搜尋結果。

若回傳的 data 包含有目標電話,則對其進行 更新電話, 若否則進行 對客戶添加電話

{
    "data": [
        {
            "id": 413024, // PhoneNumber (電話) 的 id
            "type": 0, // 電話的類型
            "extension": null, // 電話的分機
            "number": "0221626688", // 電話的號碼
            "description": "001 - 負責人 - 林啟峰", // 電話的備註
            "phone_contact": { // 可忽略
                "id": 125011,
                "contact_id": 1,
                "phone_number_id": 413024,
                "is_visible": true
            }
        }
    ],
    "links": {
        "first": "https://firstline-ap.momoshop.com.tw/api/phone-number?page=1",
        "last": "https://firstline-ap.momoshop.com.tw/api/phone-number?page=1",
        "prev": null,
        "next": null
    },
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 1,
        "path": "https://firstline-ap.momoshop.com.tw/api/phone-number",
        "per_page": 15,
        "to": 1,
        "total": 1
    }
}

對客戶添加電話

請求網址

POST https://firstline.localhost/api/v1/phone-number

參數

{
    "profile_id": 1,
    "number": "0939160705",
    "type": 1, // 0: 住家, 1: 公司, 2: 手機, 3: 傳真, 4: 其他
    "extension": null,
    "description": "021 - 承辦人 - 小明"
}

response

{
    "data": {
        "id": 1,
        "type": 1,
        "extension": null,
        "number": "0939160705",
        "description": "021 - 承辦人 - 小明",
        "profile_id": 1
    }
}

更新電話

請求網址

PUT https://firstline.localhost/api/v1/phone-number/{phone_number}

{phone_number} 為 電話 的 id,可參考 277 行

參數

{
    "profile_id": 1,
    "number": "0939160705",
    "type": 1, // 0: 住家, 1: 公司, 2: 手機, 3: 傳真, 4: 其他
    "extension": null,
    "description": "021 - 承辦人 - 小明"
}

response

{
    "data": {
        "id": 413029,
        "type": 1,
        "extension": null,
        "number": "0939160705",
        "description": "021 - 承辦人 - 小明",
        "profile_id": 1
    }
}

Email

尋找客戶已註冊的Email

請求網址

GET https://firstline.localhost/api/v1/email-contact

參數

{
    "contact_id": 1,
    "description": "002 - 業務承辦人 - 許悅德"
}

response

如果 data 為空陣列[],表示沒有符合的搜尋結果。

若回傳的 data 包含有目標電話,則對其進行 更新電話, 若否則進行 對客戶添加電話

{
    "data": [
        {
            "id": 225042, // 電子信箱的id
            "address": "[email protected]", // 電子信箱的地址
            "contact_id": 1, // 關聯的客戶之 id
            "draft": null, // 可忽略
            "name": null, // 可忽略
            "description": "002 - 業務承辦人 - 許悅德", // {承辦人序號}-{承辦人類型}-{承辦人名稱}
            "contact": { // 客戶資訊
                "id": 1,
                "membership_no": null,
                "identity_no": "000001",
                "first_name": "富邦媒體科技股份有限公司",
                "last_name": "富邦媒體科技股份有限公司",
                "gender": null,
                "birth_at": null,
                "created_at": "2019-11-06 15:51:11",
                "updated_at": "2019-11-06 15:51:38",
                "profile_id": 74803,
                "sponsor_id": null,
                "disturb_setting": null
            }
        }
    ],
    "links": {
        "first": "https://firstline-ap.momoshop.com.tw/api/email-contact?page=1",
        "last": "https://firstline-ap.momoshop.com.tw/api/email-contact?page=1",
        "prev": null,
        "next": null
    },
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 1,
        "path": "https://firstline-ap.momoshop.com.tw/api/email-contact",
        "per_page": 15,
        "to": 1,
        "total": 1
    }
}

對客戶添加Email

請求網址

POST https://firstline.localhost/api/v1/email-contact

參數

{
    "contact_id": 1,
    "address": "[email protected]",
    "description": "021 - 承辦人 - 小明"
}

response

{
    "data": {
        "id": 1,
        "address": "[email protected]",
        "contact_id": 1,
        "draft": null,
        "name": "021 - 承辦人 - 小明",
        "description": null,
        "contact": {
            "id": 1,
            "membership_no": null,
            "identity_no": "000001",
            "first_name": "富邦媒體科技股份有限公司",
            "last_name": "富邦媒體科技股份有限公司",
            "gender": null,
            "birth_at": null,
            "created_at": "2019-11-06 15:51:11",
            "updated_at": "2019-11-06 15:51:38",
            "profile_id": 74803,
            "sponsor_id": null,
            "disturb_setting": null
        }
    }
}

更新Email

請求網址

PUT https://firstline.localhost/api/v1/email-contact/{email_contact}

{email_contact} 為 Email 的 id,可參考 480 行

參數

{
    "contact_id": 1,
    "address": "[email protected]",
    "description": "022 - 承辦人 - 小華"
}

response

{
    "data": {
        "id": 1,
        "address": "[email protected]",
        "contact_id": 1,
        "draft": null,
        "name": "022 - 承辦人 - 小華",
        "description": null,
        "contact": {
            "id": 1,
            "membership_no": null,
            "identity_no": "000001",
            "first_name": "富邦媒體科技股份有限公司",
            "last_name": "富邦媒體科技股份有限公司",
            "gender": null,
            "birth_at": null,
            "created_at": "2019-11-06 15:51:11",
            "updated_at": "2019-11-06 15:51:38",
            "profile_id": 74803,
            "sponsor_id": null,
            "disturb_setting": null
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment