wjx hace 1 semana
padre
commit
bb75b92dcd

+ 50 - 4
src/pages/launchSystemV3/account/index.tsx

@@ -4,11 +4,11 @@ import { Col, Modal, Row, Input, message, Space, Tabs, Button, Select } from 'an
 import React, { useCallback, useEffect, useState } from 'react'
 import { columnsMp } from './tableConfig'
 import { useAjax } from '@/Hook/useAjax'
-import { getAdAccountListApi, GetAdAccountParams, putAdAccountApi } from '@/services/launchAdq/adAuthorize'
+import { getAdAccountListApi, GetAdAccountParams, getAuthInfoApi, putAdAccountApi, setAuthSuccessApi } from '@/services/launchAdq/adAuthorize'
 import style from './index.less'
 import TableData from '@/pages/launchSystemNew/components/TableData'
 import GroupLeft from './groupLeft'
-import { MenuFoldOutlined, MenuUnfoldOutlined, PlusOutlined, SwapOutlined } from '@ant-design/icons'
+import { ExclamationCircleOutlined, MenuFoldOutlined, MenuUnfoldOutlined, PlusOutlined, SafetyOutlined, SwapOutlined } from '@ant-design/icons'
 import { getAdAccountAllOfMember, getErpUserAll, getServiceProviderAll, putConfigServiceProvider, putRefreshTokenApi } from '@/services/launchAdq/adq'
 import AddAccountToGroup from './addAccountToGroup'
 import { delAccountToGroupApi } from '@/services/launchAdq/subgroup'
@@ -17,9 +17,10 @@ import ChangeRecord from './changeRecord'
 import CheckAccount from './checkAccount'
 import AppointPut from './appointPut'
 import SetEarlyWarningsAccount from '@/components/EarlyWarning/setEarlyWarningsAccount'
-import { AdUnitType_Enum } from './const'
 import TeamMembers from '@/pages/launchSystemNew/components/teamMembers'
 import QQAuth from '@/pages/launchSystemNew/account/components/qqAuto'
+import { history } from 'umi';
+import moment from 'moment'
 
 /** 投放管理 */
 const AdAuthorize: React.FC = () => {
@@ -58,10 +59,14 @@ const AdAuthorize: React.FC = () => {
     const [selectAccData, setSelectAccData] = useState<any[]>([])
     const [puShow, setPuShow] = useState<boolean>(false)
     const [puData, setPuData] = useState<any[]>([])
+    const [expireTime, setExpireTime] = useState<string>()
+    const [tokenStatus, setTokenStatus] = useState<string>('normal')
     const [switchType, setSwitchType] = useState<'account' | 'putUser' | 'setServer' | 'refreshToken'>('account')
     const putRemark = useAjax((adAccountId: any, remark: any) => putAdAccountApi(adAccountId, remark))
     const delAccountToGroup = useAjax((params) => delAccountToGroupApi(params))
     const getAdAccountList = useAjax((params) => getAdAccountListApi(params), { formatResult: true })
+    const setAuthSuccess = useAjax((params) => setAuthSuccessApi(params), { formatResult: true })
+    const getAuthInfo = useAjax(() => getAuthInfoApi(), { formatResult: true })
     const allOfMember = useAjax(() => getAdAccountAllOfMember(), { formatResult: true })
     const erpUserALL = useAjax(() => getErpUserAll(), { formatResult: true })
     const api_getServiceProviderAll = useAjax(() => getServiceProviderAll(), { formatResult: true })
@@ -69,8 +74,39 @@ const AdAuthorize: React.FC = () => {
     const putRefreshToken = useAjax((params) => putRefreshTokenApi(params), { formatResult: true })
     /*************************/
 
+    useEffect(() => {
+        const query = history.location.query
+        if (query?.user_token && query?.user_status && query?.wx_id) {
+            setAuthSuccess.run({
+                userStatus: query.user_status, userToken: query.user_token, expireTime: query.expire_time, wxId: query.wx_id, state: query?.state
+            }).then(() => {
+                message.success('授权成功', () => {
+                    location.href = window.location.href.split('?')[0]
+                    location.reload()
+                })
+            })
+        } else {
+            message.error('授权失败')
+        }
+    }, [])
+
     useEffect(() => {
         groupListInit()
+        getAuthInfo.run().then(res => {
+            if (res?.data?.expireTime && moment(res?.data?.expireTime) > moment()) {
+                setExpireTime(res?.data?.expireTime)
+                setTokenStatus(res?.data?.tokenStatus)
+            } else {
+                Modal.confirm({
+                    title: '授权',
+                    icon: <ExclamationCircleOutlined />,
+                    content: '授权已过期,请重新授权!',
+                    onOk() {
+                        window.open(`https://ad.qq.com/account-center/single/user-authorize?redirect_uri=${encodeURIComponent(location.href)}&state=${encodeURIComponent(1)}`, '_blank')
+                    }
+                });
+            }
+        })
         !erpUserALL.data && erpUserALL.run()
         !api_getServiceProviderAll.data && api_getServiceProviderAll.run()
     }, [])
@@ -164,9 +200,19 @@ const AdAuthorize: React.FC = () => {
             activeKey={activeKey}
             type="card"
             // tabBarExtraContent={<Button type='primary' onClick={()=>setVisible(true)}><PlusOutlined />广告账号授权</Button>}
+            tabBarExtraContent={<Button
+                type='primary'
+                loading={getAuthInfo.loading}
+                style={['expire', 'no', 'will_expire'].includes(tokenStatus) ? {
+                    backgroundColor: ['expire', 'no'].includes(tokenStatus) ? '#ff4d4f' : '#faad14',
+                    borderColor: ['expire', 'no'].includes(tokenStatus) ? '#ff4d4f' : '#faad14'
+                } : {}}
+                icon={<SafetyOutlined />}
+                onClick={() => window.open(`https://ad.qq.com/account-center/single/user-authorize?redirect_uri=${encodeURIComponent(location.href)}&state=${encodeURIComponent(1)}`, '_blank')}
+            >投放人员授权{expireTime ? `,到期时间:${expireTime}` : ''}</Button>}
             onChange={(activeKey) => {
                 if (activeKey !== 'contract') {
-                    let newQueryForm = JSON.parse(JSON.stringify(queryForm))
+                    const newQueryForm = JSON.parse(JSON.stringify(queryForm))
                     delete newQueryForm?.groupId
                     delete newQueryForm?.putUserId
                     setQueryForm(newQueryForm)

+ 2 - 50
src/pages/launchSystemV3/monitorEWList/astraGroupHourEle.tsx

@@ -61,39 +61,6 @@ const AstraGroupHourEle: React.FC<AstraGroupHourProps> = ({ localCsgroupName, da
                             return <span style={{ fontSize: 12 }}>{value}</span>
                         },
                     },
-                    // {
-                    //     title: '消耗',
-                    //     dataIndex: 'cost',
-                    //     key: 'cost',
-                    //     width: 80,
-                    //     sorter: (a, b) => a.cost - b.cost,
-                    //     align: 'right',
-                    //     render(value) {
-                    //         return <Statistic value={value || 0} />
-                    //     },
-                    // },
-                    // {
-                    //     title: '加粉次数(广告)',
-                    //     dataIndex: 'scanFollowCount',
-                    //     key: 'scanFollowCount',
-                    //     width: 80,
-                    //     sorter: (a, b) => a.scanFollowCount - b.scanFollowCount,
-                    //     align: 'right',
-                    //     render(value) {
-                    //         return <span style={{ fontSize: 12 }}>{value}</span>
-                    //     },
-                    // },
-                    // {
-                    //     title: '加粉人数(广告)',
-                    //     dataIndex: 'scanFollowUserCount',
-                    //     key: 'scanFollowUserCount',
-                    //     width: 80,
-                    //     sorter: (a, b) => a.scanFollowUserCount - b.scanFollowUserCount,
-                    //     align: 'right',
-                    //     render(value) {
-                    //         return <span style={{ fontSize: 12 }}>{value}</span>
-                    //     },
-                    // },
                     {
                         title: '加粉人数',
                         dataIndex: 'addUserCount',
@@ -119,15 +86,9 @@ const AstraGroupHourEle: React.FC<AstraGroupHourProps> = ({ localCsgroupName, da
                 ]}
                 pagination={false}
                 summary={pageData => {
-                    let totalCost = 0;
-                    let totalScanFollowCount = 0;
-                    let totalScanFollowUserCount = 0;
                     let totalAddUserCount = 0;
 
-                    pageData.forEach(({ cost, scanFollowCount, scanFollowUserCount, addUserCount }) => {
-                        totalCost += cost;
-                        totalScanFollowCount += scanFollowCount;
-                        totalScanFollowUserCount += scanFollowUserCount;
+                    pageData.forEach(({ addUserCount }) => {
                         totalAddUserCount += addUserCount;
                     });
 
@@ -137,18 +98,9 @@ const AstraGroupHourEle: React.FC<AstraGroupHourProps> = ({ localCsgroupName, da
                                 <Table.Summary.Cell index={0} align="center"><Text strong>总计</Text></Table.Summary.Cell>
                                 <Table.Summary.Cell index={1} align="center">--</Table.Summary.Cell>
                                 <Table.Summary.Cell index={2} align="right">
-                                    <Text strong>{totalCost}</Text>
-                                </Table.Summary.Cell>
-                                <Table.Summary.Cell index={3} align="right">
-                                    <Text strong>{totalScanFollowCount}</Text>
-                                </Table.Summary.Cell>
-                                <Table.Summary.Cell index={4} align="right">
-                                    <Text strong>{totalScanFollowUserCount}</Text>
-                                </Table.Summary.Cell>
-                                <Table.Summary.Cell index={5} align="right">
                                     <Text strong>{totalAddUserCount}</Text>
                                 </Table.Summary.Cell>
-                                <Table.Summary.Cell index={6} align="center">--</Table.Summary.Cell>
+                                <Table.Summary.Cell index={3} align="center">--</Table.Summary.Cell>
                             </Table.Summary.Row>
                         </Table.Summary>
                     );

+ 0 - 33
src/pages/launchSystemV3/monitorEWList/astraGroupIndexEle.tsx

@@ -61,39 +61,6 @@ const AstraGroupIndexEle: React.FC<AstraGroupHourProps> = ({ localCsgroupName, d
                             return <span style={{ fontSize: 12 }}>{value}</span>
                         },
                     },
-                    // {
-                    //     title: '消耗',
-                    //     dataIndex: 'cost',
-                    //     key: 'cost',
-                    //     width: 80,
-                    //     sorter: true,
-                    //     align: 'right',
-                    //     render(value) {
-                    //         return <Statistic value={value || 0} />
-                    //     },
-                    // },
-                    // {
-                    //     title: '加粉次数(广告)',
-                    //     dataIndex: 'scanFollowCount',
-                    //     key: 'scanFollowCount',
-                    //     width: 80,
-                    //     sorter: true,
-                    //     align: 'right',
-                    //     render(value) {
-                    //         return <span style={{ fontSize: 12 }}>{value}</span>
-                    //     },
-                    // },
-                    // {
-                    //     title: '加粉人数(广告)',
-                    //     dataIndex: 'scanFollowUserCount',
-                    //     key: 'scanFollowUserCount',
-                    //     width: 80,
-                    //     sorter: true,
-                    //     align: 'right',
-                    //     render(value) {
-                    //         return <span style={{ fontSize: 12 }}>{value}</span>
-                    //     },
-                    // },
                     {
                         title: '加粉人数',
                         dataIndex: 'addUserCount',

+ 0 - 22
src/services/adqV3/global.ts

@@ -1614,28 +1614,6 @@ export async function addBatchCreativeComponentApi(data: AddBatchCreativeCompone
     })
 }
 
-/**
- * 查询业务单元共享状态
- * @returns 
- */
-export async function getDefaultSharingApi(params: { adAccountId: number }) {
-    return request(api + `/adq/creative/component/getDefaultSharing/${params.adAccountId}`, {
-        method: 'GET'
-    })
-}
-
-/**
- * 修改业务单元组件共享状态
- * @param params 
- * @returns 
- */
-export async function updateDefaultSharingApi(params: { adAccountId: number, type: string }) {
-    return request(api + `/adq/creative/component/updateDefaultSharing`, {
-        method: 'POST',
-        params
-    })
-}
-
 /**
  * 删除组件
  * @param params 

+ 22 - 0
src/services/launchAdq/adAuthorize.ts

@@ -23,6 +23,28 @@ export async function getAdAccountListApi(data: GetAdAccountParams) {
     });
 }
 
+/**
+ * 授权详情
+ * @returns 
+ */
+export async function getAuthInfoApi() {
+    return request(api + '/adq/userRealnameAuth/authInfo', {
+        method: 'GET'
+    });
+}
+
+/**
+ * 授权成功
+ * @param data 
+ * @returns 
+ */
+export async function setAuthSuccessApi(data: { userStatus: number, userToken: string, expireTime: number, wxId: string, state: any }) {
+    return request(api + '/adq/userRealnameAuth/authSuccess', {
+        method: 'PUT',
+        data
+    });
+}
+
 export async function getAdAccountGameListApi(data: GetAdAccountParams) {
     return request(api + '/adq/adAccount/accountListOfGame', {
         method: 'POST',