Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
liexin_supplier
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
daad3722
authored
Jun 02, 2022
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
数据导入脚本
parent
96a132f1
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
326 additions
and
574 deletions
app/Console/Commands/SetSupplierFollowUp.php
app/Http/Controllers/SupplierAccountController.php
app/Http/Services/AdminUserService.php
app/Http/Services/DataService.php
app/Http/Services/SupplierService.php
app/Http/function.php
app/Http/routes.php
public/data/supplier_group.xlsx
public/data/猎芯网qc检验记录 - 副本.xlsx:Zone.Identifier
app/Console/Commands/SetSupplierFollowUp.php
View file @
daad3722
...
...
@@ -35,7 +35,9 @@ class SetSupplierFollowUp extends Command
// $service->importSupplierLevel();
// $service->changeSupplierTypeByIsType();
// $service->transferPayType();
$service
->
makeTempTagForSupplier
();
$service
->
importSupplierGroup
(
true
);
// $service->changeSupplierType();
// $service->generateYunxinAccount(false);
// $service->makeSupplierSystemTagAbnormal();
}
}
app/Http/Controllers/SupplierAccountController.php
View file @
daad3722
...
...
@@ -68,7 +68,7 @@ class SupplierAccountController extends Controller
{
$id
=
$request
->
get
(
'id'
);
$model
=
new
SupplierAccountModel
();
$account
=
$model
->
where
(
'id'
,
$id
)
->
first
()
->
toArray
();
$account
=
$model
->
where
(
'id'
,
$id
)
->
first
()
->
toArray
();
//获取所有启用的供应商编码,而且类型是包括云芯
$model
=
new
SupplierChannelModel
();
$suppliers
=
$model
->
where
(
'is_type'
,
0
)
...
...
app/Http/Services/AdminUserService.php
View file @
daad3722
...
...
@@ -20,6 +20,13 @@ class AdminUserService
return
$userInfoModel
->
where
(
'userId'
,
$adminId
)
->
first
();
}
public
function
getCodeIdByUserName
(
$userName
)
{
$userId
=
UserInfoModel
::
where
(
'name'
,
$userName
)
->
value
(
'userId'
);
$codeId
=
IntracodeModel
::
where
(
'admin_id'
,
$userId
)
->
value
(
'code_id'
);
return
$codeId
;
}
public
function
getCodeIdsByUserIds
(
$userIds
)
{
$intraCodeModel
=
new
IntracodeModel
();
...
...
app/Http/Services/DataService.php
View file @
daad3722
...
...
@@ -9,6 +9,7 @@ use App\Model\IntracodeModel;
use
App\Model\LogModel
;
use
App\Model\RedisModel
;
use
App\Model\StandardBrandModel
;
use
App\Model\SupplierAccountModel
;
use
App\Model\SupplierAttachmentModel
;
use
App\Model\SupplierAttachmentsModel
;
use
App\Model\SupplierChannelModel
;
...
...
@@ -17,6 +18,7 @@ use App\Model\SupplierPayTypeModel;
use
Carbon\Carbon
;
use
GuzzleHttp\Client
;
use
GuzzleHttp\RequestOptions
;
use
Illuminate\Support\Facades\Hash
;
use
Illuminate\Support\Facades\Log
;
use
Illuminate\Support\Facades\Redis
;
use
Maatwebsite\Excel\Facades\Excel
;
...
...
@@ -63,598 +65,277 @@ class DataService
}
}
//20210722
//转移文件数据(之前是只存到一个字段,现在要存到一张表里面去)
public
function
transferFileData
()
{
//先找出所有上传文件非空的供应商
$model
=
new
SupplierChannelModel
();
$suppliers
=
$model
->
where
(
'qualification_photos'
,
'!='
,
''
)
->
get
()
->
toArray
();
$attachmentModel
=
new
SupplierAttachmentModel
();
foreach
(
$suppliers
as
$key
=>
$supplier
)
{
$supplierId
=
$supplier
[
'supplier_id'
];
$files
=
json_decode
(
$supplier
[
'qualification_photos'
],
true
);
$count
=
$attachmentModel
->
where
(
'supplier_id'
,
$supplierId
)
->
count
();
if
(
!
$count
)
{
foreach
(
$files
as
$key
=>
&
$file
)
{
if
(
empty
(
$file
[
'url'
])
&&
empty
(
$file
[
'file_name'
]))
{
$file
=
''
;
}
}
unset
(
$file
);
$business_license
=
array_get
(
$files
,
'business_license'
);
$billing_information
=
array_get
(
$files
,
'billing_information'
);
$registration_certificate
=
array_get
(
$files
,
'registration_certificate'
);
$incorporation_certificate
=
array_get
(
$files
,
'incorporation_certificate'
);
$certification_notice
=
array_get
(
$files
,
'certification_notice'
);
$supplier_survey
=
array_get
(
$files
,
'supplier_survey'
);
$proxy_certificate
=
array_get
(
$files
,
'proxy_certificate'
);
$quality_assurance_agreement
=
array_get
(
$files
,
'quality_assurance_agreement'
);
$confidentiality_agreement
=
array_get
(
$files
,
'confidentiality_agreement'
);
$cooperation_agreement
=
array_get
(
$files
,
'cooperation_agreement'
);
$other_attachment
=
array_get
(
$files
,
'other_attachment'
);
$attachment
=
[
'business_license'
=>
$business_license
?
[
$business_license
]
:
''
,
'billing_information'
=>
$billing_information
?
[
$billing_information
]
:
''
,
'registration_certificate'
=>
$registration_certificate
?
[
$registration_certificate
]
:
''
,
'incorporation_certificate'
=>
$incorporation_certificate
?
[
$incorporation_certificate
]
:
''
,
'certification_notice'
=>
$certification_notice
?
[
$certification_notice
]
:
''
,
'supplier_survey'
=>
$supplier_survey
?
[
$supplier_survey
]
:
''
,
'proxy_certificate'
=>
$proxy_certificate
?
[
$proxy_certificate
]
:
''
,
'quality_assurance_agreement'
=>
$quality_assurance_agreement
?
[
$quality_assurance_agreement
]
:
''
,
'confidentiality_agreement'
=>
$confidentiality_agreement
?
[
$confidentiality_agreement
]
:
''
,
'cooperation_agreement'
=>
$cooperation_agreement
?
[
$cooperation_agreement
]
:
''
,
'other_attachment'
=>
$other_attachment
?
[
$other_attachment
]
:
''
,
'create_time'
=>
time
(),
'update_time'
=>
time
(),
'supplier_id'
=>
$supplierId
,
];
$attachment
=
array_filter
(
$attachment
,
function
(
$item
)
{
return
!
empty
(
$item
);
});
$attachment
=
array_map
(
function
(
$item
)
{
return
json_encode
(
$item
);
},
$attachment
);
$attachmentModel
->
insert
(
$attachment
);
}
}
}
//历史数据处理
public
function
changeSupplierIsTypeByCheckChannelUidOrPurchaseUid
()
{
$model
=
new
SupplierChannelModel
();
$suppliers
=
$model
->
where
(
function
(
$q
)
{
$q
->
where
(
'channel_uid'
,
'!='
,
''
)
->
orWhere
(
'purchase_uid'
,
'!='
,
''
);
})
->
where
(
'is_type'
,
1
)
->
get
()
->
toArray
();
// dd(count($suppliers));
if
(
count
(
$suppliers
)
>
1670
)
{
dd
(
"数量有问题"
);
}
$redis
=
new
RedisModel
();
//非正式供应商中存在渠道员/采购员,将供应商改为正式供应商
foreach
(
$suppliers
as
$supplier
)
{
//先查询是否有重复的供应商
$count
=
$model
->
where
(
'supplier_name'
,
$supplier
[
'supplier_name'
])
->
count
();
if
(
$count
>
1
)
{
dd
(
$supplier
[
'supplier_name'
]);
continue
;
}
//同时记录被修改的supplier_id列表到redis以防万一
$redis
->
hset
(
'lie_change_is_type_suppliers'
,
$supplier
[
'supplier_id'
],
json_encode
(
$supplier
));
//没有的话直接修改成待审核,并且转正
$model
->
where
(
'supplier_id'
,
$supplier
[
'supplier_id'
])
->
update
([
// 'update_time' => time(),
'is_type'
=>
0
,
'status'
=>
0
]);
}
}
const
TYPE_YC
=
4
;
const
TYPE_DLS
=
1
;
const
TYPE_MYS
=
2
;
//
替换老的品牌选择成为新的标准品牌id
public
function
replaceStandardBrandId
()
//
供应商类型修改
public
function
changeSupplierType
()
{
$supplierModel
=
new
SupplierChannelModel
();
$suppliers
=
$supplierModel
->
where
(
'main_brands'
,
'!='
,
''
)
->
get
()
->
toArray
();
$redis
=
new
RedisModel
();
foreach
(
$suppliers
as
$supplier
)
{
$mainBrands
=
explode
(
','
,
$supplier
[
'main_brands'
]);
$standardBrandIds
=
[];
foreach
(
$mainBrands
as
$brandId
)
{
//找标准品牌ID,没有直接跳过
$standardBrandId
=
$redis
->
hget
(
'standard_brand_mapping'
,
$brandId
);
if
(
empty
(
$standardBrandId
)
or
empty
(
$brandId
))
{
continue
;
}
$standardBrandIds
[]
=
$standardBrandId
;
}
print_r
(
$mainBrands
);
print_r
(
$standardBrandIds
);
echo
PHP_EOL
;
if
(
!
empty
(
$standardBrandIds
))
{
$standardBrandIdsStr
=
implode
(
','
,
$standardBrandIds
);
}
else
{
$standardBrandIdsStr
=
''
;
}
$supplierModel
->
where
(
'supplier_id'
,
$supplier
[
'supplier_id'
])
->
update
([
'main_brands'
=>
$standardBrandIdsStr
]);
}
}
ini_set
(
'memory_limit'
,
-
1
);
//统一修改掉状态先
(
new
SupplierChannelModel
)
->
where
(
'supplier_id'
,
'>'
,
0
)
->
update
([
'outside_contact_type'
=>
0
]);
//导入黑名单供应商(前提是不存在)
public
function
importBlockSupplier
()
{
$supplierNames
=
[
'Electronics Depot'
,
'Assured Electronics Corp.'
,
'深圳市力特电子有限公司'
,
'深圳市铭盛微电子科技有限公司'
,
'Aegis Components Inc'
,
'深圳市亿博创电子公司'
,
//先将真实对接的供应商修改状态
$realApiSupplierCodes
=
[
'L0000266'
,
'L0000198'
,
'L0000273'
,
'L0000135'
,
'L0000135'
,
'L0005966'
,
'L0000004'
,
'L0006149'
,
'L0006150'
,
'L0006155'
,
'L0007637'
,
'L0006148'
,
'L0006151'
,
'L0006147'
,
'L0007639'
,
'L0007640'
,
'L0007646'
,
'L0007648'
,
'L0007650'
,
'L0007653'
,
'L0000089'
,
'L0007633'
,
'L0007663'
,
'L0010826'
,
'L0010856'
,
'L0010937'
,
'L0007595'
,
'L0011054'
,
'L0004938'
,
'L0011040'
,
'L0001175'
,
'L0007243'
,
'L0011042'
,
];
//构建插入数据
$supplierModel
=
new
SupplierChannelModel
();
foreach
(
$supplierNames
as
$supplierName
)
{
$supplierName
=
trim
(
$supplierName
);
$exist
=
$supplierModel
->
where
(
'supplier_name'
,
$supplierName
)
->
count
();
if
(
!
$exist
)
{
$insertData
=
[
'supplier_name'
=>
$supplierName
,
'create_uid'
=>
1000
,
'create_time'
=>
time
(),
'status'
=>
$supplierModel
::
STATUS_BLOCK
,
'is_type'
=>
0
,
'create_name'
=>
'admin'
,
'block_reason'
=>
'系统拉黑'
,
];
$supplierId
=
$supplierModel
->
insertGetId
(
$insertData
);
$supplierService
=
new
SupplierService
();
$supplierService
->
saveSupplierCode
(
$supplierId
);
}
}
}
//给特定类型的供应商打上标签
//找出 国内/港台 + 现货商性质的,而且没有上传品质协议的供应商,自动打上临时供应商标签
public
function
makeSupplierSystemTag
()
{
$channelModel
=
new
SupplierChannelModel
();
$suppliers
=
$channelModel
->
leftjoin
(
'supplier_attachment'
,
'supplier_channel.supplier_id'
,
'='
,
'supplier_attachment.supplier_id'
)
->
whereIn
(
'region'
,
[
2
,
4
])
->
where
(
'supplier_group'
,
2
)
->
where
(
'quality_assurance_agreement'
,
''
)
->
where
(
'system_tags'
,
'not like'
,
'%临时供应商%'
)
->
get
()
->
toArray
();
$tagService
=
new
SupplierTagService
();
//找到后打上标签
foreach
(
$suppliers
as
$supplier
)
{
$supplierId
=
$supplier
[
'supplier_id'
];
$oldTags
=
$supplier
[
'system_tags'
];
$newTags
=
$supplier
[
'system_tags'
]
?
rtrim
(
$supplier
[
'system_tags'
],
','
)
.
',临时供应商'
:
'临时供应商'
;
if
(
$tagService
->
saveTags
(
$supplierId
,
14
,
$newTags
,
$oldTags
))
{
$channelModel
->
where
(
'supplier_id'
,
$supplierId
)
->
update
([
'system_tags'
=>
$newTags
]);
}
}
}
SupplierChannelModel
::
whereIn
(
'supplier_code'
,
$realApiSupplierCodes
)
->
update
([
'outside_contact_type'
=>
2
]);
//打上历史检测异常标签
public
function
makeSupplierSystemTagAbnormal
(
$change
=
false
)
{
ini_set
(
'memory_limit'
,
'-1'
);
$channelModel
=
new
SupplierChannelModel
();
//读取excel
$filePath
=
public_path
(
'data'
)
.
DIRECTORY_SEPARATOR
.
'abnormal_supplier.xlsx'
;
try
{
Excel
::
selectSheetsByIndex
(
0
)
->
load
(
$filePath
,
function
(
$reader
)
use
(
$change
)
{
$reader
->
sheet
(
'QC不良记录'
,
function
()
use
(
$reader
,
$change
)
{
$supplierModel
=
new
SupplierChannelModel
();
$suppliers
=
[];
foreach
(
$reader
->
all
()
->
toArray
()
as
$key
=>
$item
)
{
if
(
$key
==
0
||
$key
==
1
)
{
continue
;
}
$supplierName
=
trim
(
$item
[
2
]);
if
(
empty
(
$supplierName
))
{
continue
;
}
$supplier
=
$supplierModel
->
where
(
'supplier_name'
,
$supplierName
)
->
first
();
if
(
!
empty
(
$supplier
))
{
$suppliers
[]
=
$supplier
->
toArray
();
}
else
{
echo
"供应商 : "
.
$supplierName
.
"不存在,跳过"
.
PHP_EOL
;
}
}
$tagService
=
new
SupplierTagService
();
//找到后打上标签
foreach
(
$suppliers
as
$supplier
)
{
$supplierId
=
$supplier
[
'supplier_id'
];
$oldTags
=
$supplier
[
'system_tags'
];
echo
"供应商 : "
.
$supplier
[
'supplier_name'
]
.
"检测异常,需要打上标签"
.
PHP_EOL
;
if
(
strpos
(
$supplier
[
'system_tags'
],
'历史检测异常'
)
!==
false
)
{
continue
;
}
$newTags
=
$supplier
[
'system_tags'
]
?
rtrim
(
$supplier
[
'system_tags'
],
','
)
.
',历史检测异常'
:
'历史检测异常'
;
if
(
$change
)
{
if
(
$tagService
->
saveTags
(
$supplierId
,
14
,
$newTags
,
$oldTags
))
{
$supplierModel
->
where
(
'supplier_id'
,
$supplierId
)
->
update
([
'system_tags'
=>
$newTags
]);
}
}
}
});
});
}
catch
(
\Exception
$exception
)
{
dd
(
$exception
);
$suppliers
=
$this
->
getNeedDealSuppliers
();
if
(
empty
(
$suppliers
))
{
return
'供应商上传类型已经全部处理'
;
}
}
//api对接类型的供应商数量(706)
$ycApiTypeCount
=
172
;
$dlsApiTypeCount
=
207
;
$mysApiTypeCount
=
327
;
//要先找出原厂类型的API对接类型的供应商数量,然后要从库里面随机找出原厂的供应商打上类型
$this
->
dealApiSupplier
(
self
::
TYPE_YC
,
$ycApiTypeCount
);
//要先找出代理商类型的API对接类型的供应商数量,然后要从库里面随机找出代理商的供应商打上类型
$this
->
dealApiSupplier
(
self
::
TYPE_DLS
,
$dlsApiTypeCount
);
//要先找出贸易类型的API对接类型的供应商数量,然后要从库里面随机找出贸易的供应商打上类型
$this
->
dealApiSupplier
(
self
::
TYPE_MYS
,
$mysApiTypeCount
);
echo
"-------------------------"
.
PHP_EOL
;
//然后随机取出云芯的供应商(1139)
//先剔除api对接的供应商
$ycYunxinTypeCount
=
113
;
$dlsYunxinTypeCount
=
302
;
$mysYunxinTypeCount
=
724
;
$this
->
dealYunxinSupplier
(
self
::
TYPE_YC
,
$ycYunxinTypeCount
);
$this
->
dealYunxinSupplier
(
self
::
TYPE_DLS
,
$dlsYunxinTypeCount
);
$this
->
dealYunxinSupplier
(
self
::
TYPE_MYS
,
$mysYunxinTypeCount
);
echo
"-------------------------"
.
PHP_EOL
;
//剩下的都是人工上传的,也有一定占比(2658)
$ycManualTypeCount
=
20
;
$dlsManualTypeCount
=
146
;
$mysManualTypeCount
=
2492
;
$this
->
dealManualSupplier
(
self
::
TYPE_YC
,
$ycManualTypeCount
);
$this
->
dealManualSupplier
(
self
::
TYPE_DLS
,
$dlsManualTypeCount
);
$this
->
dealManualSupplier
(
self
::
TYPE_MYS
,
$mysManualTypeCount
);
//初始化供应商对应的搜索标签到redis
public
function
initSupplierSearchTags
()
{
//初始化所有正式服务器的标签情况到redis
$supplierModel
=
new
SupplierChannelModel
();
$suppliers
=
$supplierModel
->
where
(
'is_type'
,
0
)
->
get
()
->
toArray
();
$redis
=
new
RedisModel
();
foreach
(
$suppliers
as
$supplier
)
{
//1精选,2原厂直供,3认证,4猎芯自营,100无标签
$tagFlags
=
[];
//先去判断供应商性质是否为原厂,如果是的话,写入标签2
if
(
$supplier
[
'supplier_group'
]
==
4
)
{
$tagFlags
[]
=
2
;
}
if
(
$supplier
[
'has_certification'
]
==
1
)
{
$tagFlags
[]
=
3
;
}
$redis
->
hset
(
'supplier_search_tags'
,
$supplier
[
'supplier_code'
],
json_encode
([
'supplier_code'
=>
$supplier
[
'supplier_code'
],
'tags'
=>
$tagFlags
,
]));
}
}
//推送更新供应商的队列
public
function
pushSupplierSKu
()
public
function
getNeedDealSuppliers
(
$supplierGroup
=
0
,
$otherSupplierGroup
=
[])
{
$supplierModel
=
new
SupplierChannelModel
();
$suppliers
=
$supplierModel
->
where
(
'is_type'
,
0
)
->
where
(
'supplier_group'
,
4
)
->
orderBy
(
'supplier_id'
,
'desc'
)
->
limit
(
130
)
->
get
()
->
toArray
();
$redis
=
new
RedisModel
();
foreach
(
$suppliers
as
$supplier
)
{
$supplierTag
=
$redis
->
hget
(
'supplier_search_tags'
,
$supplier
[
'supplier_code'
]);
if
(
!
$supplierTag
)
{
continue
;
$query
=
SupplierChannelModel
::
where
(
'outside_contact_type'
,
0
)
->
where
(
'channel_uid'
,
'!='
,
''
)
->
where
(
'status'
,
'!='
,
-
3
)
->
whereRaw
(
'supplier_name NOT LIKE "%-1"'
)
->
where
(
'is_type'
,
0
);
if
(
!
empty
(
$otherSupplierGroup
))
{
$query
->
whereIn
(
'supplier_group'
,
$otherSupplierGroup
);
}
else
{
if
(
!
empty
(
$supplierGroup
))
{
$query
->
where
(
'supplier_group'
,
$supplierGroup
);
}
$message
=
json_encode
([
'supplier_code'
=>
$supplier
[
'supplier_code'
],
]);
$conn
=
new
AMQPStreamConnection
(
config
(
'database.connections.rabbitmq.host'
),
config
(
'database.connections.rabbitmq.port'
),
config
(
'database.connections.rabbitmq.login'
),
config
(
'database.connections.rabbitmq.password'
));
$channel
=
$conn
->
channel
();
$channel
->
queue_declare
(
'supplier_zhuanmai_update'
,
false
,
true
,
false
,
false
);
$msg
=
new
AMQPMessage
(
$message
,
array
(
'content_type'
=>
'text/plain'
));
$channel
->
basic_publish
(
$msg
,
''
,
'supplier_zhuanmai_update'
);
}
$data
=
$query
->
get
()
->
toArray
();
return
$data
;
}
//
导入主营品牌
数据
public
function
importMainBrandData
(
)
//
处理API接入的不同类型的
数据
public
function
dealApiSupplier
(
$supplierGroup
,
$totalApiTypeCount
)
{
$filePath
=
public_path
(
'data'
)
.
DIRECTORY_SEPARATOR
.
'supplier_main_brand.xlsx'
;
try
{
Excel
::
selectSheetsByIndex
(
0
)
->
load
(
$filePath
,
function
(
$reader
)
{
$reader
->
sheet
(
'产出'
,
function
()
use
(
$reader
)
{
$supplierMainBrandData
=
[];
$standardBrandModel
=
new
StandardBrandModel
();
foreach
(
$reader
->
all
()
->
toArray
()
as
$key
=>
$item
)
{
$supplierName
=
trim
(
$item
[
0
]);
$brandName
=
$item
[
1
];
$brandId
=
$standardBrandModel
->
where
(
'brand_name'
,
trim
(
$brandName
))
->
value
(
'standard_brand_id'
);
if
(
empty
(
$brandId
))
{
continue
;
}
if
(
!
isset
(
$supplierMainBrandData
[
$supplierName
]))
{
$supplierMainBrandData
[
$supplierName
][]
=
$brandId
;
}
else
{
$supplierMainBrandData
[
$supplierName
][]
=
$brandId
;
}
}
$supplierModel
=
new
SupplierChannelModel
();
foreach
(
$supplierMainBrandData
as
$supplierName
=>
$mainBrandIds
)
{
$result
=
$supplierModel
->
where
(
'supplier_name'
,
$supplierName
)
->
update
([
'main_brands'
=>
implode
(
','
,
$mainBrandIds
),
]);
if
(
$result
)
{
var_dump
(
'更新供应商主营品牌成功,供应商 : '
.
$supplierName
);
}
}
});
});
}
catch
(
\Exception
$exception
)
{
var_dump
(
$exception
);
}
}
//先找出已经存在的api对接类型的供应商数量,方便下面算出补全数量
$existApiTypeCount
=
SupplierChannelModel
::
where
(
'outside_contact_type'
,
2
)
->
where
(
'supplier_group'
,
$supplierGroup
)
->
count
();
//从excel导入供应商
public
function
importSupplier
()
{
$filePath
=
public_path
(
'data'
)
.
DIRECTORY_SEPARATOR
.
'supplier_import.xls'
;
try
{
Excel
::
selectSheetsByIndex
(
0
)
->
load
(
$filePath
,
function
(
$reader
)
{
$supplierChannelModel
=
new
SupplierChannelModel
();
$supplierService
=
new
SupplierService
();
$reader
->
sheet
(
'供应商清单'
,
function
(
$sheet
)
use
(
$reader
,
$supplierChannelModel
,
$supplierService
)
{
$number
=
0
;
foreach
(
$reader
->
all
()
->
toArray
()
as
$key
=>
$item
)
{
$supplierName
=
trim
(
$item
[
1
]);
//先去判断是否存在
$exist
=
$supplierChannelModel
->
where
(
'supplier_name'
,
$supplierName
)
->
exists
();
if
(
!
$exist
)
{
$number
++
;
//往库里面插入
$data
=
[
'supplier_name'
=>
$supplierName
,
'create_uid'
=>
1000
,
'create_time'
=>
time
(),
'status'
=>
2
,
'is_type'
=>
1
,
'create_name'
=>
'admin'
,
];
$supplierId
=
$supplierChannelModel
->
insertGetId
(
$data
);
$supplierService
->
saveSupplierCode
(
$supplierId
);
//然后修改excel
$sheet
->
cell
(
'E'
.
(
$key
+
2
),
function
(
$cell
)
{
$cell
->
setValue
(
'供应商不存在,已经新增'
);
});
}
else
{
$sheet
->
cell
(
'E'
.
(
$key
+
2
),
function
(
$cell
)
{
$cell
->
setValue
(
'供应商已经存在,不做新增'
);
});
}
}
var_dump
(
"一共新增了${number}个不存在的供应商"
);
});
})
->
store
(
'xls'
);
}
catch
(
\Exception
$exception
)
{
var_dump
(
$exception
);
}
}
echo
"API对接类型的
$supplierGroup
供应商数量一共要有数量 : "
.
$totalApiTypeCount
.
PHP_EOL
;
/*
* 供应商0.5版本下面需要跑的数据方法
* */
echo
"已经存在的API对接类型的
$supplierGroup
供应商数量 : "
.
$existApiTypeCount
.
PHP_EOL
;
//剩下就要补全
$needAddApiTypeCount
=
$totalApiTypeCount
-
$existApiTypeCount
;
//临时供应商标记以及等级切换
public
function
makeTempTagForSupplier
(
$change
=
false
)
{
/*
创建时间为2021-06-01开始截至现在,供应商类别为正式/临时,供应商性质为现货商,且没有上传品质协议,系统标签需要贴【临时供应商标签】,等级标记为E
创建时间为空,不在上述供应商集内
*/
$time
=
strtotime
(
"2021-06-01"
);
$suppliers
=
SupplierChannelModel
::
where
(
'create_time'
,
'>'
,
$time
)
->
where
(
'is_type'
,
0
)
->
where
(
'create_time'
,
'!='
,
0
)
->
get
();
foreach
(
$suppliers
as
$supplier
)
{
$supplierId
=
$supplier
[
'supplier_id'
];
//判断是否有上传品质协议
$hasQualityAssuranceAgreement
=
SupplierAttachmentModel
::
where
(
'supplier_id'
,
$supplierId
)
->
value
(
'quality_assurance_agreement'
);
//供应商性质为现货商,且没有上传品质协议,系统标签需要贴【临时供应商标签】,等级标记为E
if
(
!
$hasQualityAssuranceAgreement
&&
$supplier
[
'supplier_group'
]
==
2
)
{
// if ($supplier['level'] != '' && $supplier['level'] != 'E') {
// echo "供应商编码 ${supplier['supplier_code']} 已经有等级${supplier['level']},但是不为等级E,跳过" . PHP_EOL;
// continue;
// }
echo
"供应商编码 ${supplier['supplier_code']} 转换为临时供应商"
.
PHP_EOL
;
if
(
$change
)
{
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplierId
)
->
update
([
'supplier_type'
=>
2
]);
}
}
echo
"需要补全API对接类型的
$supplierGroup
供应商数量 :"
.
$needAddApiTypeCount
.
PHP_EOL
;
if
(
$needAddApiTypeCount
<=
0
)
{
return
;
}
}
//将非正式供应商(is_type=1)的类别设置为待转正
public
function
changeSupplierTypeByIsType
()
{
SupplierChannelModel
::
where
(
'supplier_id'
,
13038
)
->
update
([
'supplier_type'
=>
1
]);
$suppliers
=
$this
->
getNeedDealSuppliers
(
$supplierGroup
);
echo
"供应商性质
$supplierGroup
可操作供应商数量 :"
.
count
(
$suppliers
)
.
PHP_EOL
;
if
(
!
count
(
$suppliers
))
{
return
;
}
$rand
=
array_rand
(
$suppliers
,
$needAddApiTypeCount
);
$apiSuppliers
=
array_intersect_key
(
$suppliers
,
array_flip
(
is_array
(
$rand
)
?
$rand
:
[
$rand
]));
$apiSupplierIds
=
array_column
(
$apiSuppliers
,
'supplier_id'
);
echo
"供应商性质为 :
$supplierGroup
的供应商修改API上传类型数量 : "
.
count
(
$apiSupplierIds
)
.
PHP_EOL
.
PHP_EOL
;
SupplierChannelModel
::
whereIn
(
'supplier_id'
,
$apiSupplierIds
)
->
where
(
'outside_contact_type'
,
0
)
->
update
([
'outside_contact_type'
=>
2
]);
}
//
转移附件数据到新的表
public
function
transferAttachmentToNewTable
(
)
//
处理云芯接入的不同类型的数据
public
function
dealYunxinSupplier
(
$supplierGroup
,
$totalYunxinCount
)
{
$supplierAttachments
=
SupplierAttachmentModel
::
get
()
->
toArray
();
foreach
(
$supplierAttachments
as
$supplierAttachment
)
{
$supplierId
=
$supplierAttachment
[
'supplier_id'
];
if
(
SupplierAttachmentsModel
::
where
(
'supplier_id'
,
$supplierId
)
->
exists
())
{
continue
;
}
$fields
=
[
'business_license'
,
'billing_information'
,
'registration_certificate'
,
'incorporation_certificate'
,
'certification_notice'
,
'supplier_survey'
,
'proxy_certificate'
,
'quality_assurance_agreement'
,
'confidentiality_agreement'
,
'cooperation_agreement'
,
'other_attachment'
,
];
$attachmentData
=
[];
foreach
(
$fields
as
$field
)
{
if
(
isset
(
$supplierAttachment
[
$field
])
&&
!
empty
(
$supplierAttachment
[
$field
]))
{
$supplierAttachment
[
$field
]
=
json_decode
(
$supplierAttachment
[
$field
],
true
);
foreach
(
$supplierAttachment
[
$field
]
as
$item
)
{
/*
* [{"name":"business_license","url":"http:\/\/img.ichunt.com\/test\/images\/ichunt\/202106\/25\/fc9c8179aa327f878932dd6b62b4d88c.png","file_name":"38.png"}]
* */
$attachmentData
[]
=
[
'supplier_id'
=>
$supplierId
,
'type_name'
=>
array_get
(
config
(
'fixed.FileNameMapping'
),
$item
[
'name'
]),
'field_name'
=>
$item
[
'name'
],
'file_url'
=>
$item
[
'url'
],
'file_name'
=>
array_get
(
$item
,
'file_name'
,
''
),
];
}
}
}
SupplierAttachmentsModel
::
insert
(
$attachmentData
);
$suppliers
=
$this
->
getNeedDealSuppliers
(
$supplierGroup
);
echo
"供应商性质
$supplierGroup
需要修改数量 :"
.
$totalYunxinCount
.
PHP_EOL
;
echo
"供应商性质
$supplierGroup
可操作供应商数量 :"
.
count
(
$suppliers
)
.
PHP_EOL
;
if
(
!
count
(
$suppliers
))
{
return
;
}
if
(
count
(
$suppliers
)
<
$totalYunxinCount
)
{
$totalYunxinCount
=
count
(
$suppliers
);
}
$rand
=
array_rand
(
$suppliers
,
$totalYunxinCount
);
$yunxinSuppliers
=
array_intersect_key
(
$suppliers
,
array_flip
(
is_array
(
$rand
)
?
$rand
:
[
$rand
]));
$yunxinSupplierIds
=
array_column
(
$yunxinSuppliers
,
'supplier_id'
);
echo
"供应商性质为 :
$supplierGroup
的供应商修改云芯上传类型数量 : "
.
count
(
array_unique
(
$yunxinSupplierIds
))
.
PHP_EOL
;
// foreach ($yunxinSupplierIds as $supplierId) {
// SupplierChannelModel::where('supplier_id', $supplierId)->update([
// 'outside_contact_type' => 3
// ]);
// }
SupplierChannelModel
::
whereIn
(
'supplier_id'
,
$yunxinSupplierIds
)
->
where
(
'outside_contact_type'
,
0
)
->
update
([
'outside_contact_type'
=>
3
]);
}
//
转换交易方式和付款方式数据统一到付款方式
public
function
transferPayType
(
$change
=
false
)
//
处理人工上传
public
function
dealManualSupplier
(
$supplierGroup
,
$totalManualCount
)
{
$suppliersA
=
SupplierChannelModel
::
where
(
'trading_method'
,
'!='
,
0
)
->
where
(
'pay_type'
,
'!='
,
0
)
->
get
()
->
toArray
();
$suppliersB
=
SupplierChannelModel
::
where
(
'trading_method'
,
'!='
,
0
)
->
where
(
'pay_type'
,
0
)
->
get
()
->
toArray
();
$suppliersC
=
SupplierChannelModel
::
where
(
'trading_method'
,
0
)
->
where
(
'pay_type'
,
'!='
,
0
)
->
get
()
->
toArray
();
$handledSupplierIds
=
[];
//如果供应商交易方式与付款方式都有数据,则付款周期从交易方式中映射,映射规则:先款后货映射成预付款;月结映射成账期;
if
(
$suppliersA
)
{
foreach
(
$suppliersA
as
$supplier
)
{
if
(
$supplier
[
'trading_method'
]
==
1
)
{
$payType
=
3
;
}
else
{
$payType
=
1
;
}
$tradeMethod
=
array_get
(
config
(
'fixed.TradingMethod'
),
$supplier
[
'trading_method'
]);
$payTypeName
=
array_get
(
config
(
'fixed.SupplierPayType'
),
$payType
);
dump
(
"供应商编码 ${supplier['supplier_code']} 原来的交易方式为
$tradeMethod
转换成付款周期
$payTypeName
"
);
if
(
$change
)
{
$handledSupplierIds
[]
=
$supplier
[
'supplier_id'
];
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplier
[
'supplier_id'
])
->
update
([
'pay_type'
=>
$payType
,
]);
}
}
$otherSupplierGroup
=
[];
if
(
$supplierGroup
==
2
)
{
$otherSupplierGroup
=
[
0
,
2
,
3
,
5
,
6
];
// $otherSupplierGroup = [2];
}
dump
(
'--------------------------------'
);
//如果供应商交易方式有数据,付款方式无数据,则付款周期从交易方式中映射,映射规则:先款后货映射成预付款;月结映射成账期;
if
(
$suppliersB
)
{
foreach
(
$suppliersB
as
$supplier
)
{
if
(
$supplier
[
'trading_method'
]
==
1
)
{
$payType
=
3
;
}
else
{
$payType
=
1
;
}
$tradeMethod
=
array_get
(
config
(
'fixed.TradingMethod'
),
$supplier
[
'trading_method'
]);
$payTypeName
=
array_get
(
config
(
'fixed.SupplierPayType'
),
$payType
);
dump
(
"供应商编码 ${supplier['supplier_code']} 原来的交易方式为
$tradeMethod
转换成付款周期
$payTypeName
"
);
if
(
$change
)
{
$handledSupplierIds
[]
=
$supplier
[
'supplier_id'
];
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplier
[
'supplier_id'
])
->
update
([
'pay_type'
=>
$payType
,
]);
}
}
//人工上传这个类别,供应商性质如果是贸易商,那就要加上方案商和分销平台和代工厂
$suppliers
=
$this
->
getNeedDealSuppliers
(
$supplierGroup
,
$otherSupplierGroup
);
echo
"供应商性质
$supplierGroup
需要修改数量 :"
.
$totalManualCount
.
PHP_EOL
;
echo
"供应商性质
$supplierGroup
可操作供应商数量 :"
.
count
(
$suppliers
)
.
PHP_EOL
;
if
(
!
count
(
$suppliers
))
{
return
;
}
dump
(
'--------------------------------'
);
//如果供应商交易方式无数据,付款方式有数据,则付款周期从付款方式中映射,映射规则:账期-周期结算映射成账期,账期-定期结算映射成账期,全款映射成预付款,定金映射成预付款;
if
(
$suppliersC
)
{
foreach
(
$suppliersC
as
$supplier
)
{
$payType
=
0
;
if
(
!
trim
(
$supplier
[
'pay_type'
]))
{
continue
;
}
switch
(
trim
(
$supplier
[
'pay_type'
]))
{
case
1
:
$payType
=
1
;
break
;
case
2
:
$payType
=
1
;
break
;
case
3
:
$payType
=
3
;
break
;
case
4
:
$payType
=
3
;
break
;
}
$originPayTypeNameMap
=
[
1
=>
'账期-周期结算'
,
2
=>
'账期-定期结算'
,
3
=>
'全款'
,
4
=>
'定金'
,
];
$originPayTypeName
=
array_get
(
$originPayTypeNameMap
,
$supplier
[
'pay_type'
]);
$payTypeName
=
array_get
(
config
(
'fixed.SupplierPayType'
),
$payType
);
dump
(
"供应商编码 ${supplier['supplier_code']} 原来的付款方式为
$originPayTypeName
转换成付款周期
$payTypeName
"
);
if
(
$change
&&
$payType
)
{
$handledSupplierIds
[]
=
$supplier
[
'supplier_id'
];
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplier
[
'supplier_id'
])
->
update
([
'pay_type'
=>
$payType
,
]);
}
}
if
(
count
(
$suppliers
)
<=
$totalManualCount
)
{
$totalManualCount
=
count
(
$suppliers
);
}
$rand
=
array_rand
(
$suppliers
,
$totalManualCount
);
$manualSuppliers
=
array_intersect_key
(
$suppliers
,
array_flip
(
is_array
(
$rand
)
?
$rand
:
[
$rand
]));
$manualSupplierIds
=
array_column
(
$manualSuppliers
,
'supplier_id'
);
echo
"供应商性质为 :
$supplierGroup
的供应商修改人工上传类型数量 : "
.
count
(
$manualSupplierIds
)
.
PHP_EOL
;
// foreach ($manualSupplierIds as $supplierId) {
// SupplierChannelModel::where('supplier_id', $supplierId)->update([
// 'outside_contact_type' => 1
// ]);
// }
foreach
(
collect
(
$manualSupplierIds
)
->
chunk
(
500
)
as
$key
=>
$ids
)
{
SupplierChannelModel
::
whereIn
(
'supplier_id'
,
$ids
)
->
where
(
'outside_contact_type'
,
0
)
->
update
([
'outside_contact_type'
=>
1
]);
}
}
//导入
等级修改供应商并且找出没有等级的供应商(针对正式的)
public
function
importSupplier
Level
(
$chang
e
=
false
)
//导入
公司性质
public
function
importSupplier
Group
(
$isUpdat
e
=
false
)
{
$filePath
=
public_path
(
'data'
)
.
DIRECTORY_SEPARATOR
.
'supplier_
level
.xlsx'
;
$filePath
=
public_path
(
'data'
)
.
DIRECTORY_SEPARATOR
.
'supplier_
group
.xlsx'
;
try
{
Excel
::
selectSheetsByIndex
(
0
)
->
load
(
$filePath
,
function
(
$reader
)
use
(
$
chang
e
)
{
$
supplierChannelModel
=
new
SupplierChannelModel
();
$reader
->
sheet
(
'2021年评估'
,
function
(
$sheet
)
use
(
$reader
,
$supplierChannelModel
,
$change
)
{
$
number
=
0
;
Excel
::
selectSheetsByIndex
(
0
)
->
load
(
$filePath
,
function
(
$reader
)
use
(
$
isUpdat
e
)
{
$
reader
->
sheet
(
'Sheet2'
,
function
()
use
(
$reader
,
$isUpdate
)
{
$num
=
$ycNum
=
0
;
$
redis
=
new
RedisModel
()
;
foreach
(
$reader
->
all
()
->
toArray
()
as
$key
=>
$item
)
{
$supplierName
=
trim
(
$item
[
1
]);
$level
=
trim
(
$item
[
2
]);
//先去判断是否存在
$exist
=
$supplierChannelModel
->
where
(
'supplier_name'
,
$supplierName
)
->
exists
();
$levelExist
=
$supplierChannelModel
->
where
(
'supplier_name'
,
$supplierName
)
->
value
(
'level'
);
if
(
$levelExist
)
{
echo
"供应商 ${supplierName} 已有,等级为 : "
.
$level
.
PHP_EOL
;
continue
;
$supplierCode
=
trim
(
$item
[
0
]);
$purchaseName
=
trim
(
$item
[
3
]);
$channelUid
=
(
new
AdminUserService
())
->
getCodeIdByUserName
(
$purchaseName
);
//如果采购员id不为空,那么就要写进去
$supplierId
=
SupplierChannelModel
::
where
(
'supplier_code'
,
$supplierCode
)
->
value
(
'supplier_id'
);
if
(
!
$supplierId
)
{
echo
"供应商不存在 : "
.
$supplierCode
.
PHP_EOL
;
}
if
(
!
$exist
)
{
$number
++
;
}
else
{
echo
"修改供应商 ${supplierName} 等级为 : "
.
$level
.
PHP_EOL
;
if
(
$change
)
{
$supplierChannelModel
->
where
(
'supplier_name'
,
$supplierName
)
->
update
([
'level'
=>
$level
,
]);
if
(
$channelUid
)
{
echo
"添加采购员${purchaseName}到 : "
.
$supplierCode
.
PHP_EOL
;
if
(
$isUpdate
)
{
(
new
SupplierService
())
->
allocateChannelUser
(
$supplierId
,
$channelUid
,
false
);
}
}
$isYc
=
trim
(
$item
[
4
]);
if
(
$isYc
==
'原厂'
)
{
//判断是否是原厂,如果是原厂,就跳过
$supplierGroup
=
SupplierChannelModel
::
where
(
'supplier_code'
,
$supplierCode
)
->
value
(
'supplier_group'
);
if
(
$supplierGroup
==
self
::
TYPE_YC
)
{
echo
"该供应商已经是原厂,跳过 :
$supplierCode
"
.
PHP_EOL
;
continue
;
}
echo
"修改供应商性质为原厂 : "
.
$supplierCode
.
PHP_EOL
;
if
(
$isUpdate
)
{
//写入redis,方便恢复
$redis
->
hset
(
'lie_supplier_group_change'
,
$supplierGroup
,
self
::
TYPE_YC
);
SupplierChannelModel
::
where
(
'supplier_code'
,
$supplierCode
)
->
update
([
'supplier_group'
=>
self
::
TYPE_YC
,
]);
}
$ycNum
++
;
}
$num
++
;
}
var_dump
(
"一共有${number}个不存在的供应商"
);
echo
"一共处理
$num
家供应商采购员,处理
$ycNum
家供应商性质为原厂"
.
PHP_EOL
;
});
});
}
catch
(
\Exception
$exception
)
{
...
...
@@ -662,7 +343,31 @@ class DataService
}
}
//生成云芯账号
public
function
generateYunxinAccount
(
$isUpdate
=
false
)
{
$suppliers
=
SupplierChannelModel
::
where
(
'outside_contact_type'
,
3
)
->
get
()
->
toArray
();
// $suppliers = SupplierChannelModel::where('is_type', 0)->limit(100)->get()->toArray();
foreach
(
$suppliers
as
$supplier
)
{
if
(
SupplierAccountModel
::
where
(
'supplier_id'
,
$supplier
[
'supplier_id'
])
->
exists
())
{
continue
;
}
$mobile
=
generateMobile
(
1
)[
0
];
$password
=
makePassword
(
mt_rand
(
8
,
12
));
$account
=
[
'supplier_id'
=>
$supplier
[
'supplier_id'
],
'supplier_code'
=>
$supplier
[
'supplier_code'
],
'mobile'
=>
$mobile
,
'password_raw'
=>
$password
,
'password'
=>
Hash
::
make
(
$password
),
'create_uid'
=>
1000
,
'create_time'
=>
time
(),
];
if
(
$isUpdate
)
{
SupplierAccountModel
::
insert
(
$account
);
}
}
}
}
app/Http/Services/SupplierService.php
View file @
daad3722
...
...
@@ -418,9 +418,9 @@ class SupplierService
}
//分配采购员
public
function
allocateChannelUser
(
$supplierId
,
$channelUid
)
public
function
allocateChannelUser
(
$supplierId
,
$channelUid
,
$logFlag
=
true
)
{
$result
=
DB
::
connection
(
'web'
)
->
transaction
(
function
()
use
(
$supplierId
,
$channelUid
)
{
$result
=
DB
::
connection
(
'web'
)
->
transaction
(
function
()
use
(
$supplierId
,
$channelUid
,
$logFlag
)
{
$model
=
new
SupplierChannelModel
();
$supplier
=
$model
->
where
(
'supplier_id'
,
$supplierId
)
->
first
();
$supplier
=
$supplier
?
$supplier
->
toArray
()
:
[];
...
...
@@ -429,10 +429,18 @@ class SupplierService
$preChannelUid
[]
=
$channelUid
;
$preChannelUid
=
array_unique
(
$preChannelUid
);
$preChannelUid
=
implode
(
','
,
$preChannelUid
);
$result
=
$model
->
where
(
'supplier_id'
,
$supplierId
)
->
update
([
'update_time'
=>
time
(),
'channel_uid'
=>
$preChannelUid
,
]);
$preChannelUid
=
trim
(
$preChannelUid
,
','
);
if
(
$logFlag
)
{
$result
=
$model
->
where
(
'supplier_id'
,
$supplierId
)
->
update
([
'update_time'
=>
time
(),
'channel_uid'
=>
$preChannelUid
,
]);
}
else
{
$result
=
$model
->
where
(
'supplier_id'
,
$supplierId
)
->
update
([
'channel_uid'
=>
$preChannelUid
,
]);
}
$contactResult
=
false
;
if
(
$result
)
{
$contactModel
=
new
SupplierContactModel
();
...
...
@@ -440,11 +448,11 @@ class SupplierService
'supplier_id'
=>
$supplierId
,
'can_check_uids'
=>
$channelUid
,
'add_time'
=>
time
(),
'admin_id'
=>
request
()
->
user
->
userId
,
'admin_id'
=>
!
empty
(
request
()
->
user
->
userId
)
?
request
()
->
user
->
userId
:
1000
,
];
$contactResult
=
$contactModel
->
insert
(
$contact
);
}
if
(
$contactResult
)
{
if
(
$contactResult
&&
$logFlag
)
{
//判断是否是非正式供应商,如果是,自动转正,并且修改为待审核状态
$this
->
autoChangeIsType
(
$supplier
);
//记录日志
...
...
@@ -511,7 +519,7 @@ class SupplierService
$printData
[
'contact'
]
=
$contact
;
$attachmentModel
=
new
SupplierAttachmentsModel
();
$hasAgreement
=
$attachmentModel
->
where
(
'supplier_id'
,
$supplierId
)
->
where
(
'field_name'
,
'quality_assurance_agreement'
)
->
exists
()
?
'已签'
:
'未签'
;
->
where
(
'field_name'
,
'quality_assurance_agreement'
)
->
exists
()
?
'已签'
:
'未签'
;
$printData
[
'has_agreement'
]
=
$hasAgreement
;
$adminUserService
=
new
AdminUserService
();
$user
=
$adminUserService
->
getAdminUserInfo
(
request
()
->
user
->
userId
);
...
...
@@ -580,8 +588,8 @@ class SupplierService
'supplier_type'
,
'settlement_type'
,
];
foreach
(
$supplier
as
$key
=>
&
$value
)
{
if
(
in_array
(
$key
,
$needChangeField
)
&&
empty
(
$value
))
{
foreach
(
$supplier
as
$key
=>
&
$value
)
{
if
(
in_array
(
$key
,
$needChangeField
)
&&
empty
(
$value
))
{
$value
=
''
;
}
}
...
...
app/Http/function.php
View file @
daad3722
...
...
@@ -203,4 +203,44 @@ function checkArrayAllValueNull($array, $excludeField = [])
}
return
true
;
}
function
generateMobile
(
$count
)
{
$arr
=
[
130
,
131
,
132
,
133
,
134
,
135
,
136
,
137
,
138
,
139
,
144
,
147
,
150
,
151
,
152
,
153
,
155
,
156
,
157
,
158
,
159
,
176
,
177
,
178
,
180
,
181
,
182
,
183
,
184
,
185
,
186
,
187
,
188
,
189
,
];
$phone
=
[];
for
(
$i
=
0
;
$i
<
$count
;
$i
++
)
{
$phone
[]
=
$arr
[
array_rand
(
$arr
)]
.
''
.
mt_rand
(
1000
,
9999
)
.
''
.
mt_rand
(
1000
,
9999
);
}
return
array_unique
(
$phone
);
}
function
makePassword
(
$length
)
{
// 密码字符集,可任意添加你需要的字符
// $str = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
// 'i', 'j', 'k', 'l','m', 'n', 'o', 'p', 'q', 'r', 's',
// 't', 'u', 'v', 'w', 'x', 'y','z', 'A', 'B', 'C', 'D',
// 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L','M', 'N', 'O',
// 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y','Z',
// '0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
$str
=
array
(
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
,
'g'
,
'h'
,
'i'
,
'j'
,
'k'
,
'l'
,
'm'
,
'n'
,
'o'
,
'p'
,
'q'
,
'r'
,
's'
,
't'
,
'u'
,
'v'
,
'w'
,
'x'
,
'y'
,
'z'
,
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
);
// 在 $str 中随机取 $length 个数组元素键名
$keys
=
array_rand
(
$str
,
$length
);
$password
=
''
;
for
(
$i
=
0
;
$i
<
$length
;
$i
++
)
{
// 将 $length 个数组元素连接成字符串
$password
.=
$str
[
$keys
[
$i
]];
}
return
$password
;
}
\ No newline at end of file
app/Http/routes.php
View file @
daad3722
...
...
@@ -53,11 +53,5 @@ Route::group(['middleware' => ['external'],'namespace' => 'Api'], function () {
});
Route
::
match
([
'get'
,
'post'
],
'/test'
,
function
()
{
$data
=
[
'sku_ids'
=>
'1163833791883548099,1163833787833091377'
,
'is_long_term'
=>
-
1
,
'operate_type'
=>
1
,
'cp_time'
=>
'2022-05-31 0:0:0'
,
];
(
new
SkuService
())
->
batchUpdateSkuStatus
(
$data
);
// (new \App\Http\Services\DataService())->importSupplierGroup();
});
public/data/supplier_group.xlsx
0 → 100644
View file @
daad3722
No preview for this file type
public/data/猎芯网qc检验记录 - 副本.xlsx:Zone.Identifier
deleted
100644 → 0
View file @
96a132f1
[ZoneTransfer]
[ZoneTransfer]
ZoneId=3
ReferrerUrl=https://www.tapd.cn/
HostUrl=https://file.tapd.cn/56056445/attachments/download/1156056445001001663/story
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment