Commit daad3722 by 杨树贤

数据导入脚本

parent 96a132f1
......@@ -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();
}
}
......@@ -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)
......
......@@ -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();
......
......@@ -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 = '';
}
}
......
......@@ -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
......@@ -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();
});
No preview for this file type
[ZoneTransfer]
[ZoneTransfer]
ZoneId=3
ReferrerUrl=https://www.tapd.cn/
HostUrl=https://file.tapd.cn/56056445/attachments/download/1156056445001001663/story
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment