Commit f8d69d4b by mushishixian

Merge branch 'ysx-供应商四期-20210720'

parents c29d468c ff950e89
Showing with 3431 additions and 435 deletions
......@@ -111,4 +111,6 @@ PERM_GOURL=http://perm.liexin.net
ADMIN_GROUP=10000,20000
MENU_ID=16
MENU_URL=http://data.liexin.net/api/config/
FOOTSTONE_URL=http://footstone.liexin.net
\ No newline at end of file
FOOTSTONE_URL=http://footstone.liexin.net
#标签系统的地址
TAG_URL=http://192.168.1.18:32581
\ No newline at end of file
......@@ -37,29 +37,12 @@ class CommonApiController extends Controller
return $this->response(0, 'ok', $brandList);
}
public function upload($request)
//获取标准品牌
public function getStandardBrandList($request)
{
$upload = $request->file('qualification_photos');
$ext = $upload->getClientOriginalExtension();
$fileName = time() . '.' . $ext;
$upload->move(storage_path("uploads"), $fileName);
$path = storage_path("uploads") . '/' . $fileName;
$result = UploadToOss($path);
$result = json_decode($result, true);
unlink($path);
if (!empty($result) && $result['code'] === 200) {
echo json_encode([
'code' => 200,
'src' => $result['data'][0],
'msg' => 'ok',
]);
} else {
echo json_encode([
'code' => -1,
'msg' => '上传失败',
]);
}
exit();
$model = new BrandModel();
$brandList = $model->getStandardBrandList();
return $this->response(0, 'ok', $brandList);
}
private function SearchBrand($request)
......
......@@ -6,7 +6,6 @@ use App\Http\Controllers\Controller;
use App\Http\Controllers\Filter\SupplierFilter;
use App\Http\Services\AdminUserService;
use App\Http\Services\LogService;
use App\Http\Services\MessageService;
use App\Http\Services\SupplierAuditService;
use App\Http\Services\SupplierService;
use App\Http\Services\SyncSupplierService;
......@@ -17,7 +16,6 @@ use App\Model\RedisModel;
use App\Model\SupplierChannelModel;
use Illuminate\Http\Request;
//通用API,比如获取品牌列表,分类列表等
class SupplierApiController extends Controller
{
......@@ -64,11 +62,21 @@ class SupplierApiController extends Controller
//附加费
'cn',
'hk',
// 'status',
//商品上传规则
'sku_upload_ruler',
'sku_audit_ruler',
//标签
'system_tags',
'customer_tags',
'level',
'has_certification',
'sku_mode',
'sku_tag',
'main_customers',
'ticket_time',
'billing_period_detail',
];
public function Entrance(Request $request, $id)
......@@ -96,6 +104,8 @@ class SupplierApiController extends Controller
'supplier_fax',
'can_check_uids'
]);
//附件
$channelMap = array_merge($channelMap, config('field.AttachmentFields'));
$channel = $request->only($channelMap);
$service = new SupplierService();
$result = $service->saveSupplier($channel);
......@@ -115,7 +125,8 @@ class SupplierApiController extends Controller
if ($validateResult) {
$this->response(-1, $validateResult);
}
$channel = $request->only($this->channelMap);
$channelMap = array_merge($this->channelMap, config('field.AttachmentFields'));
$channel = $request->only($channelMap);
$service = new SupplierService();
$result = $service->saveSupplier($channel);
if (!$result) {
......@@ -144,23 +155,24 @@ class SupplierApiController extends Controller
public function DisableSupplier($request)
{
//禁用不是直接修改为无法交易,而是改为待审核,然后审核通过后,变成无法交易
//禁用不是直接修改为无法交易,而是改为审核中,然后审核通过后,变成无法交易
$supplierId = $request->get('supplier_id');
$model = new SupplierChannelModel();
//先保存原来的状态
$supplier = $model->where('supplier_id', $supplierId)->first()->toArray();
$redis = new RedisModel();
//存到redis做数据对比
$redis->hset('audit_disable_supplier_list', $supplierId, 1);
$redis->hset('supplier_status_before_disable', $supplierId, $supplier['status']);
$result = $model->where('supplier_id', $supplierId)->update([
'update_time' => time(),
'status' => $model::STATUS_IN_REVIEW,
'status' => $model::STATUS_DISABLE,
]);
if ($result) {
//写日志
$logService = new LogService();
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, '禁用', '禁用供应商');
$this->response(0, '操作成功,进入审核状态');
$this->response(0, '禁用成功');
} else {
$this->response(-1, '操作失败,进入审核状态');
$this->response(-1, '禁用失败');
}
}
......@@ -208,9 +220,6 @@ class SupplierApiController extends Controller
if (!$result) {
$this->response(-1, '修改状态失败');
}
//发送短信
// $messageService = new MessageService();
// $messageService->sendSupplierMessage($supplierId, $status);
//发送队列消息同步到金蝶
$service = new SyncSupplierService();
$service->syncSupplierToErp($supplierId);
......@@ -300,6 +309,7 @@ class SupplierApiController extends Controller
}
//批量修改渠道开发员
//修改后自动触发转正,资料不完善,进入待审核
public function BatchAllocatePurchaseUser($request)
{
$purchaseUid = $request->get('purchase_uid');
......@@ -380,7 +390,7 @@ class SupplierApiController extends Controller
//修改供应商状态
$model->where('supplier_id', $supplierId)->update([
'update_time' => time(),
'status' => SupplierChannelModel::STATUS_IN_REVIEW,
'status' => SupplierChannelModel::STATUS_PENDING,
]);
$adminService = new AdminUserService();
$user = $adminService->getAdminUserInfoByCodeId($channelUid);
......@@ -404,4 +414,82 @@ class SupplierApiController extends Controller
$this->response(-1, '无法进行审核操作,因为该供应商最后(修改人/创建人)和您不属于同一个部门');
}
}
//拉黑供应商
public function BlockSupplier($request)
{
$supplierId = $request->get('supplier_id');
$blockReason = $request->get('block_reason');
if (empty(trim($blockReason))) {
$this->response(-1, '必须填写拉黑原因');
}
if (mb_strlen($blockReason) > 200) {
$this->response(-1, '拉黑原因不能超过200字');
}
$channelModel = new SupplierChannelModel();
$result = $channelModel->where('supplier_id', $supplierId)->update([
'block_reason' => $request->get('block_reason'),
'status' => $channelModel::STATUS_BLOCK,
'update_time' => time(),
]);
if ($result) {
$logService = new LogService();
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, '拉黑', '拉黑供应商');
$this->response(0, '拉黑成功');
} else {
$this->response(-1, '拉黑操作失败');
}
}
//取消拉黑供应商
public function CancelBlockSupplier($request)
{
$supplierId = $request->get('supplier_id');
$channelModel = new SupplierChannelModel();
$result = $channelModel->where('supplier_id', $supplierId)->update([
'status' => SupplierChannelModel::STATUS_IN_REVIEW,
'update_time' => time(),
]);
if ($result) {
$logService = new LogService();
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, '取消拉黑', '取消拉黑供应商');
$this->response(0, '取消拉黑成功');
} else {
$this->response(-1, '取消拉黑操作失败');
}
}
//取消禁用供应商
public function CancelDisableSupplier($request)
{
$supplierId = $request->get('supplier_id');
$channelModel = new SupplierChannelModel();
//先找出原来的状态
$redis = new RedisModel();
$previousStatus = $redis->hget('supplier_status_before_disable', $supplierId);
$result = $channelModel->where('supplier_id', $supplierId)->update([
'status' => $previousStatus,
'update_time' => time(),
]);
if ($result) {
//删除redis状态
$redis->hdel('supplier_status_before_disable', $supplierId);
$logService = new LogService();
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, '取消禁用', '取消禁用供应商');
$this->response(0, '取消禁用成功');
} else {
$this->response(-1, '取消禁用操作失败');
}
}
//批量申请审核供应商
public function BatchApplyInReviewSupplier($request)
{
$supplierIds = $request->get('supplier_ids');
$supplierIds = explode(',', $supplierIds);
$supplierService = new SupplierService();
$supplierService->batchApplyInReviewSupplier($supplierIds);
$this->response(0, '申请审核成功');
}
}
......@@ -53,13 +53,13 @@ class SupplierContactApiController extends Controller
$inUserIdSql = "(" . $inUserIdSql . ")";
if ($inCodeIdSql) {
$query->whereRaw(DB::raw("(admin_id in $inUserIdSql or can_check_uids in $inCodeIdSql)"));
}else{
} else {
$query->whereRaw(DB::raw("(admin_id in $inUserIdSql)"));
}
}else{
} else {
if ($codeId) {
$query->whereRaw("(can_check_uids = $codeId or admin_id = $adminId)");
}else{
} else {
$query->whereRaw("(admin_id = $adminId)");
}
}
......@@ -91,11 +91,18 @@ class SupplierContactApiController extends Controller
$this->response(-1, $validateResult);
}
$service = new SupplierContactService();
$hasNeedReplaceContact = $service->getNeedReplaceContact($data['supplier_id'], $data['can_check_uids']);
$result = $service->saveContact($data);
if (!$result) {
$this->response(-1, '操作失败');
}
$this->response(0, '保存成功');
//有需要自动替换补全数据操作后的提示
if ($hasNeedReplaceContact) {
$this->response(0, '系统检测到当前采购有默认的空联系人,直接更新对应数据');
}else{
$this->response(0, '保存成功');
}
}
public function DeleteSupplierContact($request)
......
......@@ -81,7 +81,7 @@ class SupplierReceiptApiController extends Controller
//修改供应商为审核状态
$supplierModel->where('supplier_id', $supplierId)->update([
'update_time' => time(),
'status' => 1,
'status' => SupplierChannelModel::STATUS_PENDING,
]);
}
......@@ -94,7 +94,7 @@ class SupplierReceiptApiController extends Controller
$this->response(-1, '操作失败');
}
//判断是否要进入待审核状态,因为部分字段修改是不需要走审核的
//判断是否要进入审核中状态,因为部分字段修改是不需要走审核的
private function checkNeedAudit($oldReceipt, $newReceipt)
{
$notNeedAuditField = [
......
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Services\DepartmentService;
use App\Http\Services\SupplierShareApplyService;
use App\Model\SupplierChannelModel;
use Illuminate\Http\Request;
//供应商共享申请
class SupplierShareApplyApiController extends Controller
{
public function Entrance(Request $request, $id)
{
$this->$id($request, $id);
}
public function GetSupplierShareApplyList($request)
{
$userId = $request->user->userId;
$applyService = new SupplierShareApplyService();
$list = $applyService->getSupplierShareApplyList($userId);
$this->response(0, 'ok', $list['data'], $list['total']);
}
//校验申请的供应商,并且还要返回所属部门列表
public function CheckApplySupplierShare($request)
{
$supplierName = trim($request->get('supplier_name'));
if (empty($supplierName)) {
$this->response(-1, '供应商名称不能为空');
}
$supplierModel = new SupplierChannelModel();
$supplier = $supplierModel->where('supplier_name', $supplierName)->first();
if (empty($supplier)) {
$this->response(-1, '该供应商名称不存在,请输入正确供应商名称');
}
$userId = $request->user->userId;
$codeId = $request->user->codeId;
if (empty($codeId)) {
$this->response(-1, '你还没有绑定内部编码,无法申请共用');
}
//要判断自己是不是有这个供应商了,有的话没必要申请
$isOwn = $supplierModel->where('supplier_name', $supplierName)->where(function ($q) use ($userId, $codeId) {
$q->where('create_uid', $userId);
if (!empty($codeId)) {
$q->orWhere('purchase_uid', $codeId)
->orwhere('channel_uid', 'like', "%$codeId%");
}
})->where('is_type', 0)->first();
if ($isOwn) {
$this->response(-1, '你已经可以管理该供应商,无需申请共用');
}
if (empty($supplier['create_uid']) && empty($supplier['channel_uid']) && empty($supplier['purchase_uid'])) {
$this->response(-1, '该供应商没有相关的所属人信息,请联系管理员');
}
$departmentService = new DepartmentService();
$department = $departmentService->getUpperDepartmentByUserIdForShareApply($request->user->userId);
$applyService = new SupplierShareApplyService();
$departments = $applyService->getApplyCanUseDepartments($supplier);
//获取当前人的部门id,如果部门列表里面包含自己的部门,则提示该供应商属于自己部门,请找主管分配
if (in_array($department, $departments)) {
$this->response(-1, '该供应商属于自己部门,请找主管分配');
}
if (empty($departments)) {
$this->response(-1, '该供应商不存在相关联的部门');
}
$this->response(0, '匹配到供应商数据,可以下拉选择你需要申请的部门', $departments, $supplier['supplier_id']);
}
//保存共用申请
public function SaveSupplierShareApply($request)
{
$map = $request->only([
'apply_department_id',
'supplier_id',
]);
if (empty($map['apply_department_id']) || empty($map['supplier_id'])) {
$this->response(-1, '缺少参数');
}
if (empty($request->user->codeId)) {
$this->response(-1, '你还没有绑定内部编码,无法申请共用');
}
$map['apply_code_id'] = $request->user->codeId;
$applyService = new SupplierShareApplyService();
$hasNoFinish = $applyService->checkHasNoFinishApply($map);
if ($hasNoFinish) {
$this->response(-1, '你存在对该供应商的申请,正在审核流程中,请等待对应的审核流程走完方可针对该供应商进行新的共用申请');
}
$result = $applyService->saveSupplierShareApply($map);
if (!$result) {
$this->response(-1, '申请失败,系统错误');
}
return $this->response(0, '申请成功');
}
//获取共用审核列表
//1.审核分初审和复审
//2.有审核权限都可以看到这个列表
public function GetAuditSupplierShareApplyList($request)
{
$applyService = new SupplierShareApplyService();
$userId = $request->user->userId;
$list = $applyService->getAuditSupplierShareApplyList($userId);
$this->response(0, 'ok', $list['data'], $list['total']);
}
//审核
public function AuditSupplierShareApply($request)
{
$statusName = $request->get('status');
$applyService = new SupplierShareApplyService();
$userId = $request->user->userId;
$id = $request->get('id');
$result = $applyService->auditSupplierShareApply($id, $userId, $statusName);
if (!$result) {
$this->response(-1, '审核操作失败');
}
return $this->response(0, '审核操作成功');
}
}
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Services\SupplierTagService;
use App\Http\Transformers\SupplierLogTransformer;
use App\Model\LogModel;
use App\Model\SupplierLogModel;
use GuzzleHttp\Client;
use Illuminate\Http\Request;
//通用API,比如获取品牌列表,分类列表等
class SupplierTagApiController extends Controller
{
public function Entrance(Request $request, $id)
{
$this->$id($request, $id);
}
//获取所有系统标签
public function GetSystemTagList($request)
{
$supplierTagService = new SupplierTagService();
$data = $supplierTagService->getSystemTags();
$this->response(0, 'ok', $data, count($data));
}
}
......@@ -19,7 +19,7 @@ class SupplierFilter
$query = $this->defaultFilter($query, $map['source_type']);
//判断筛选参数
if (!empty($map['supplier_id'])) {
$query->where('supplier_id', $map['supplier_id']);
$query->where('supplier_channel.supplier_id', $map['supplier_id']);
}
if (!empty($map['supplier_name'])) {
$query->where('supplier_name', 'like', "%{$map['supplier_name']}%");
......@@ -66,6 +66,14 @@ class SupplierFilter
}
}
if (!empty($map['sku_tag'])) {
$query->where('sku_tag', $map['sku_tag']);
}
if (!empty($map['sku_mode'])) {
$query->where('sku_mode', $map['sku_mode']);
}
if (!empty($map['create_time'])) {
$times = explode('~', $map['create_time']);
$startTime = strtotime($times[0]);
......@@ -99,15 +107,16 @@ class SupplierFilter
$canViewAllSupplier = checkPerm('ViewAllSupplier');
$canViewSubordinateSupplier = checkPerm('ViewSubordinateSupplier');
$canViewFakeSupplier = checkPerm('ViewFakeSupplier');
//现在普通采购也能看到竞调供应商了(与他有关的)
if (!$canViewFakeSupplier) {
$query->where('is_type', 0);
}
$query->with(['contact', 'attachment']);
$query->whereRaw('supplier_name NOT LIKE "%-1"');
//默认展示的数据查询
//看全部的权限,优先级最高
// if ($canViewAllSupplier || $sourceType == 'block') {
if ($canViewAllSupplier) {
//能查看所有的话,限制基本没有
} else {
......@@ -128,9 +137,11 @@ class SupplierFilter
$inUserIdSql = "(" . $inUserIdSql . ")";
if ($subordinateCodeIds) {
if ($canViewFakeSupplier) {
$query->whereRaw(DB::raw("(create_uid in $inUserIdSql or purchase_uid in $inCodeIdSql or channel_uid REGEXP '$likeSqlRaw' or is_type = 1) "));
$query->whereRaw(DB::raw("(create_uid in $inUserIdSql or purchase_uid in $inCodeIdSql
or channel_uid REGEXP '$likeSqlRaw' or is_type = 1) "));
} else {
$query->whereRaw(DB::raw("(create_uid in $inUserIdSql or purchase_uid in $inCodeIdSql or channel_uid REGEXP '$likeSqlRaw') "));
$query->whereRaw(DB::raw("(create_uid in $inUserIdSql or purchase_uid in $inCodeIdSql
or channel_uid REGEXP '$likeSqlRaw') "));
}
} else {
if ($canViewFakeSupplier) {
......@@ -150,16 +161,23 @@ class SupplierFilter
}
}
// $query->orwhere('status', SupplierChannelModel::STATUS_BLOCK);
//先判断获取类型
switch ($sourceType) {
case "all":
//还要看到所有黑名单
// $query->orWhere('status', SupplierChannelModel::STATUS_BLOCK);
break;
case "pending":
//待复审供应商
$query->where('status', SupplierChannelModel::STATUS_PENDING);
break;
case "need_review":
//待复审供应商
$query->where('status', SupplierChannelModel::STATUS_NEED_REVIEW);
break;
case "in_review":
//待审核
//审核中
$query->where('status', SupplierChannelModel::STATUS_IN_REVIEW);
break;
case "passed":
......@@ -177,8 +195,15 @@ class SupplierFilter
case "no_purchase_uid":
//没有渠道开发
$query->where('status', '!=', SupplierChannelModel::STATUS_DISABLE)
->where('status', '!=', SupplierChannelModel::STATUS_BLOCK)
->where('purchase_uid', '');
break;
case "no_channel_uid":
//没有采购员
$query->where('status', '!=', SupplierChannelModel::STATUS_DISABLE)
->where('status', '!=', SupplierChannelModel::STATUS_BLOCK)
->where('channel_uid', '');
break;
case "invalid_channel_uid":
//不合理的渠道开发(比如渠道开发离职了)
$adminUserService = new AdminUserService();
......@@ -206,6 +231,43 @@ class SupplierFilter
//没有sku
$query->where('sku_num', 0);
break;
case "block":
$query->where('status', SupplierChannelModel::STATUS_BLOCK);
// $query->orWhere('status', SupplierChannelModel::STATUS_BLOCK);
break;
case "has_supplier_tag":
$query->where(function ($q) {
$q->whereRaw("system_tags REGEXP '客户指定供应商'");
// $q->where('system_tags', '!=', '')->orWhere('customer_tags', '!=', '');
});
break;
//附件里面缺少品质协议的
case "no_quality_assurance_agreement":
$query->leftjoin('supplier_attachment', 'supplier_channel.supplier_id', '=',
'supplier_attachment.supplier_id')
->selectRaw('lie_supplier_channel.*,
lie_supplier_attachment.quality_assurance_agreement,lie_supplier_attachment.supplier_id as supplier_attachment_supplier_id')
->where(function ($q) {
$q->where('supplier_attachment.quality_assurance_agreement', '')
->orWhereNull('supplier_attachment.supplier_id');
});
$query->whereNotIn('status',
[SupplierChannelModel::STATUS_DISABLE, SupplierChannelModel::STATUS_BLOCK]);
//而且还是贸易商类型的供应商
$query->where('supplier_group', 2);
break;
//联系人待完善
case "contact_no_complete":
$query->whereHas('contact', function ($q) {
$q->where('can_check_uids', request()->user->codeId)->where(function ($subQuery) {
$subQuery->where('supplier_consignee', '')
->orWhere('supplier_position', '')
->orWhere('supplier_email', '')
->orWhere('supplier_mobile', '')
->orWhere('supplier_telephone', '');
});
});
break;
}
return $query;
}
......
......@@ -2,14 +2,13 @@
namespace App\Http\Controllers;
use App\Http\Services\AdminUserService;
use App\Http\Services\LogService;
use App\Http\Services\RegionService;
use App\Http\Services\RoleService;
use App\Http\Services\SupplierContactService;
use App\Http\Services\SupplierAttachmentService;
use App\Http\Services\SupplierService;
use App\Http\Services\SupplierShareApplyService;
use App\Http\Services\SupplierStatisticsService;
use App\Http\Services\ViewCheckService;
use App\Http\Services\SupplierTagService;
use App\Http\Transformers\LogTransformer;
use App\Http\Transformers\SupplierTransformer;
use App\Model\IntracodeModel;
......@@ -66,6 +65,10 @@ class SupplierController extends Controller
$statistics = $supplierStatisticsService->getSupplierListStatistics();
$this->data['statistics'] = $statistics;
$this->data['validPerms'] = [];
//获取共用审核的条数
$applyService = new SupplierShareApplyService();
$applyData = $applyService->getAuditSupplierShareApplyList($request->user->userId);
$this->data['shareApplyCount'] = $applyData['total'];
return $this->view('供应商列表');
}
......@@ -96,6 +99,9 @@ class SupplierController extends Controller
]);
$this->data['province_city'] = implode(' | ', $regionNames);
$this->data['address'] = $supplierService->getAddress($supplierId);
$supplierAttachmentService = new SupplierAttachmentService();
$this->data['attachment'] = $supplierAttachmentService->getAttachment($supplierId);
// dd($supplierAttachmentService->getAttachment($supplierId));
return $this->view('供应商详情');
}
......@@ -165,8 +171,21 @@ class SupplierController extends Controller
}
//省市id,给控件用
$this->data['province_city'] = [$supplier['province_id'], $supplier['city_id']];
//获取标签情况
$tagService = new SupplierTagService();
$systemTags = $tagService->getTagsBySupplierId($supplierId, 1);
$customerTags = $tagService->getTagsBySupplierId($supplierId, 2);
$supplier['system_tags'] = $systemTags ? implode(',', $systemTags) : '';
$supplier['customer_tags'] = $customerTags ? implode(',', $customerTags) : '';
$supplierModel = new SupplierChannelModel();
$supplierModel->where('supplier_id', $supplierId)->update([
'customer_tags' => $supplier['customer_tags'],
'system_tags' => $supplier['system_tags'],
]);
$this->data['supplier'] = $supplier;
$this->data['address'] = $supplierService->getAddress($supplierId);
$supplierAttachmentService = new SupplierAttachmentService();
$this->data['attachment'] = $supplierAttachmentService->getAttachment($supplierId);
return $this->view('编辑供应商');
}
......@@ -178,8 +197,9 @@ class SupplierController extends Controller
$supplier = $model->where('supplier_id', $supplierId)->first();
//获取最后一条非分配渠道员的日志
$logModel = new LogModel();
$auditContent = $logModel->where('supplier_id', $supplierId)->where('action', '!=', '分配渠道开发员')
->where('action','!=','')
$auditContent = $logModel->where('supplier_id', $supplierId)
// ->where('action', '!=', '分配渠道开发员')
->where('action', '!=', '')
->where('type', '!=', 3)
->orderBy('id', 'desc')->first();
if (!empty($auditContent)) {
......@@ -273,4 +293,38 @@ class SupplierController extends Controller
return $this->view('审核供应商');
}
//拉黑供应商
public function BlockSupplier($request)
{
$supplierId = $request->get('supplier_id');
$supplierModel = new SupplierChannelModel();
$supplier = $supplierModel->where('supplier_id', $supplierId)->first()->toArray();
$this->data['supplier'] = $supplier;
return $this->view('加入黑名单');
}
//导出供应商详情表格
public function PrintSupplier($request)
{
$supplierService = new SupplierService();
$supplierId = $request->get('supplier_id');
$printData = $supplierService->getSupplierPrintData($supplierId);
$this->data['printData'] = $printData;
return $this->view('打印供应商详情');
}
//批量申请审批供应商
public function BatchApplyInReviewSupplier($request)
{
$supplierIds = $request->get('supplier_ids');
$this->data['supplierIds'] = $supplierIds;
$supplierIds = explode(',', $supplierIds);
$model = new SupplierChannelModel();
$suppliers = $model->whereIn('supplier_id', $supplierIds)->get()->toArray();
$transformer = new SupplierTransformer();
$suppliers = $transformer->transformList($suppliers);
$this->data['suppliers'] = $suppliers;
return $this->view('批量分配渠道开发员');
}
}
\ No newline at end of file
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Filter\SupplierLogFilter;
use App\Http\Services\LogService;
use App\Model\LogModel;
use App\Model\SupplierLogModel;
use Illuminate\Http\Request;
use DB;
class SupplierShareApplyController extends Controller
{
public function Entrance(Request $request, $id = 'index')
{
if ($request->path() == '/') {
$path = 'web/index';
} else {
$path = $request->path();
}
$this->data = [
'menus' => $request->menus,
'header' => $request->user->header,
'username' => $request->user->email,
'user_email' => $request->user->email,
'uri' => '/' . $path,
'id' => $id
];
return $this->$id($request);
}
public function __call($method, $parameters)
{
return $this->errhtml('Not', '没有这个页面');
}
//申请供应商共享
public function ApplySupplierShare($request)
{
return $this->view('申请供应商共享');
}
//审核共用申请(列表)
public function AuditSupplierShareApply()
{
return $this->view('审核供应商共享');
}
}
......@@ -38,10 +38,7 @@ class CheckLogin
}
$cookie = 'oa_user_id=' . $userId . '; oa_skey=' . $skey;
$rsp = curl($login['check'], '', false, false, $cookie);
if (!$rsp) {
if ($isApi) {
return ['errcode' => 10001, 'errmsg' => '鉴权失败'];
......
......@@ -67,5 +67,4 @@ class AdminUserService
$users = $intracodeModel->getEncodeByUserIds($userIds);
return $users;
}
}
\ No newline at end of file
......@@ -15,7 +15,7 @@ class BlacklistService
{
$supplierModel = new SupplierChannelModel();
$result = $supplierModel->where('supplier_id', $supplierId)->update([
'status' => -3,
'status' => SupplierChannelModel::STATUS_BLOCK,
'update_time' => time(),
]);
if ($result) {
......
......@@ -3,6 +3,8 @@
namespace App\Http\Services;
use App\Model\DepartmentModel;
use App\Model\UserInfoModel;
use DB;
//部门数据服务
......@@ -54,4 +56,50 @@ class DepartmentService
return $departmentIds;
}
//根据用户id获取上一层部门信息(专门为共用申请设置的方法)
/*
针对共用申请:
不同部门的情况还不同,因为线上的数据错乱了,不同部门的分级有问题
比如运营老大被分在了顶级部门(运营部),联营采购老大和自营采购老大被分在了二级部门
但是联营采购老大的部下,在三级部门,而且自营采购老大的部下,在二级部门,和自己同一个部门
但是目前用这个供应商系统的,只会有这三个部门,所以要找出一个合理的处理方法
所以这边的方法如下 :
运营和联营采购无脑找上一级.
因为运营老大在顶级,找不到上一级,那就取顶级即可
联营采购本来向上找一级就是对的(除了被查找的人是联营采购的老大....那就不要往上找了)
自营采购比较特殊,因为领导和部下都在这一个层级,所以不能往上找,往上找就是顶级的采购部了,顶级采购部是找不到人的(没有用户的部门id是顶级采购部id)
以上所说的情况,都是建立在部门架构不变以及部门老大维持层级不变的前提下进行的
*/
public function getUpperDepartmentByUserIdForShareApply($userId)
{
$userModel = new UserInfoModel();
$departmentId = $userModel->where('userId', $userId)->value('department_id');
if (empty($departmentId)) {
return [];
}
$departmentModel = new DepartmentModel();
//先判断是不是自营采购部门id
if ($departmentId == config('field.ZiYingDepartmentId')) {
return $departmentModel->where('department_id', $departmentId)->first()->toArray();
} else {
$department = $departmentModel->where('department_id', $departmentId)->first();
//如果当前的部门id已经是联营采购部门Id
if ($departmentId == config('field.LiangYingDepartmentId')) {
return $department->toArray();
} else {
if (!empty($department)) {
$department = $department->toArray();
//找出自己的parent_id,如果是0代表自己就是顶级部门信息了
if ($department['parent_id'] == 0) {
return $department;
}
$department = $departmentModel->where('department_id',
$department['parent_id'])->first()->toArray();
return $department;
}
}
}
return [];
}
}
\ No newline at end of file
<?php
namespace App\Http\Services;
//后台用户相关信息服务
......@@ -8,12 +7,9 @@ use App\Http\Controllers\Filter\LogFilter;
use App\Http\Transformers\LogTransformer;
use App\Http\Transformers\SupplierTransformer;
use App\Model\LogModel;
use App\Model\SupplierChannelModel;
use Illuminate\Support\Facades\DB;
class LogService
{
//添加日志
public function AddLog($supplierId, $type, $action, $content, $remark = '')
{
......@@ -99,30 +95,6 @@ class LogService
$content = 'Sku审核规则由 [ ' . $oldValue . ' ] 改成 [ ' . $newValue . ' ];';
$result[] = $content;
}
if ($key == 'qualification_photos') {
$oldFiles = json_decode($oldSupplier['qualification_photos'], true);
$oldFileNames = array_map(function ($file) {
return $file['file_name'];
}, $oldFiles);
$newFiles = json_decode($newSupplier['qualification_photos'], true);
$newFileNames = array_map(function ($file) {
return $file['file_name'];
}, $newFiles);
//对比文件名变化
$diffKeys = array_keys(array_diff_assoc($newFileNames, $oldFileNames));
$content = '';
foreach ($diffKeys as $key) {
$oldFileName = array_get($oldFileNames, $key);
$oldFileName = $oldFileName == '选择文件上传' ? ' ' : $oldFileName;
$newFileName = array_get($newFileNames, $key);
if ($newFileName == "选择文件上传") {
continue;
}
$content .= array_get(config('fixed.FileNameMapping'),
$key) . '由 [ ' . $oldFileName . ' ] 修改为 [' . $newFileName . ']; ';
}
$result[] = $content;
}
if ($key == 'extra_fee') {
$oldFee = json_decode($oldSupplier['extra_fee'], true);
$newFee = json_decode($newSupplier['extra_fee'], true);
......@@ -147,7 +119,6 @@ class LogService
$contact = json_decode($contact, true);
//更新
if (!empty($contact['old_contact']) && !empty($contact['new_contact'])) {
// $diffCols = array_diff($contact['old_contact'], $contact['new_contact']);
$oldContent = $this->contactDesc($contact['old_contact']);
$newContent = $this->contactDesc($contact['new_contact']);
return $oldContent . ' 修改为 ' . $newContent;
......
<?php
namespace App\Http\Services;
//价格相关服务
use App\Model\RedisModel;
use Illuminate\Support\Facades\DB;
//用于判断是否已经查看的服务
class PriceService
class PriceService
{
//获取最小阶梯的价格
public function getMoqPrice($price)
......
......@@ -50,4 +50,20 @@ class SupplierAddressService
return $result;
}
//保存发货地址
public function saveShippingAddress($supplierId,$address)
{
$supplierModel = new SupplierChannelModel();
$supplierCode = $supplierModel->where('supplier_id', $supplierId)->value('supplier_code');
//组装成两条数据(鬼知道以前为啥存两条)
$shippingData = [
'supplier_id' => $supplierId,
'supplier_code' => $supplierCode,
'address' => $address,
'address_type' => 1,
];
$addressModel = new SupplierAddressModel();
$addressModel->insert($shippingData);
}
}
\ No newline at end of file
<?php
namespace App\Http\Services;
//后台用户相关信息服务
use App\Model\RedisModel;
use App\Model\SupplierAttachmentModel;
use Illuminate\Support\Facades\DB;
//用于判断是否已经查看的服务
class SupplierAttachmentService
{
public function getAttachment($supplierId)
{
$attachmentModel = new SupplierAttachmentModel();
$attachmentData = $attachmentModel->where('supplier_id', $supplierId)->first();
$attachment = [];
if (!empty($attachmentData)) {
$attachment = json_decode($attachmentData,true);
$attachment = array_map(function ($item) {
return json_decode($item, true);
}, $attachment);
}
return $attachment;
}
public function saveAttachment($supplierId, $attachment)
{
$attachmentModel = new SupplierAttachmentModel();
$attachmentData = $attachmentModel->where('supplier_id', $supplierId)->first();
if (!empty($attachmentData)) {
$attachment['update_time'] = time();
$attachmentModel->where('supplier_id', $supplierId)->update($attachment);
}else{
$attachment['create_time'] = time();
$attachment['supplier_id'] = $supplierId;
$attachmentModel->insert($attachment);
}
}
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ namespace App\Http\Services;
use App\Model\LogModel;
use App\Model\RedisModel;
use App\Model\SupplierAttachmentModel;
use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel;
......@@ -13,29 +14,16 @@ class SupplierAuditService
public function auditSupplier($supplierId, $status, $rejectReason)
{
$model = new SupplierChannelModel();
//判断当前要审核的供应商是不是想要被禁用的
//因为想要禁用,需要审核后才能禁用的,不能直接修改成禁用
//要找个地方存起来是不是想要禁用
$redis = new RedisModel();
$disableExist = $redis->hget('audit_disable_supplier_list', $supplierId);
if ($disableExist) {
if ($status == SupplierChannelModel::STATUS_PASSED) {
$status = SupplierChannelModel::STATUS_DISABLE;
} else {
//因为只有通过状态的供应商才能发起禁用审核,所以拒绝禁用申请,自然会变回启用状态
$status = SupplierChannelModel::STATUS_PASSED;
}
}
//先找出原来供应商的状态
$supplierModel = new SupplierChannelModel();
$supplier = $supplierModel->where('supplier_id', $supplierId)->first()->toArray();
//如果需要复审并且审核状态为待审核,则代表这次审核为第一次审核
//如果需要复审并且审核状态为审核中,则代表这次审核为第一次审核
if ($supplier['status'] == SupplierChannelModel::STATUS_IN_REVIEW && $supplier['need_review'] == 1) {
//第一次审核,通过是将审核状态置为待复审
//通过
if ($status == SupplierChannelModel::STATUS_PASSED) {
$dbStatus = SupplierChannelModel::STATUS_PENDING;
$dbStatus = SupplierChannelModel::STATUS_NEED_REVIEW;
} else {
//不通过
$dbStatus = $status;
......@@ -48,7 +36,7 @@ class SupplierAuditService
$result = $model->where('supplier_id', $supplierId)->update($update);
//如果是待复审状态,通过的话还要将是否需要复审状态置为0
} elseif ($supplier['status'] === SupplierChannelModel::STATUS_PENDING) {
} elseif ($supplier['status'] === SupplierChannelModel::STATUS_NEED_REVIEW) {
if ($status == SupplierChannelModel::STATUS_PASSED) {
$result = $model->where('supplier_id', $supplierId)->update([
'update_time' => time(),
......@@ -73,22 +61,14 @@ class SupplierAuditService
]);
}
if ($disableExist) {
$redis->hdel('audit_disable_supplier_list', $supplierId);
}
$action = '审核供应商';
if ($result) {
//记录日志
if ($disableExist) {
$auditStatus = $status == SupplierChannelModel::STATUS_DISABLE ? '审核通过,禁用供应商' : '审核不通过,原因是 : ' . $rejectReason;
//如果状态是复审
if ($supplier['status'] == SupplierChannelModel::STATUS_NEED_REVIEW) {
$auditStatus = $status == SupplierChannelModel::STATUS_PASSED ? '复审通过' : '复审不通过,原因是 : ' . $rejectReason;
$action = '复审供应商';
} else {
//如果状态是复审
if ($supplier['status'] == SupplierChannelModel::STATUS_PENDING) {
$auditStatus = $status == SupplierChannelModel::STATUS_PASSED ? '复审通过' : '复审不通过,原因是 : ' . $rejectReason;
$action = '复审供应商';
} else {
$auditStatus = $status == SupplierChannelModel::STATUS_PASSED ? '审核通过' : '审核不通过,原因是 : ' . $rejectReason;
}
$auditStatus = $status == SupplierChannelModel::STATUS_PASSED ? '审核通过' : '审核不通过,原因是 : ' . $rejectReason;
}
$logService = new LogService();
$content = $auditStatus;
......@@ -189,8 +169,8 @@ class SupplierAuditService
return true;
}
//判断是否要进入待审核状态,因为部分字段修改是不需要走审核的
public function checkNeedAudit($supplierId, $channel)
//判断是否要进入审核中状态,因为部分字段修改是不需要走审核的
public function checkNeedAudit($supplierId, $channel, $attachment)
{
$notNeedAuditField = [
'register_company_name',
......@@ -198,7 +178,9 @@ class SupplierAuditService
'province_id',
'city_id',
'established_time',
'credit_investigation'
'credit_investigation',
'system_tags',
'customer_tags',
];
//先找出目前数据库里面的数据
$selectField = array_keys($channel);
......@@ -209,6 +191,15 @@ class SupplierAuditService
return true;
}
$attachmentModel = new SupplierAttachmentModel();
//判断附件有没有变化,有变化也要进入审核
$oldAttachment = $attachmentModel->select(array_keys(config('fixed.FileNameMapping')))
->where('supplier_id', $supplierId)->first();
$oldAttachment = !empty($oldAttachment) ? $oldAttachment->toArray() : [];
$newAttachment = $attachment;
if ($oldAttachment != $newAttachment) {
return true;
}
$supplier = $model->select($selectField)->where('supplier_id', $supplierId)->first()->toArray();
$changeField = [];
foreach ($supplier as $key => $value) {
......@@ -216,7 +207,6 @@ class SupplierAuditService
$changeField[] = $key;
}
}
foreach ($changeField as $filed) {
//只要有一个不存在于不需要审核的字段,就返回需要审核
if (!in_array($filed, $notNeedAuditField)) {
......
......@@ -46,17 +46,31 @@ class SupplierContactService
//还要将采购的数据整理重新写入
$supplierId = $contact['supplier_id'];
$supplierModel = new SupplierChannelModel();
//去判断该供应商是否已经有相同的can_check_uids并且是空联系人
$needReplaceContact = $this->getNeedReplaceContact($supplierId, $contact['can_check_uids']);
if (!empty($contact['contact_id'])) {
$contact['update_time'] = time();
$contactId = $contact['contact_id'];
$oldContact = $model->where('contact_id', $contact['contact_id'])->first()->toArray();
$result = $model->where('contact_id', $contact['contact_id'])->update($contact);
} else {
$oldContact = [];
$contact['add_time'] = time();
$contact['admin_id'] = request()->user->userId;
$result = $model->insertGetId($contact);
$contactId = $result;
//进行新增操作的时候,还要去判断是否这次新增的采购员ID在库里面是否有空白联系人的记录
//有的话直接替换就可以
if ($needReplaceContact) {
$oldContact = $model->where('contact_id', $needReplaceContact['contact_id'])->first()->toArray();
$contactId = $needReplaceContact['contact_id'];
$contact['contact_id'] = $contactId;
$contact['update_time'] = time();
$contact['admin_id'] = request()->user->userId;
$result = $model->where('contact_id', $contactId)->update($contact);
} else {
$oldContact = [];
$contact['add_time'] = time();
$contact['admin_id'] = request()->user->userId;
$result = $model->insertGetId($contact);
$contactId = $result;
}
}
//找出所有的联系人对应的采购id,更新主表
$canCheckUids = $model->where('supplier_id', $supplierId)->pluck('can_check_uids');
......@@ -80,7 +94,7 @@ class SupplierContactService
//修改供应商为审核状态
$supplierModel->where('supplier_id', $contact['supplier_id'])->update([
'update_time' => time(),
'status' => 1,
'status' => SupplierChannelModel::STATUS_PENDING,
]);
}
......@@ -96,7 +110,21 @@ class SupplierContactService
return $result;
}
//判断是否要进入待审核状态,因为部分字段修改是不需要走审核的
//判断是否需要替换掉空的联系方式而不是新增,因为新增的时候,可能添加的采购已经在数据库有了(之前从金蝶导过来的)
//有的话,就把这次新增的联系方式更新到这个采购里面去
public function getNeedReplaceContact($supplierId, $canCheckUids)
{
$contactModel = new SupplierContactModel();
$contact = $contactModel->where('supplier_id', $supplierId)->where('can_check_uids', $canCheckUids)
->where('supplier_consignee', '')
->where('supplier_position', '')
->where('supplier_email', '')
->where('supplier_mobile', '')
->where('supplier_telephone', '')->first();
return !empty($contact) ? $contact->toArray() : [];
}
//判断是否要进入审核中状态,因为部分字段修改是不需要走审核的
private function checkNeedAudit($oldContact, $newContact)
{
$notNeedAuditField = [
......@@ -114,4 +142,56 @@ class SupplierContactService
}
return false;
}
//如果申请人属于联营采购部/自营采购部,业务负责人取绑定的采购员为申请人的联系人(如果有多条,随机取一条);
//如果申请人属于渠道部,渠道开发员没有设置采购,则显示为空;如果渠道开发员显示自己为采购,显示自己对应的联系人;如果创建其他采购,显示创建采购对应的联系人(如果有多条,随机取一条)
//获取用于打印的联系方式
public function getContactForPrint($supplierId)
{
$userId = request()->user->userId;
$codeId = request()->user->codeId;
$contactModel = new SupplierContactModel();
$contact = $contactModel->where('can_check_uids', $codeId)->where('supplier_id', $supplierId)
->first();
$contact = !empty($contact) ? $contact->toArray() : [];
if (empty($contact)) {
$contact = $contactModel->where('admin_id', $userId)->where('supplier_id', $supplierId)
->first();
$contact = !empty($contact) ? $contact->toArray() : [];
}
return $contact;
}
//通过采购员编码直接创建空白的默认联系方式
public function createContactByChannelUid($supplierId, $channelUid)
{
//先去判断是否已经有对应的采购
$contactModel = new SupplierContactModel();
$count = $contactModel->where('supplier_id', $supplierId)->where('can_check_uids', $channelUid)->count();
if ($count) {
return true;
}
$contact['can_check_uids'] = $channelUid;
$contact['supplier_id'] = $supplierId;
$contact['add_time'] = time();
$contact['admin_id'] = request()->user->userId;
$result = $contactModel->insert($contact);
if ($result) {
$channelUids = $contacts = $contactModel->where('supplier_id',$supplierId)->pluck('can_check_uids')->toArray();
$supplierModel = new SupplierChannelModel();
$result = $supplierModel->where('supplier_id',$supplierId)->update([
'channel_uid' => implode(',', $channelUids),
'update_time' => time(),
]);
$adminService = new AdminUserService();
$user = $adminService->getAdminUserInfoByCodeId($channelUid);
$channelUserName = array_get($user, 'name');
//还要记录日志
$logService = new LogService();
$content = "共用申请审核通过,添加采购员 : " . $channelUserName;
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, '添加采购员', $content);
}
return $result;
}
}
\ No newline at end of file
<?php
namespace App\Http\Services;
//后台用户相关信息服务
use App\Http\Transformers\SupplierShareApplyTransformer;
use App\Model\SupplierChannelModel;
use App\Model\SupplierShareApplyModel;
//用于判断是否已经查看的服务
class SupplierShareApplyService
{
public function getSupplierShareApplyList($userId)
{
$applyModel = new SupplierShareApplyModel();
$limit = request()->get('limit', 10);
$query = $applyModel::with([
'supplier' => function ($q) {
$q->select(['supplier_name', 'supplier_id']);
},
'department',
'apply_department'
])->where('create_uid', $userId)->orderBy('id', 'desc');
$list = $query->paginate($limit)->toArray();
$transformer = new SupplierShareApplyTransformer();
$list['data'] = $transformer->transformList($list['data']);
return $list;
}
//获取申请可以选择的部门
/*
不同部门的情况还不同,因为线上的数据错乱了,不同部门的分级有问题
比如运营老大被分在了顶级部门(运营部),联营采购老大和自营采购老大被分在了二级部门
但是联营采购老大的部下,在三级部门,而且自营采购老大的部下,在二级部门,和自己同一个部门
但是目前用这个供应商系统的,只会有这三个部门,所以要找出一个合理的处理方法
所以这边的方法如下 :
运营和联营采购无脑找上一级.
因为运营老大在顶级,找不到上一级,那就取顶级即可
联营采购本来向上找一级就是对的(除了被查找的人是联营采购的老大....那就不要往上找了)
自营采购比较特殊,因为领导和部下都在这一个层级,所以不能往上找,往上找就是顶级的采购部了,顶级采购部是找不到人的(没有用户的部门id是顶级采购部id)
以上所说的情况,都是建立在部门架构不变以及部门老大维持层级不变的前提下进行的
*/
public function getApplyCanUseDepartments($supplier)
{
$supplier = $supplier->toArray();
//找出采购,开发员,创建者所属部门,一个供应商可能和多个部门相关,因为采购可能有自营或者联营的
$purchaseUid = $supplier['purchase_uid'];
$channelUids = explode(',', $supplier['channel_uid']);
$createUid = $supplier['create_uid'];
$departmentService = new DepartmentService();
$adminService = new AdminUserService();
$purchaseUser = $adminService->getAdminUserInfoByCodeId($purchaseUid);
$purchaseDepartment = $departmentService->getUpperDepartmentByUserIdForShareApply($purchaseUser['userId']);
$createDepartment = $departmentService->getUpperDepartmentByUserIdForShareApply($createUid);
$allDepartments = [];
if (!empty($purchaseDepartment)) {
$allDepartments[] = $purchaseDepartment;
}
if (!in_array($createDepartment, $allDepartments)) {
$allDepartments[] = $createDepartment;
}
if (!empty($channelUids)) {
foreach ($channelUids as $channelUid) {
$channelUser = $adminService->getAdminUserInfoByCodeId($channelUid);
$channelDepartment = $departmentService->getUpperDepartmentByUserIdForShareApply($channelUser['userId']);
//为什么不判断只要有三个部门就跳出,因为以后可能会有其它部门的人当采购
if (!in_array($channelDepartment, $allDepartments) && !empty($channelDepartment)) {
$allDepartments[] = $channelDepartment;
}
}
}
$allDepartments = array_filter($allDepartments, function ($department) {
return !empty($department);
});
return $allDepartments;
}
//保存申请
public function saveSupplierShareApply($map)
{
$data = $map;
$data['status'] = 0;
$data['create_time'] = time();
$data['create_uid'] = request()->user->userId;
$departmentService = new DepartmentService();
$department = $departmentService->getUpperDepartmentByUserIdForShareApply($data['create_uid']);
$data['department_id'] = $department['department_id'];
$applyModel = new SupplierShareApplyModel();
return $applyModel->insert($data);
}
//校验是否已经有存在的申请
public function checkHasNoFinishApply($map)
{
$applyModel = new SupplierShareApplyModel();
$count = $applyModel->where('supplier_id', $map['supplier_id'])
->where('apply_code_id', $map['apply_code_id'])->where('apply_department_id', $map['apply_department_id'])
->whereNotIn('status', [$applyModel::STATUS_AUDIT_REJECT, $applyModel::STATUS_REVIEW_REJECT])->count();
return $count;
}
public function getAuditSupplierShareApplyList($userId)
{
//1.先获取自己的部门ID
$departmentService = new DepartmentService();
$topDepartment = $departmentService->getUpperDepartmentByUserIdForShareApply($userId);
$departmentId = $topDepartment['department_id'];
$applyModel = new SupplierShareApplyModel();
$query = $applyModel::with([
'supplier' => function ($q) {
$q->select(['supplier_name', 'supplier_id']);
},
'department',
'apply_department',
'apply_user'
])->where(function ($q) use ($departmentId) {
//当要判断申请者所在部门的时候,要审核人为空,因为审核这一步是所在部门的人审核的
$q->where('department_id', $departmentId)->where('audit_uid', 0);
})->orWhere(function ($q) use ($departmentId) {
//当要判断申请者申请的部门的时候,要复审人为空,因为复审这一步是被申请部门的人审核的
$q->where('apply_department_id', $departmentId)->where('review_uid', 0)->where('audit_uid', '!=', 0)
->where('status', SupplierShareApplyModel::STATUS_NEED_REVIEW);
})->orderBy('id', 'desc');
$limit = request()->get('limit', 20);
$list = $query->paginate($limit)->toArray();
$transformer = new SupplierShareApplyTransformer();
$list['data'] = $transformer->transformList($list['data']);
return $list;
}
//审核供应商共用申请
public function auditSupplierShareApply($id, $userId, $statusName)
{
//先找出这个审核id对应的审核状态
//如果是初审(审核),就要处理初审,通过的话进入复审,而不是直接通过
$applyModel = new SupplierShareApplyModel();
$apply = $applyModel->where('id', $id)->first()->toArray();
//初审
if ($apply['status'] == $applyModel::STATUS_PENDING) {
$apply['status'] = $statusName == 'pass' ? $applyModel::STATUS_NEED_REVIEW : $applyModel::STATUS_AUDIT_REJECT;
$apply['audit_uid'] = $userId;
$apply['audit_time'] = time();
} else {
//复审
$apply['status'] = $statusName == 'pass' ? $applyModel::STATUS_PASS : $applyModel::STATUS_REVIEW_REJECT;
$apply['review_time'] = time();
$apply['review_uid'] = $userId;
//还要去将当前请求人的内部编码写到采购里面去
if ($statusName == 'pass') {
$contactService = new SupplierContactService();
$contactService->createContactByChannelUid($apply['supplier_id'], $apply['apply_code_id']);
//然后自动转正
$supplierModel = new SupplierChannelModel();
$supplier = $supplierModel->where('supplier_id', $apply['supplier_id'])->first()->toArray();
$supplierService = new SupplierService();
$supplierService->autoChangeIsType($supplier);
}
}
return $applyModel->where('id', $id)->update($apply);
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@
namespace App\Http\Services;
use App\Http\Controllers\Filter\SupplierFilter;
use App\Model\RedisModel;
use App\Model\SupplierChannelModel;
use Illuminate\Support\Facades\DB;
......@@ -12,11 +13,17 @@ class SupplierStatisticsService
//获取供应商列表需要统计的信息
public function getSupplierListStatistics()
{
$redis = new RedisModel();
$result = json_decode($redis->get('supplier_list_statistics'), true);
if ($result) {
return $result;
}
$total = $this->getStatisticsCount('all');
//待复审
$pending = $this->getStatisticsCount('pending');
$needReview = $this->getStatisticsCount('need_review');
//待审核
$pending = $this->getStatisticsCount('pending');
//审核中
$inReview = $this->getStatisticsCount('in_review');
//通过
$passed = $this->getStatisticsCount('passed');
......@@ -26,6 +33,8 @@ class SupplierStatisticsService
$disable = $this->getStatisticsCount('disable');
//没有渠道开发员
$noPurchaseUid = $this->getStatisticsCount('no_purchase_uid');
//没有采购
$noChannelUid = $this->getStatisticsCount('no_channel_uid');
//存在无效(离职)采购员
$invalidChannelUid = $this->getStatisticsCount('invalid_channel_uid');
//存在无效(离职)开发员
......@@ -34,19 +43,33 @@ class SupplierStatisticsService
$toFollowUp = $this->getStatisticsCount('to_follow_up');
//没有sku的
$noSku = $this->getStatisticsCount('no_sku');
//拉黑的
$block = $this->getStatisticsCount('block');
//没有品牌协议附件的
$noQualityAssuranceAgreement = $this->getStatisticsCount('no_quality_assurance_agreement');
//有标签的(客户指定供应商)
$hasTagSupplier = $this->getStatisticsCount('has_supplier_tag');
//联系人未完善
$concatNoComplete = $this->getStatisticsCount('contact_no_complete');
$result = [
'total' => $total,
'need_review' => $needReview,
'pending' => $pending,
'in_review' => $inReview,
'passed' => $passed,
'rejected' => $rejected,
'disable' => $disable,
'block' => $block,
'no_purchase_uid' => $noPurchaseUid,
'no_channel_uid' => $noChannelUid,
'invalid_channel_uid' => $invalidChannelUid,
'invalid_purchase_uid' => $invalidPurchaseUid,
'to_follow_up' => $toFollowUp,
'no_sku' => $noSku,
'no_quality_assurance_agreement' => $noQualityAssuranceAgreement,
'has_supplier_tag' => $hasTagSupplier,
'contact_no_complete' => $concatNoComplete,
];
$result = array_map(function ($value) {
if ($value > 999) {
......@@ -54,16 +77,17 @@ class SupplierStatisticsService
}
return $value;
}, $result);
$redis->set('supplier_list_statistics', json_encode($result));
$redis->expire('supplier_list_statistics', 1);
return $result;
}
private function getStatisticsCount($type)
{
$model = new SupplierChannelModel();
$model = $model->where('supplier_id','>',0);
//显示默认的数据(有权限逻辑)
$filter = new SupplierFilter();
$model = $model->where('supplier_code', '!=', '');
return $filter->defaultFilter($model, $type)->count();
}
}
\ No newline at end of file
<?php
namespace App\Http\Services;
//后台用户相关信息服务
use GuzzleHttp\Client;
use GuzzleHttp\RequestOptions;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class SupplierTagService
{
private $client;
public function __construct()
{
$this->client = new Client([
'base_uri' => config('website.TagUrl'),
]);
}
//标签系统获取标签
public function getSystemTags()
{
$response = $this->client->get('/get?tag_use=14');
$data = json_decode($response->getBody()->getContents(), true);
$data = !empty($data['data']) ? $data['data'] : [];
$result = [];
foreach ($data as $key => $value) {
if (empty($value)) {
continue;
}
$result[] = [
'tag_id' => $value,
'tag_name' => $value,
];
}
return $result;
}
//获取供应商对应的标签
public function getTagsBySupplierId($supplierId, $type = 1)
{
//1是系统标签,2是自定义标签
$tagUse = $type == 1 ? 14 : 4;
$response = $this->client->get('/get?tag_use=' . $tagUse . '&req_id=' . $supplierId);
$data = json_decode($response->getBody()->getContents(), true);
return !empty($data['data']) ? $data['data'] : [];
}
//新增/修改标签和供应商id对应关系到标签系统
public function saveTags($supplierId, $tagUse, $newTags, $oldTags)
{
if ((!$newTags) && (!$oldTags)) {
return true;
}
$newTags = explode(',', $newTags);
$oldTags = explode(',', $oldTags);
//先区分哪些需要删除,哪些需要修改
$allSystemTags = array_merge($newTags, $oldTags);
$deleteTags = [];
$keepTags = [];
foreach ($allSystemTags as $tag) {
//在新标签,不在老标签,就是新增,否则就是删除
if (in_array($tag, $newTags) && !in_array($tag, $oldTags)) {
$keepTags[] = $tag;
}
if (!in_array($tag, $newTags) && in_array($tag, $oldTags)) {
$deleteTags[] = $tag;
}
}
$params = [];
foreach ($deleteTags as $tag) {
$params[$tag] = [
'tag_use' => $tagUse,
'business' => 5,
'modifier' => 1000,
'modifier_name' => 'admin',
'data' => [
[
'id' => $supplierId,
'tag_status' => 0,
]
]
];
}
foreach ($keepTags as $tag) {
$params[$tag] = [
'tag_use' => $tagUse,
'business' => 5,
'modifier' => 1000,
'modifier_name' => 'admin',
'data' => [
[
'id' => (int)$supplierId,
'tag_status' => 1,
]
]
];
}
//没有参数就直接跳过吧
if (empty($params)) {
return true;
}
$response = $this->client->post('/update', [
RequestOptions::JSON => $params,
]);
$data = json_decode($response->getBody()->getContents(), true);
if (!empty($data['status']) && $data['status'] == 1) {
return true;
} else {
Log::error('保存标签失败,' . json_encode($data));
}
}
}
\ No newline at end of file
<?php
namespace App\Http\Transformers;
use App\Http\Services\AdminUserService;
use App\Http\Services\LogService;
class SupplierShareApplyTransformer
{
public function transformList($list)
{
foreach ($list as &$item) {
$item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
$item['status_name'] = array_get(config('field.SupplierShareApplyStatus'), $item['status']);
}
unset($item);
return $list;
}
}
\ No newline at end of file
......@@ -30,12 +30,13 @@ class SupplierTransformer
$supplier = $this->getStockupType($supplier);
$supplier['supplier_group'] = array_get(config('fixed.SupplierGroup'), $supplier['supplier_group'], '未设置');
$supplier['region_name'] = array_get(config('fixed.Region'), $supplier['region']);
$supplier['create_time'] = $supplier['create_time']?date('Y-m-d H:i:s', $supplier['create_time']):'';
$supplier['create_time'] = $supplier['create_time'] ? date('Y-m-d H:i:s', $supplier['create_time']) : '';
$supplier['audit_time'] = $supplier['audit_time'] ? date('Y-m-d H:i:s', $supplier['audit_time']) : '';
$supplier['update_time'] = $supplier['update_time'] ? date('Y-m-d H:i:s', $supplier['update_time']) : '';
$supplier['channel_username'] = $this->getChannelUserNames($supplier['channel_uid']);
$supplier['purchase_username'] = array_get($users, $supplier['purchase_uid']);
$supplier['status_name'] = array_get(config('fixed.SupplierStatus'), $supplier['status']);
$supplier['region_name'] = array_get(config('fixed.Region'), $supplier['region'], '暂无');
$supplier['contact_num'] = $this->getContactNum($supplier['supplier_id']);
$supplier['has_sku'] = $supplier['sku_num'] ? '是' : '否';
$supplier['is_own'] = $supplier['create_uid'] == request()->user->userId ? "创建" : "指派";
......@@ -91,7 +92,6 @@ class SupplierTransformer
}
$intracodeModel = new IntracodeModel();
$users = $intracodeModel->getSampleEncode(true);
$supplier['qualification_photos'] = trim($supplier['qualification_photos']);
$supplier['stockup_type_data'] = $this->transformStockupTypeData($supplier['stockup_type']);
$supplier['established_time'] = !empty($supplier['established_time']) ? date('Y-m-d',
$supplier['established_time']) : '';
......@@ -107,8 +107,7 @@ class SupplierTransformer
$supplier['create_time'] = $supplier['create_time'] ? date('Y-m-d H:i:s', $supplier['create_time']) : '';
$supplier['channel_username'] = $this->getChannelUserNames($supplier['channel_uid']);
$supplier['purchase_username'] = array_get($users, $supplier['purchase_uid']);
$supplier['yunxin_channel_username'] = array_get($users, array_get($supplier,'yunxin_channel_uid'));
$supplier['qualification_photos'] = $this->getPhotosDataForForm($supplier['qualification_photos']);
$supplier['yunxin_channel_username'] = array_get($users, array_get($supplier, 'yunxin_channel_uid'));
$uploadRulerService = new SupplierSkuUploadRulerService();
$supplier['sku_upload_ruler'] = $uploadRulerService->getSkuUploadRuler($supplier['sku_upload_ruler']);
$ruleService = new SupplierSkuAuditRulerService();
......@@ -126,6 +125,10 @@ class SupplierTransformer
$supplier['last_update_name'] = $log['admin_name'] ?: '无';
$supplier['last_update_time'] = empty($supplier['last_update_time']) ? date('Y-m-d H:i:s',
$log['add_time']) : '无';
$supplier['has_certification_name'] = array_get(config('fixed.CertificationStatus'),
$supplier['has_certification'], '');
$supplier['sku_tag_name'] = array_get(config('field.SkuTag'), $supplier['sku_tag'], '无');
$supplier['sku_mode_name'] = array_get(config('field.SkuMode'), $supplier['sku_mode'], '无');
return $supplier;
}
......@@ -153,26 +156,6 @@ class SupplierTransformer
return $supplier;
}
private function getPhotosDataForForm($photos)
{
if (empty($photos)) {
return [];
}
$photos = json_decode($photos, true);
if (empty($photos['business_license'])) {
return [];
}
$data = [];
foreach ($photos as $name => $photo) {
$data[$name] = [
'value' => $photo['url'] . '|_|' . $photo['file_name'],
'file_name' => $photo['file_name'] ?: '选择文件上传',
'url' => $photo['url'],
];
}
return $data;
}
private function getStockupType($supplier)
{
$supplier['stockup_type'] = explode(',', $supplier['stockup_type']);
......@@ -187,9 +170,13 @@ class SupplierTransformer
{
$mainBrandsIds = explode(',', $mainBrandsIds);
$redis = new RedisModel();
$brands = $redis->hmget('brand', $mainBrandsIds);
$brands = implode(',', $brands);
return $brands;
$brands = $redis->hmget('standard_brand', $mainBrandsIds);
$brandNames = '';
foreach ($brands as $brand) {
$brand = json_decode($brand, true);
$brandNames = $brandNames .' | '. $brand['brand_name'];
}
return $brandNames;
}
public function transformStockupTypeData($stockupType)
......@@ -201,4 +188,65 @@ class SupplierTransformer
return [];
}
//转换表单数据
public function transformPostData($channel)
{
if (!empty($channel['stockup_type'])) {
$stockupType = array_keys($channel['stockup_type']);
$stockupType = !empty($stockupType) ? implode(",", $stockupType) : '';
$channel['stockup_type'] = $stockupType;
}
if (!empty($channel['currency'])) {
if ($channel['currency'] != 1) {
$channel['tax_number'] = '';
}
}
if (empty($channel['purchase_uid'])) {
unset($channel['purchase_uid']);
}
if (!empty($channel['system_tags'])) {
$channel['system_tags'] = rtrim($channel['system_tags'], ',');
}
if (!empty($channel['customer_tags'])) {
$channel['customer_tags'] = rtrim($channel['customer_tags'], ',');
}
$channel['cn_ratio'] = empty($channel['cn_ratio']) ? 1 : $channel['cn_ratio'];
$channel['us_ratio'] = empty($channel['us_ratio']) ? 1 : $channel['us_ratio'];
$channel['cn_delivery_time'] = $channel['cn_delivery_time'] ? $channel['cn_delivery_time'] . $channel['cn_delivery_time_period'] : '';
$channel['us_delivery_time'] = $channel['us_delivery_time'] ? $channel['us_delivery_time'] . $channel['us_delivery_time_period'] : '';
unset($channel['upload_file']);
$channel['established_time'] = strtotime($channel['established_time']);
//省市选择的处理
if (!empty($channel['province_city'])) {
$regionData = explode(',', $channel['province_city']);
$channel['province_id'] = !empty($regionData[0]) ? $regionData[0] : 0;
$channel['city_id'] = !empty($regionData[1]) ? $regionData[1] : 0;
}
//判断所在区域,如果不是中国,则要把省市去掉
if ($channel['region'] != 2) {
$channel['province_id'] = $channel['city_id'] = 0;
}
unset($channel['province_city']);
$skuUploadRulerService = new SupplierSkuUploadRulerService();
$channel['sku_upload_ruler'] = $skuUploadRulerService->getSkuUploadRulerForDB($channel['sku_upload_ruler']);
$attachment = [];
$attachmentFields = config('field.AttachmentFields');
foreach ($channel as $key => $field) {
if (in_array($key, $attachmentFields)) {
$attachment[$key] = $field;
unset($channel[$key]);
}
}
$channel['attachment'] = $attachment;
return $channel;
}
}
\ No newline at end of file
......@@ -20,15 +20,20 @@ class SupplierValidator
'supplier_name' => 'required',
'legal_representative' => 'required',
'stockup_type' => 'required',
'supplier_address' => 'required',
'main_brands' => 'required',
'main_customers' => 'max:100',
'ticket_time' => 'max:20',
// 'supplier_address' => 'required',
'region' => 'required',
'cn_delivery_time' => 'regex:/^\d+\-\d$/',
'us_delivery_time' => 'regex:/^\d+\-\d$/',
'shipping_address' => 'max:100',
'billing_period_detail' => 'required|max:100',
'return_address' => 'max:100',
'return_consignee' => 'max:50',
'return_phone' => 'max:50',
'upload_file.business_license' => 'required',
'business_license' => 'required',
// 'established_time' => 'required',
'cn_ratio' => 'min:1',
'us_ratio' => 'min:1',
];
......@@ -62,19 +67,21 @@ class SupplierValidator
return $validator->errors()->first();
}
$supplierId = $request->get('supplier_id');
//检验名称是否已经存在数据库
$supplierModel = new SupplierChannelModel();
$contactModel = new SupplierContactModel();
$companyNameCount = 0;
if (empty($request->get('supplier_id'))) {
if (empty($supplierId)) {
$count = $supplierModel->where('supplier_name', $request->get('supplier_name'))->count();
$companyNameCount = $supplierModel->where('register_company_name',
$request->get('register_company_name'))->where('register_company_name','!=','')->count();
$request->get('register_company_name'))->where('register_company_name', '!=', '')->count();
} else {
$count = $supplierModel->where('supplier_name', $request->get('supplier_name'))
->where('supplier_id', '!=', $request->get('supplier_id'))->count();
->where('supplier_id', '!=', $supplierId)->count();
//至少要有一个联系方式
$contactModel = new SupplierContactModel();
$contactCount = $contactModel->where('supplier_id', $request->get('supplier_id'))->count();
$contactCount = $contactModel->where('supplier_id', $supplierId)->count();
if (!$contactCount) {
return "供应商至少要有一个联系人,请补全";
}
......@@ -85,6 +92,24 @@ class SupplierValidator
if ($companyNameCount) {
return "该注册公司名已经存在,请核验后再提交";
}
if (!empty($supplierId)) {
//还要去判断当前提交人是否存在与其关联的联系人没有完善
$codeId = $request->user->codeId;
$notCompleteContacts = $contactModel->where('supplier_id', $supplierId)->where('can_check_uids', $codeId)
->where(function ($q) {
$q->where('supplier_consignee', '')
->orWhere('supplier_position', '')
->orWhere('supplier_email', '')
->orWhere('supplier_mobile', '')
->orWhere('supplier_telephone', '');
})->get();
$notCompleteContacts = !empty($notCompleteContacts) ? $notCompleteContacts->toArray() : [];
if ($notCompleteContacts) {
return "存在和你相关的联系人没有完善,请先去完善相关联系人";
}
}
}
private function messages()
......@@ -99,7 +124,8 @@ class SupplierValidator
'region.required' => '所在区域不能为空',
'purchase_uid.required' => '渠道开发员不能为空',
'cn_ratio.min' => '人民币系数必须是大于1的浮点数',
'upload_file.business_license.required' => '营业执照不能为空',
'business_license.required' => '营业执照不能为空',
'established_time.required' => '成立时间不能为空',
'us_ratio.min' => '美金系数必须是大于1的浮点数',
'us_delivery_time.regex' => '香港货期格式不正确',
'cn_delivery_time.regex' => '大陆货期格式不正确',
......@@ -114,10 +140,16 @@ class SupplierValidator
'supplier_email.required' => '联系方式的邮箱不能为空',
'supplier_email.email' => '联系方式的邮箱格式不对',
'can_check_uids.required' => '联系方式对应的采购员不能为空',
'shipping_address.required' => '发货地址不能为空',
'shipping_address.max' => '发货地址不能超过100个字符',
'return_address.max' => '退货地址不能超过100个字符',
'return_consignee.max' => '退货收货人不能超过50个字符',
'return_phone.max' => '退货收货人电话不能超过50个字符',
'main_brands.required' => '主营品牌不能为空',
'main_customers.max' => '3-5家客户描述不能超过100个字符',
'ticket_time.max' => '到票时间不能超过20个字符',
'billing_period_detail.required' => '账期详情不能为空',
'billing_period_detail.max' => '账期详情不能超过100个字符',
];
}
......
......@@ -19,6 +19,7 @@ Route::group(['middleware' => ['web', 'menu']], function () {
Route::match(['get', 'post'], '/supplier_contact/{key}', 'SupplierContactController@info');
Route::match(['get', 'post'], '/supplier_receipt/{key}', 'SupplierReceiptController@info');
Route::match(['get', 'post'], '/supplier_account/{key}', 'SupplierAccountController@info');
Route::match(['get', 'post'], '/supplier_share_apply/{key}', 'SupplierShareApplyController@Entrance');
Route::match(['get', 'post'], '/index/{key}', 'IndexController@Entrance');
Route::match(['get', 'post'], '/sku/{key}', 'SkuController@Entrance');
Route::match(['get', 'post'], '/log/{key}', 'LogController@Entrance');
......@@ -38,9 +39,13 @@ Route::group(['middleware' => ['web'], 'namespace' => 'Api'], function () {
Route::match(['get', 'post'], '/api/supplier_receipt/{key}', 'SupplierReceiptApiController@Entrance');
Route::match(['get', 'post'], '/api/supplier_sync_log/{key}', 'SupplierSyncLogApiController@Entrance');
Route::match(['get', 'post'], '/api/supplier_account/{key}', 'SupplierAccountApiController@Entrance');
Route::match(['get', 'post'], '/api/supplier_tag/{key}', 'SupplierTagApiController@Entrance');
Route::match(['get', 'post'], '/api/supplier_share_apply/{key}', 'SupplierShareApplyApiController@Entrance');
});
Route::match(['get', 'post'], '/test', function () {
$service = new \App\Http\Services\DataService();
$service->exportSuppliersNew();
// $service->initSystemTag();
// $service->transferFileData();
// $service->changeSupplierIsTypeByCheckChannelUidOrPurchaseUid();
// $service->replaceStandardBrandId();
});
......@@ -63,4 +63,19 @@ class BrandModel extends Model
}
return $brandList;
}
public function getStandardBrandList()
{
$redis = new RedisModel();
$standardBrands = json_decode($redis->get('standard_brands_for_supplier'),true);
if (empty($standardBrands)) {
$standardBrandModel = new StandardBrandModel();
$standardBrands = $standardBrandModel->selectRaw('brand_name,standard_brand_id as brand_id')
->where('status', 1)->get()->toArray();
$redis->set('standard_brands_for_supplier', json_encode($standardBrands));
$redis->expire('standard_brands_for_supplier', 600);
}
return $standardBrands;
}
}
\ No newline at end of file
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class DepartmentModel extends Model
{
protected $table='user_department';
protected $primaryKey = 'department_id';
public $timestamps = false;
}
......@@ -5,6 +5,7 @@ namespace App\Model;
use App\Http\Services\AdminUserService;
use App\Http\Services\DepartmentService;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Redis;
class IntracodeModel extends Model
{
......@@ -87,6 +88,11 @@ class IntracodeModel extends Model
//获取采购员和对应的编码
public function getChannelUsersEncode()
{
$redis = new RedisModel();
$result = json_decode($redis->get('department_user_encode_list'), true);
if ($result) {
return $result;
}
$departmentService = new DepartmentService();
//市场部
$usersMarket = $departmentService->getUserByDepartmentId(4);
......@@ -101,6 +107,8 @@ class IntracodeModel extends Model
foreach ($users as $code) {
$result[$code['code_id']] = $code['name'] . '(' . $code['code_id'] . ')';
}
$redis->set('department_user_encode_list', json_encode($result));
$redis->expire('department_user_encode_list', 600);
return $result;
}
......
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class StandardBrandModel extends Model
{
protected $connection='spu';
protected $table='brand_standard';
public $timestamps = false;
}
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class SupplierAttachmentModel extends Model
{
protected $connection='web';
protected $table='supplier_attachment';
protected $primaryKey = 'id';
public $timestamps = false;
}
......@@ -11,8 +11,10 @@ class SupplierChannelModel extends Model
public $timestamps = false;
//待复审(第一次新增)
const STATUS_PENDING = -1;
const STATUS_NEED_REVIEW = -1;
//待审核
const STATUS_PENDING = 0;
//审核中
const STATUS_IN_REVIEW = 1;
//通过
const STATUS_PASSED = 2;
......@@ -20,6 +22,8 @@ class SupplierChannelModel extends Model
const STATUS_REJECT = 3;
//禁止交易(禁用)
const STATUS_DISABLE = -2;
//黑名单
const STATUS_BLOCK = -3;
//黑名单信息
public function blacklist()
......@@ -32,4 +36,10 @@ class SupplierChannelModel extends Model
{
return $this->hasMany(SupplierContactModel::class, 'supplier_id', 'supplier_id');
}
//附件
public function attachment()
{
return $this->hasOne(SupplierAttachmentModel::class, 'supplier_id', 'supplier_id');
}
}
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class SupplierShareApplyModel extends Model
{
protected $connection='web';
protected $table='supplier_share_apply';
public $timestamps = false;
//通过
const STATUS_PASS = 2;
//待复审
const STATUS_NEED_REVIEW = 1;
//待审核
const STATUS_PENDING = 0;
//审核不通过
const STATUS_AUDIT_REJECT = -1;
//复审不通过
const STATUS_REVIEW_REJECT = -2;
public function supplier()
{
return $this->hasOne(SupplierChannelModel::class, 'supplier_id', 'supplier_id');
}
public function department()
{
return $this->hasOne(DepartmentModel::class, 'department_id', 'department_id');
}
//申请的部门信息
public function apply_department()
{
return $this->hasOne(DepartmentModel::class, 'department_id', 'apply_department_id');
}
public function apply_user()
{
return $this->hasOne(UserInfoModel::class, 'userId', 'create_uid');
}
}
<?php
namespace App\Presenters\Filter;
//左边数据可以多种,右边数据也可以多种,而且右边数据跟着左边来变
class MultiTransformableSelectPresenter
{
public function render($map = [], $data = [])
{
$defaultKey = array_keys($map)[0];
$unique = "unique_" . mt_rand(1, 100000);
$selectUnique = "unique_" . mt_rand(1, 100000);
//默认的第一项数据
$firstDataItemKey = array_first(array_keys($data));
$html = <<<EOF
<div class="layui-row" style="width:268px;margin-bottom: 3px;">
<div class="layui-col-md5">
<div class="layui-input-inline" style="width: 100px;margin-left: 10px">
<select lay-filter="$unique">
{$this->optionsRender($map)}
</select>
</div>
</div>
<div class="layui-col-md7" style="margin-left: -3px">
<div class="layui-input-inline">
<select class="value_select" name="$defaultKey" id="$selectUnique" lay-filter="$selectUnique" lay-search="">
</select>
</div>
</div>
{$this->selectOptionsRender($data)}
</div>
<script>
$(function() {
layui.use(['form', 'element'], function () {
let form = layui.form;
//初始化渲染
let optionsHtml = $('#$firstDataItemKey').html();
$('#$selectUnique').html(optionsHtml);
form.render();
//变更渲染
form.on('select($unique)', function(data){
console.log(data.value)
optionsHtml = $('#'+data.value).html();
$('#$selectUnique').html(optionsHtml);
data.othis.parent().parent().parent().find('.value_select').attr('name',data.value);
form.render();
});
});
});
</script>
EOF;
return $html;
}
public function optionsRender($data)
{
$optionsHtml = '';
foreach ($data as $key => $value) {
$optionsHtml = $optionsHtml . "<option value='$key'>$value</option>";
}
return $optionsHtml;
}
public function selectOptionsRender($data)
{
$html = '';
foreach ($data as $key => $value) {
//第二层
$optionsHtml = ' <option value="">请选择</option>';
foreach ($value as $k => $v) {
$optionsHtml = $optionsHtml . "<option value='$k'>$v</option>";
}
$html .= <<<EOF
<div id="$key" style="display: none" >
$optionsHtml;
</div>
EOF;
}
return $html;
}
}
\ No newline at end of file
......@@ -3,7 +3,7 @@
namespace App\Presenters\Filter;
//左边可以下拉,右边也可以下拉
class TransformableSelectPresenter
{
public function render($map = [], $data = [])
......
......@@ -13,7 +13,7 @@ class TransformableTimeIntervalPresenter
$unique = "unique_" . mt_rand(1, 100000);
$defaultKey = array_keys($map)[0];
$todayTimeInterval = Carbon::now()->startOfDay()->toDateString() . ' ~ ' . Carbon::now()->addDay(1)->toDateString();
$threeDayTimeInterval = Carbon::now()->subDay(3)->toDateString() . ' ~ ' . Carbon::now()->addDay(1)->toDateString();
$threeDayTimeInterval = Carbon::now()->subDay(2)->toDateString() . ' ~ ' . Carbon::now()->addDay(1)->toDateString();
$thisWeekTimeInterval = Carbon::now()->startOfWeek()->toDateString() . ' ~ ' . Carbon::now()->addDay(1)->toDateString();
$thisMonthTimeInterval = Carbon::now()->startOfMonth()->toDateString() . ' ~ ' . Carbon::now()->addDay(1)->toDateString();
$html = <<<EOF
......
......@@ -11,7 +11,8 @@
"ext-curl": "*",
"predis/predis": "^1.1",
"vladimir-yuldashev/laravel-queue-rabbitmq": "5.2",
"maatwebsite/excel": "2.1.0"
"maatwebsite/excel": "2.1.0",
"guzzlehttp/guzzle": "6.3"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
......
......@@ -15,7 +15,7 @@ return [
//sku列表用
'SkuStatus' => [
0 => '待审核',
0 => '审核中',
1 => '上架',
2 => '审核不通过',
3 => '下架',
......@@ -42,8 +42,51 @@ return [
'cp_time' => 1,
],
//SKU 标签
'SkuTag' => [
1 => '优选',
2 => '认证',
],
//SKU 模式
'SkuMode' => [
1 => '原厂直供',
2 => '国内现货',
3 => '国际现货',
4 => '猎芯期货',
5 => '海外代购',
6 => '线下现货',
7 => '猎芯自营',
],
'SupplierAccountType' => [
0 => '其它',
1 => '云芯商家'
]
],
'AttachmentFields' => [
'business_license',
'billing_information',
'registration_certificate',
'incorporation_certificate',
'certification_notice',
'supplier_survey',
'proxy_certificate',
'quality_assurance_agreement',
'confidentiality_agreement',
'cooperation_agreement',
'other_attachment',
],
//-2是复审不通过,-1是初审不通过,0是待审核,1是待复审,2是复审通过
'SupplierShareApplyStatus' => [
-2 => '复审不通过',
-1 => '初审不通过',
0 => '审核中',
1 => '待复审',
2 => '复审通过'
],
'ZiYingDepartmentId' => 51,
'LiangYingDepartmentId' => 47,
];
\ No newline at end of file
......@@ -66,11 +66,13 @@ return [
],
'StockupType' => [
1 => '联营',
2 => '自营',
3 => '代购',
4 => '寄售',
5 => '云芯',
1 => '联营-现货',
6 => '联营-期货',
3 => '联营-代购',
7 => '联营-原厂直供',
2 => '自营-自采',
4 => '自营-寄售',
5 => '联营-云芯商家',
],
'SupplierPayType' => [
......@@ -87,11 +89,13 @@ return [
'SupplierStatus' => [
0 => '待审核',
-1 => '待复审',
1 => '待审核',
1 => '审核中',
3 => '未通过',
2 => '已通过',
-2 => '禁止交易',
-3 => '黑名单',
],
'Currency' => [
......@@ -187,7 +191,6 @@ return [
1 => '先款后货',
2 => '月结',
],
'FileNameMapping' => [
'business_license' => '营业执照',
'billing_information' => '开票资料',
......@@ -204,16 +207,23 @@ return [
//罗盘菜单对应id
'CompassMenuMap' => [
'total' => '全部',
'pending' => '待复审',
'in_review' => '待审核',
'pending' => '待审核',
'need_review' => '待复审',
'in_review' => '审核中',
'draft' => '草稿',
'passed' => '已通过',
'rejected' => '未通过',
'block' => '黑名单',
'disable' => '禁止交易',
'no_purchase_uid' => '渠道未分配',
'no_channel_uid' => '采购未分配',
'invalid_channel_uid' => '无效采购员',
'invalid_purchase_uid' => '无效渠道员',
'contact_no_complete' => '联系人不完善',
'to_follow_up' => '待跟进',
'no_sku' => '无sku',
'no_quality_assurance_agreement' => '无品质协议',
'has_supplier_tag' => '客户指定供应商',
],
//Sku列表的罗盘对应菜单id
'SkuListCompassMenuMap' => [
......@@ -221,4 +231,9 @@ return [
'expire' => '七天后过期',
'off_shelf' => '下架',
],
'CertificationStatus' => [
-1 => '非认证',
1 => '认证',
]
];
......@@ -44,5 +44,14 @@ return [
'return_address' => '退货地址',
'return_phone' => '退货收货人电话 ',
'return_consignee' => '退货收货人',
'system_tags' => '系统标签',
'customer_tags' => '自定义标签',
'level' => '等级',
'has_certification' => '认证',
'sku_mode_name' => 'SKU 模式',
'sku_tag_name' => 'SKU 标签',
'main_customers' => '3-5家客户',
'ticket_time' => '到票时间',
'billing_period_detail' => '账期详情',
]
];
\ No newline at end of file
......@@ -31,4 +31,5 @@ return [
'exportMonopoly' => 'http://footstone.liexin.net/footstone/exportMonopoly?', // 专卖商品批量导出
'templet' => 'http://footstone.liexin.net/footstone/templet?', // 专卖商品批量导出
],
'TagUrl' => env('TAG_URL'),
];
......@@ -18,6 +18,7 @@ layui.config({ // common.js是配置layui扩展模块的目录,每个页面
zTree: 'zTree/zTree',
xmSelect: 'xmSelect',
selectN: 'selectExt/layui_extends/selectN',
// selectN: 'selectExt/layui_extends/selectN',
}).use(['layer', 'admin'], function () {
var $ = layui.jquery;
var layer = layui.layer;
......@@ -41,7 +42,6 @@ function getProjectUrl() {
return layuiDir.substring(0, layuiDir.indexOf('assets'));
}
function getQueryVariable(variable) {
let query = window.location.search.substring(1);
let vars = query.split("&");
......@@ -75,4 +75,4 @@ function ajax(url, data) {
})
layer.closeAll();
return result;
}
\ No newline at end of file
}
This diff could not be displayed because it is too large.
......@@ -20,6 +20,10 @@
font-size: 12px !important;
}
input:focus, textarea:focus {
outline: 1px solid #AFECAB;
}
.layui-input {
height: 30px;
}
......@@ -37,6 +41,14 @@
.layui-table-click {
background-color: #ddf2e9 !important;
}
.list-href {
color: dodgerblue;
}
.list-href:hover {
color: #1417F4;
}
</style>
<body>
<!-- 正文开始 -->
......
<script>
layui.use(['table', 'form', 'element', 'table', 'layer', 'admin'], function () {
let admin = layui.admin;
let form = layui.form;
let table = layui.table
table.render({
elem: '#applyList'
, url: '/api/supplier_share_apply/GetSupplierShareApplyList'
, method: 'post'
, size: 'sm'
, limit: 10
, cellMinWidth: 80 //全局定义常规单元格的最小宽度
, where: {}
, loading: true
, first: true //不显示首页
, last: false //不显示尾页
, cols: [[
{
field: 'supplier_name', title: '供应商名称', align: 'center', templet: function (d) {
return d.supplier ? d.supplier.supplier_name : '';
}
},
{
field: 'department_name', title: '被申请部门', width: 150, align: 'center', templet: function (d) {
return d.apply_department ? d.apply_department.department_name : '';
}
},
{field: 'create_time', title: '申请时间', width: 150, align: 'center'},
{
field: 'status_name', title: '状态', width: 150, align: 'center', templet: function (d) {
console.log(d);
if (d.status === -1 || d.status === -2) {
return "<span style='color: red'>" + d.status_name + "</span>"
} else {
return d.status_name;
}
}
},
]]
, id: 'applyList'
, page: {}
});
//点击校验按钮
$('#check_apply_supplier_share').click(function () {
let supplierName = $('#supplier_name').val();
let url = '/api/supplier_share_apply/CheckApplySupplierShare?supplier_name=' + supplierName;
let res = ajax(url);
if (res.err_code === 0) {
layer.msg(res.err_msg, {icon: 6});
//设置对应的supplier_id,后端暂时放到res.count这个字段吧...
let supplierId = res.count;
$('#supplier_id').val(supplierId);
//渲染下拉框
let optionHtml = '<option value="">请选择一个部门</option>';
$.each(res.data, function (index, value) {
optionHtml += "<option value='" + value.department_id + "'>" + value.department_name + "</option>"
})
$('#apply_department_id').html(optionHtml);
form.render('select');
} else {
layer.msg(res.err_msg, {icon: 5});
}
});
form.on('submit(save_supplier_share_apply)', function (data) {
let url = '/api/supplier_share_apply/SaveSupplierShareApply';
let res = ajax(url, data.field);
if (!res) {
layer.msg('网络错误,请重试', {icon: 6});
} else {
if (res.err_code === 0) {
admin.closeThisDialog();
parent.layer.msg(res.err_msg, {icon: 6});
} else {
parent.layer.msg(res.err_msg, {icon: 5});
}
}
return false;
});
form.on('submit(cancel)', function (data) {
admin.closeThisDialog();
});
});
</script>
\ No newline at end of file
<script>
layui.use(['table', 'form', 'element', 'table', 'layer', 'admin'], function () {
let table = layui.table
table.render({
elem: '#auditList'
, url: '/api/supplier_share_apply/GetAuditSupplierShareApplyList'
, method: 'post'
, size: 'sm'
, limit: 20
, cellMinWidth: 80 //全局定义常规单元格的最小宽度
, where: {}
, loading: true
, first: true //不显示首页
, last: false //不显示尾页
, cols: [[
{
field: 'supplier_name', title: '供应商名称', align: 'center', templet: function (d) {
return d.supplier ? d.supplier.supplier_name : '';
}
},
{
field: 'department_name', title: '申请部门', width: 150, align: 'center', templet: function (d) {
return d.department ? d.department.department_name : '';
}
},
{
field: 'apply_user_name', title: '申请人', width: 150, align: 'center', templet: function (d) {
return d.apply_user ? d.apply_user.name : '';
}
},
{
field: 'apply_department_name', title: '被申请部门', width: 150, align: 'center', templet: function (d) {
return d.apply_department ? d.apply_department.department_name : '';
}
},
{field: 'create_time', title: '申请时间', width: 150, align: 'center'},
{field: 'status_name', title: '状态', width: 150, align: 'center'},
{field: 'operate', title: '操作', templet: '#operate', align: 'center'},
]]
, id: 'auditList'
, page: {}
});
$(document).on('click', '.audit_supplier_share_apply', function () {
let status = $(this).attr('status');
let id = $(this).val();
let statusName = status === 'pass' ? '通过' : '拒绝';
layer.confirm('确定要' + statusName + '该申请吗?', function () {
let url = '/api/supplier_share_apply/AuditSupplierShareApply';
let result = ajax(url, {
status: status,
id: id,
});
if (result.err_code === 0) {
layer.msg('审核成功', {icon: 6})
table.reload('auditList');
} else {
layer.msg(result.err_msg, {icon: 5})
}
});
});
});
</script>
\ No newline at end of file
<script>
layui.use(['table', 'form', 'element', 'table', 'layer', 'admin'], function () {
let admin = layui.admin;
let form = layui.form;
let table = layui.table
let element = layui.element;
$('#batch_apply_in_review_supplier').click(function () {
admin.btnLoading('.submit-loading');
let supplierIds = getQueryVariable('supplier_ids');
let url = '/api/supplier/BatchApplyInReviewSupplier?supplier_ids=' + supplierIds;
let res = ajax(url);
if (!res) {
layer.msg('网络错误,请重试', {icon: 6});
} else {
if (res.err_code === 0) {
admin.closeThisDialog();
parent.layer.msg(res.err_msg, {icon: 6});
} else {
admin.btnLoading('.submit-loading', false);
parent.layer.msg(res.err_msg, {icon: 5});
}
}
});
form.on('submit(cancel)', function (data) {
admin.closeThisDialog();
});
});
</script>
\ No newline at end of file
<script>
layui.use(['table', 'form', 'element', 'layer','admin'], function () {
let admin = layui.admin;
let form = layui.form;
form.on('submit(blockSupplier)', function (data) {
let supplierId = getQueryVariable('supplier_id');
let url = '/api/supplier/BlockSupplier?supplier_id=' + supplierId;
let res = ajax(url, data.field);
if (!res) {
layer.msg('网络错误,请重试', {icon: 6});
} else {
if (res.err_code === 0) {
admin.closeThisDialog();
parent.layer.msg(res.err_msg, {icon: 6});
} else {
parent.layer.msg(res.err_msg, {icon: 5});
}
}
return false;
});
form.on('submit(cancel)', function (data) {
admin.closeThisDialog();
});
});
</script>
\ No newline at end of file
<script>
</script>
\ No newline at end of file
<script>
layui.use(['table', 'form', 'element', 'layer', 'admin', 'upload', 'index'], function () {
let table = layui.table;
let layer = layui.layer;
let form = layui.form;
let index = layui.index;
let admin = layui.admin;
let element = layui.element;
let upload = layui.upload;
let supplierId = getQueryVariable('supplier_id')
$('#updateSupplierUrl').click(function () {
......@@ -15,6 +9,35 @@
window.location.href = "/supplier/UpdateSupplier?view=iframe&supplier_id={{$supplier['supplier_id']}}&tab=" + tabName;
})
$('#cancel_block_supplier').click(function () {
layer.confirm('对应的供应商设为取消拉黑后,该供应商将重新走审核流程,通过后将重新启用,是否执行当前操作?', function (index) {
let supplierId = getQueryVariable('supplier_id');
let res = ajax('/api/supplier/CancelBlockSupplier', {supplier_id: supplierId, is_type: 0})
if (res.err_code === 0) {
layer.closeAll();
layer.msg(res.err_msg, {icon: 6})
location.reload();
} else {
layer.msg(res.err_msg, {icon: 5})
}
});
});
//取消禁用
$('#cancel_disable_supplier').click(function () {
layer.confirm('确定要取消禁用当前供应商吗?', function (index) {
let supplierId = getQueryVariable('supplier_id');
let res = ajax('/api/supplier/CancelDisableSupplier', {supplier_id: supplierId, is_type: 0})
if (res.err_code === 0) {
layer.closeAll();
layer.msg(res.err_msg, {icon: 6})
location.reload();
} else {
layer.msg(res.err_msg, {icon: 5})
}
});
});
{{--index.setTabTitle('供应商详情 - {{$supplier['supplier_code'] or ''}}');--}}
function openLogView() {
......@@ -30,7 +53,9 @@
}
@if(checkPerm('SupplierLog'))
openLogView();
setTimeout(function () {
openLogView();
}, 100);
@endif
//判断是否要切换tab
......
......@@ -19,17 +19,20 @@
} else if (data.field.status === '-1') {
confirmMessage = '确定要提交新增供应商信息吗?一旦提交,该供应商就会进入待复审阶段,审核过程中无法进行信息修改'
}else if (data.field.status === '3') {
confirmMessage = '确定要重新提交审核吗?一旦提交,该供应商就会再次进入待审核阶段,审核过程中无法进行信息修改';
confirmMessage = '确定要重新提交审核吗?一旦提交,该供应商就会再次进入审核中阶段,审核过程中无法进行信息修改';
} else {
confirmMessage = '确定要修改供应商信息吗?一旦修改关键字段,该供应商就会再次进入待审核阶段,审核过程中无法进行信息修改';
confirmMessage = '确定要修改供应商信息吗?<br>一旦修改关键字段,该供应商就会再次进入<b>待审核</b>状态,需要去列表页<b>提交申请审核</b>,送至主管审核';
}
layer.confirm(confirmMessage, function (index) {
let res = ajax('/api/supplier/UpdateSupplier', data.field)
// debugger
let layerIndex = layer.load();
let res = ajax('/api/supplier/UpdateSupplier', data.field);
if (res.err_code === 0) {
admin.putTempData("needFreshList", 1)
table.reload('receiptList')
location.href = "/supplier/SupplierDetail?view=iframe&supplier_id={{$supplier['supplier_id']}}"
layer.msg(res.err_msg, {icon: 6})
layer.close(index);
} else {
layer.msg(res.err_msg, {icon: 5})
}
......
<script>
layui.use(['table', 'form', 'element', 'layer', 'admin', 'laydate', 'xmSelect'], function () {
let form = layui.form;
if ({{$supplier['sku_audit_ruler']['skip']}}){
$(function () {
$('.audit_ruler_item').attr('disabled', true);
form.render()
})
}
//点击无需审核,所有选项变灰
form.on('radio(is_skip)', function(data){
if (data.value === '1') {
$('.audit_ruler_item').attr('disabled', true);
form.render()
}else{
$('.audit_ruler_item').attr('disabled', false);
form.render()
}
console.log(data.elem); //得到radio原始DOM对象
console.log(data.value); //被点击的radio的value值
});
});
</script>
\ No newline at end of file
<script>
layui.use(['table', 'form', 'element', 'layer', 'admin', 'laydate', 'xmSelect', 'selectN'], function () {
layui.use(['table', 'form', 'element', 'layer', 'admin', 'laydate', 'xmSelect', 'selectN', 'tagsInput'], function () {
let admin = layui.admin;
let form = layui.form;
let selectN = layui.selectN;
......@@ -13,9 +13,11 @@
, format: 'yyyy-MM'
});
const supplierId = getQueryVariable('supplier_id');
$("#supplier_name").blur(function () {
const supplier_name = $(this).val();
const supplier_id = getQueryVariable("supplier_id");
const supplier_id = supplierId;
$('#supplier_check_tip').remove();
let url = '/api/supplier/CheckSupplierName?supplier_name=' + supplier_name + '&supplier_id=' + supplier_id;
let res = ajax(url);
......@@ -64,7 +66,7 @@
//渲染主营品牌的多选
function getBrandOption(element, brandType) {
let brandUrl = '/api/common/getBrandList?type=' + brandType;
let brandUrl = '/api/common/getStandardBrandList';
let brandRes = ajax(brandUrl);
let brandList = brandRes.data;
return {
......@@ -79,6 +81,13 @@
name: 'brand_name',
value: 'brand_id',
},
filterMethod: function (val, item, index, prop) {
if (val === item.brand_name.toLowerCase()) {//把brand_name相同的搜索出来
return true;
}
return item.brand_name.toLowerCase().indexOf(val) === 0;
//不知道的就不管了
},
pageSize: 30,
data: brandList,
on: function (brandList) {
......@@ -98,6 +107,48 @@
let brandIds = $('#main_brands').attr('value');
brandSelector.setValue(brandIds.split(','));
//供应商标签的多选
function getTagOption(element) {
//获取系统标签列表
let url = '/api/supplier_tag/GetSystemTagList';
let tagResult = ajax(url);
let tagList = tagResult.data;
return {
el: '#' + element,
filterable: true,
paging: true,
height: '250px',
size: 'small',
direction: 'auto',
autoRow: true,
prop: {
name: 'tag_name',
value: 'tag_id',
},
pageSize: 30,
data: tagList,
on: function (tagList) {
let arr = tagList.arr;
let tagIds = '';
for (let i in arr) {
tagIds += arr[i].tag_id + ',';
}
let idName = 'system_tags';
$('#' + idName).val(tagIds);
},
};
}
if (supplierId) {
let systemTagOption = getTagOption('system_tags_selector', 2);
let tagSelector = xmSelect.render(systemTagOption);
let tagIds = $('#system_tags').attr('value');
tagSelector.setValue(tagIds.split(','));
//自定义标签
$('#customer_tags').tagsInput({});
}
let regionData = {!! json_encode($region_data) !!};
let provinceCity = {!! !empty($province_city)?json_encode($province_city):'[]' !!};
//无限级分类-基本配置
......@@ -124,9 +175,28 @@
parent.layer.msg(res.err_msg, {icon: 6});
} else {
parent.layer.msg(res.err_msg, {icon: 5});
//todo
}
}
return false;
});
form.on('submit(addAndApplySupplier)', function (data) {
layer.confirm('确定直接申请审核吗?确定后会直接进入审核中的状态,无法进行二次修改', function (index) {
let url = '/api/supplier/AddSupplier?direct_apply=1';
let res = ajax(url, data.field);
if (!res) {
layer.msg('网络错误,请重试', {icon: 6});
} else {
if (res.err_code === 0) {
admin.closeThisDialog();
parent.layer.msg(res.err_msg, {icon: 6});
} else {
parent.layer.msg(res.err_msg, {icon: 5});
}
}
});
return false;
});
});
</script>
\ No newline at end of file
{{Autograph()}}
<script>
layui.use(['table', 'form', 'element', 'layer', 'admin', 'upload'], function () {
let table = layui.table;
let form = layui.form;
let admin = layui.admin;
let element = layui.element;
let upload = layui.upload;
let layer = layui.layer;
let form = layui.form;
let fileName = '';
var loadIndex = 0;
let fileType = '';
//监听附件上传选择,有值才显示上传按钮
form.on('select(file_type_selector)', function (data) {
fileType = data.value;
if (data.value) {
$('#disable_upload_button').hide();
$('#upload_button').show();
} else {
$('#disable_upload_button').show();
$('#upload_button').hide();
}
});
upload.render({
elem: '.uploadButton'
, url: '{{config('website.UploadUrl')}}' //改成您自己的上传接口
, accept: 'file' //文件
, field: 'upload'
, data: {
elem: '#upload_button',
url: '{{config('website.UploadUrl')}}', //改成您自己的上传接口
accept: 'file', //文件
field: 'upload',
data: {
k1: k1,
k2: k2,
source: 1,
cancel_time_verify: 1,
}
, exts: 'jpg|png|bmp|jpeg|zip|pdf'
, size: 20000
, before: function () {
}
, choose: function (obj) {
var files = this.files = obj.pushFile();
},
multiple: true,
exts: 'jpg|png|bmp|jpeg|zip|pdf',
size: 20000,
before: function () {
},
choose: function (obj) {
let files = this.files = obj.pushFile();
let recentFile = files[Object.keys(files)[Object.keys(files).length - 1]]
fileName = recentFile.name;
loadIndex = layer.load(1);
}
, done: function (res, index, upload) {
},
done: function (res, index, upload) {
fileName = this.files[index].name;
if (res.code === 200) {
this.item.parent().find('.upload_obj').val(res.data[0] + '|_|' + fileName);
this.item.parent().find('.uploadButton').text(fileName);
//动态添加js
let fileTemplateObj = $('#file_template')
fileTemplateObj.find('a').attr('href', res.data[0]);
fileTemplateObj.find('a').text(fileName);
fileTemplateObj.find('a').attr('value',fileName);
let fileTemplate = fileTemplateObj.html();
$('#' + fileType + '_div').show();
$('#' + fileType + '_file_div').append(fileTemplate);
setFileTypeValue(fileType);
} else {
layer.msg('上传接口异常,请重试或者联系管理员 . ' + res.message);
}
// console.log(this.files[index]);
delete this.files[index];
layer.close(loadIndex);
}
},
});
//删除文件操作
$(document).on('click', '.delete_file', function () {
// layer.confirm('确定要删除该文件吗?', function (index) {
let fileType = $(this).parent().parent().parent().find('input').attr('id');
//找出对应的div删除
$(this).parent().remove();
setFileTypeValue(fileType)
// return false;
// });
});
//遍历找出文件list复制到表单域
function setFileTypeValue(fileType) {
let fileTypeObj = $('#' + fileType);
let fileTypeDiv = $('#' + fileType + '_div');
let fileValueArr = [];
fileTypeDiv.find('a').each(function () {
let url = $(this).attr('href');
let fileName = $(this).attr('value');
let fileValueMap = {
file_name: fileName,
url: url,
name: fileType
}
fileValueArr.push(fileValueMap)
})
if (fileValueArr.length === 0) {
fileTypeObj.val('');
}else{
fileTypeObj.val(JSON.stringify(fileValueArr));
}
//判断是否没有子元素了,没有的话直接隐藏父元素
// let fileListSize = $('#fileType').find('a').size();
// if (fileListSize === 0) {
// fileTypeDiv.hide();
// }
}
});
</script>
\ No newline at end of file
......@@ -16,26 +16,5 @@
$('#hk_max').val(9999999);
}
});
if ({{$supplier['sku_audit_ruler']['skip']}}){
$(function () {
$('.audit_ruler_item').attr('disabled', true);
form.render()
})
}
//点击无需审核,所有选项变灰
form.on('radio(is_skip)', function(data){
if (data.value === '1') {
$('.audit_ruler_item').attr('disabled', true);
form.render()
}else{
$('.audit_ruler_item').attr('disabled', false);
form.render()
}
console.log(data.elem); //得到radio原始DOM对象
console.log(data.value); //被点击的radio的value值
});
});
</script>
\ No newline at end of file
......@@ -20,6 +20,10 @@
.layui-layout-admin .layui-body {
buttom: 1px;
}
input:focus, textarea:focus {
outline: 1px solid #AFECAB;
}
</style>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
......@@ -63,15 +67,7 @@
if (d.layId.search('SupplierList') !== -1) {
setTimeout(function () {
$('.admin-iframe').contents().find('#refreshWindow').click()
// let iframe = $('#admin-iframe')[0].contentWindow.refreshWindow();
}, 10);
// let flag = admin.getTempData("needFreshList");
// if (flag) {
// setTimeout(function () {
// $('.admin-iframe').contents().find('#getSupplierListButton').click()
// admin.putTempData("needFreshList", null);
// }, 10);
// }
}
//判断详情是否需要刷新
if (d.layId.search('SupplierDetail') !== -1) {
......
......@@ -69,7 +69,7 @@
</div>
<div class="layui-form-item">
<div align="center" style="margin-top: 20px">
<button type="button" class="layui-btn layui-btn-info submit-loading" lay-submit lay-filter="load">保存</button>
<button type="button" class="layui-btn layui-btn-info submit-loading" lay-submit lay-filter="load">确认</button>
</div>
</div>
</form>
......
......@@ -100,7 +100,7 @@
<div align="center" style="margin-top: 20px">
<button type="button" id="addSupplierReceipt" class="layui-btn layui-btn-info submit-loading"
lay-submit
lay-filter="addSupplierReceipt">保存
lay-filter="addSupplierReceipt">确认
</button>
</div>
</div>
......
......@@ -36,7 +36,7 @@
<div class="layui-form-item">
<div align="center" style="margin-top: 20px;text-align: right">
<button type="button" class="layui-btn layui-btn-sm layui-btn-info submit-loading" lay-submit
lay-filter="auditSupplier">保存
lay-filter="auditSupplier">确认
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-primary" lay-submit
lay-filter="cancel">取消
......
......@@ -34,7 +34,7 @@
<div class="layui-form-item">
<div align="center" style="margin-top: 20px;text-align: right">
<button type="button" class="layui-btn layui-btn-sm layui-btn-info submit-loading" lay-submit
lay-filter="auditSupplier">保存
lay-filter="auditSupplier">确认
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-primary" lay-submit
lay-filter="cancel">取消
......
<style>
.layui-form-item {
margin-bottom: 5px;
}
</style>
<div class="layui-card">
{{-- <div class="layui-card-header" style="height: 90px">--}}
{{-- </div>--}}
<div class="layui-card-body">
<form class="layui-form" action="">
<div class="layui-form-item">
<div class="layui-col-xs8">
<label class="layui-form-label"><span class="require">*</span>供应商名称 :
</label>
<div class="layui-inline" style="width: 250px">
<input type="text" id="supplier_name"
placeholder="请输入供应商名称进行校验" class="layui-input"
value="">
</div>
<input type="hidden" name="supplier_id" id="supplier_id">
</div>
<div class="layui-col-xs4">
<button type="button" class="layui-btn layui-btn-sm" id="check_apply_supplier_share">校验</button>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label"><span class="require">*</span>被申请部门 :
</label>
<div class="layui-inline" style="width: 250px">
<select name="apply_department_id" lay-filter="apply_department_id" id="apply_department_id">
<option value="">请选择一个部门</option>
</select>
</div>
</div>
<div class="layui-form-item">
<div align="center" style="margin-top: 20px;text-align: right">
<button type="button" class="layui-btn layui-btn-sm layui-btn-info submit-loading" lay-submit
lay-filter="save_supplier_share_apply">确认
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-primary" lay-submit
lay-filter="cancel">取消
</button>
</div>
</div>
</form>
</div>
</div>
<blockquote class="layui-elem-quote layui-text">
<b>步骤 : </b>
<br>
<b>1.将你要申请共用的供应商名称粘贴到输入框后点击校验 </b>
<br>
<b>2.如果校验后系统存在该供应商,下拉框会出现供应商所属部门,选择其中一个进行申请即可</b>
<br>
</blockquote>
<blockquote class="layui-elem-quote layui-text">
<b>历史申请 :</b>
</blockquote>
<table class="layui-table" id="applyList" lay-filter="applyList"></table>
......@@ -20,15 +20,19 @@
<div class="layui-form-item">
<label class="layui-form-label">审核内容 : </label>
<div class="layui-input-block block-42" style="padding-top: 7px">
<b>{{$auditContent['action'] .' : '}}</b>
@if(is_array($auditContent['content']))
@foreach($auditContent['content'] as $content)
<p>
{{$content}}
</p>
@endforeach
@if (!empty($auditContent))
<b>{{$auditContent['action'] .' : '}}</b>
@if(is_array($auditContent['content']))
@foreach($auditContent['content'] as $content)
<p>
{{$content}}
</p>
@endforeach
@else
{{$auditContent['content']}}
@endif
@else
{{$auditContent['content']}}
暂无
@endif
</div>
</div>
......@@ -48,7 +52,7 @@
<div class="layui-form-item">
<div align="center" style="margin-top: 20px;text-align: right">
<button type="button" class="layui-btn layui-btn-sm layui-btn-info submit-loading" lay-submit
lay-filter="auditSupplier">保存
lay-filter="auditSupplier">确认
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-primary" lay-submit
lay-filter="cancel">取消
......
<blockquote class="layui-elem-quote layui-text">
<b>审核列表 : </b> (只要申请部门或者被申请部门和你是同一个部门的,具有审核权限的你都可以看到申请)
</blockquote>
<table class="layui-table" id="auditList" lay-filter="auditList"></table>
<script type="text/html" id="operate">
<div>
<button type="button" value="@{{ d.id}}" status="pass" class="layui-btn layui-btn-xs audit_supplier_share_apply">同意
</button>
<button type="button" value="@{{ d.id}}" status="reject" class="layui-btn layui-btn-xs layui-btn-danger audit_supplier_share_apply">拒绝
</button>
</div>
</script>
\ No newline at end of file
......@@ -20,7 +20,7 @@
<div class="layui-form-item">
<div align="center" style="margin-top: 20px;text-align: right">
<button type="button" class="layui-btn layui-btn-sm layui-btn-info submit-loading" lay-submit
lay-filter="auditSupplier">保存
lay-filter="auditSupplier">确认
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-primary" lay-submit
lay-filter="cancel">取消
......
<style>
.layui-form-item {
margin-bottom: 5px;
}
</style>
<div class="layui-card">
<div class="layui-card-body">
<blockquote class="layui-elem-quote layui-text">
<b>当前选中需要批量申请审核的供应商列表</b>
</blockquote>
<table class="layui-table">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th>供应商名称</th>
</tr>
</thead>
<tbody>
@foreach($suppliers as $supplier)
<tr>
<td>{{$supplier['supplier_name']}}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<div align="center" style="margin-top: 20px;text-align: right">
<button type="button" class="layui-btn layui-btn-sm layui-btn-info submit-loading" id="batch_apply_in_review_supplier">确认
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-primary" id="cancel">取消
</button>
</div>
</div>
<style>
.layui-form-item {
margin-bottom: 5px;
}
</style>
<div class="layui-card">
<div class="layui-card-body">
<form class="layui-form" action="">
<input type="hidden" name="supplier_id" value="{{$supplier['supplier_id']}}">
<blockquote class="layui-elem-quote layui-text">
<b>基本信息</b>
</blockquote>
<div class="layui-form-item">
<label class="layui-form-label">供应商名称 : </label>
<div class="layui-input-block block-42" style="padding-top: 7px">
{{$supplier['supplier_name']}}
<a style="color: dodgerblue;margin-left: 20px"
ew-href="/supplier/SupplierDetail?view=iframe&supplier_id={{$supplier['supplier_id']}}"
ew-title='供应商详情 - {{$supplier['supplier_code']}}'
>{{$supplier['supplier_code']}}</a>
</div>
</div>
<blockquote class="layui-elem-quote layui-text">
<b>注意</b>
<br>
对应供应商设为黑名单后,猎芯将无法与其进行交易,如要再次启用,则须再次走审核流程。
</blockquote>
<div class="layui-form-item layui-form-text">
<label class="layui-form-label"><span class="require">*</span> 原因说明 : </label>
<div class="layui-input-block">
<textarea name="block_reason" required placeholder="请填写拉黑原因" class="layui-textarea"></textarea>
</div>
</div>
<div class="layui-form-item">
<div align="center" style="margin-top: 20px;text-align: right">
<button type="button" class="layui-btn layui-btn-sm layui-btn-info submit-loading" lay-submit
lay-filter="blockSupplier">确认
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-primary" lay-submit
lay-filter="cancel">取消
</button>
</div>
</div>
</form>
</div>
</div>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Document</title>
</head>
<style>
td {
height: 35px !important;
}
/*.title-td {*/
/* width: 20%;*/
/*}*/
</style>
<body>
<div class="layui-row">
<div class="layui-col-md3">&nbsp;</div>
<div class="layui-col-md6" style="text-align: center">
<div class="layui-row" style="margin-bottom: 5px">
<div class="layui-col-md12" style="text-align: right;color: blue">
<b>深圳市猎芯科技有限公司</b>
</div>
<div class="layui-col-md12">
<span style="font-size: 20px !important;font-weight: bold;">新供应商引入申请单</span>
</div>
<div style="text-align: right">申请部门 : {{$printData['department_name']}}</div>
</div>
<table border="1" style="width: 100%;">
<tr>
<td width="20%" colspan="1">申请人</td>
<td width="30%" colspan="2">{{$printData['apply_name']}}</td>
<td width="20%" colspan="1">申请时间</td>
<td width="30%" colspan="2">{{$printData['apply_time']}}</td>
</tr>
<tr>
<td width="20%" colspan="1">供应商名*</td>
<td width="80%" colspan="5"
style="text-align: left;padding-left: 20px">{{$printData['supplier_name']}}</td>
</tr>
<tr>
<td width="20%" colspan="1">供应商英文名</td>
<td width="80%" colspan="5"
style="text-align: left;padding-left: 20px">{{$printData['supplier_name_en']}}</td>
</tr>
<tr>
<td width="20%" colspan="1">供应商性质</td>
<td width="80%" colspan="5"
style="text-align: left;padding-left: 20px">{{$printData['supplier_group_name']}}</td>
</tr>
<tr>
<td width="20%" colspan="1">行业地位</td>
<td width="80%" colspan="5" style="text-align: left;padding-left: 20px"></td>
</tr>
<tr>
<td width="20%" colspan="1">主要产品线品牌</td>
<td width="80%" colspan="5"
style="text-align: left;padding-left: 20px">{{$printData['main_brand_names']}}</td>
</tr>
<tr>
<td width="20%" colspan="1">3-5家主要客户</td>
<td width="80%" colspan="5"
style="text-align: left;padding-left: 20px">{{$printData['main_customers']}}</td>
</tr>
<tr>
<td width="20%" colspan="1">资信调查情况</td>
<td width="80%" colspan="5"
style="text-align: left;padding-left: 20px">{{$printData['credit_investigation']}}</td>
</tr>
<tr>
<td width="20%" colspan="1">供应商注册地址</td>
<td width="80%" colspan="5"
style="text-align: left;padding-left: 20px">{{$printData['supplier_address']}}</td>
</tr>
<tr>
<td width="20%" colspan="1">供应商办公/发货地址*</td>
<td width="80%" colspan="5"
style="text-align: left;padding-left: 20px">{{$printData['shipping_address']}}</td>
</tr>
<tr>
<td width="20%" colspan="1">供应商法人代表</td>
<td width="80%" colspan="5"
style="text-align: left;padding-left: 20px">{{$printData['legal_representative']}}</td>
</tr>
<tr>
<td width="20%" colspan="1">供应商营业税号</td>
<td width="80%" colspan="5"
style="text-align: left;padding-left: 20px">{{$printData['tax_number']}}</td>
</tr>
<tr>
<td width="20%" colspan="1">供应商成立时间*</td>
<td width="80%" colspan="5"
style="text-align: left;padding-left: 20px">{{$printData['established_time']}}</td>
</tr>
<tr>
<td width="20%" colspan="1">付款币别</td>
<td width="80%" colspan="5"
style="text-align: left;padding-left: 20px">{{$printData['currency_name'] or ''}}</td>
</tr>
<tr>
<td width="20%" colspan="1">供应商付款方式</td>
<td width="80%" colspan="5"
style="text-align: left;padding-left: 20px">{{$printData['pay_type_name'] or ''}}</td>
</tr>
<tr>
<td width="20%" colspan="1">付款时间</td>
<td width="80%" colspan="5" style="text-align: left;padding-left: 20px"></td>
</tr>
<tr>
<td width="20%" colspan="1">供应商到票时间*</td>
<td width="80%" colspan="5"
style="text-align: left;padding-left: 20px">{{$printData['ticket_time'] or ''}}</td>
</tr>
<tr>
<td width="20%" colspan="1">账期详情*</td>
<td width="80%" colspan="5"
style="text-align: left;padding-left: 20px">{{$printData['billing_period_detail'] or ''}}</td>
</tr>
<tr>
<td width="20%" colspan="1">业务负责人</td>
<td width="20%" colspan="1">{{array_get($printData['contact'],'supplier_consignee','')}}</td>
<td width="10%" colspan="1">电话</td>
<td width="20%" colspan="1">{{array_get($printData['contact'],'supplier_telephone','')}}</td>
<td width="10%" colspan="1">邮箱</td>
<td width="20%" colspan="1">{{array_get($printData['contact'],'supplier_email','')}}</td>
</tr>
<tr>
<td width="20%" colspan="1">业务跟进人</td>
<td width="20%" colspan="1"></td>
<td width="10%" colspan="1">电话</td>
<td width="20%" colspan="1"></td>
<td width="10%" colspan="1">邮箱</td>
<td width="20%" colspan="1"></td>
</tr>
<tr>
<td width="20%" colspan="1">业务/技术跟进人</td>
<td width="20%" colspan="1"></td>
<td width="10%" colspan="1">电话</td>
<td width="20%" colspan="1"></td>
<td width="10%" colspan="1">邮箱</td>
<td width="20%" colspan="1"></td>
</tr>
<tr>
<td width="20%" colspan="1">品质保证协议</td>
<td width="80%" colspan="5"
style="text-align: left;padding-left: 20px">{{$printData['has_agreement']}}</td>
</tr>
</table>
<table border="1" style="width: 100%;">
<tr>
<td width="16.6%" colspan="1">主管审批 :</td>
<td width="16.6%" colspan="1"></td>
<td width="16.6%" colspan="1">采购部审批 :</td>
<td width="16.6%" colspan="1"></td>
<td width="16.6%" colspan="1">总经理核准 :</td>
<td width="16.6%" colspan="1"></td>
</tr>
</table>
<div class="layui-row" style="text-align: left">
<div style="margin-left: 30px;margin-top: 10px;">
<span>附营业执照、银行收款资料、代理证书等相关资质证明</span>
</div>
</div>
</div>
<div class="layui-col-md3">&nbsp;</div>
<script>
window.print();
</script>
</div>
</body>
</html>
\ No newline at end of file
......@@ -17,7 +17,7 @@
<div class="layui-form-item">
<div align="center" style="margin-top: 20px;text-align: right">
<button type="button" class="layui-btn layui-btn-sm layui-btn-info submit-loading" lay-submit
lay-filter="setYunxinChannelUid">保存
lay-filter="setYunxinChannelUid">确认
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-primary" lay-submit
lay-filter="cancel">取消
......
......@@ -10,11 +10,12 @@
@if(checkPerm('AuditSupplier'))
<button type="button" class="layui-btn layui-btn-sm" id="audit_supplier">审核</button>
@endif
@if(checkPerm('AllocatePurchaseUser'))
<button type="button" class="layui-btn layui-btn-sm" id="allocate_purchase_user">分配渠道员</button>
@endif
{{-- @if(checkPerm('AllocatePurchaseUser'))--}}
{{-- <button type="button" class="layui-btn layui-btn-sm" id="allocate_purchase_user">分配渠道员</button>--}}
{{-- @endif--}}
@if(checkPerm('BatchAllocatePurchaseUser'))
<button type="button" class="layui-btn layui-btn-sm" id="batch_allocate_purchase_user">批量分配渠道员</button>
{{-- <button type="button" class="layui-btn layui-btn-sm" id="batch_allocate_purchase_user">批量分配渠道员</button>--}}
<button type="button" class="layui-btn layui-btn-sm" id="batch_allocate_purchase_user">分配渠道员</button>
@endif
@if(checkPerm('AllocateChannelUser'))
<button type="button" class="layui-btn layui-btn-sm" id="allocate_channel_user">分配采购员</button>
......@@ -24,11 +25,34 @@
转正供应商
</button>
@endif
<button type="button" class="layui-btn layui-btn-sm" title="点击确定审核后会进入审核中状态" id="batch_apply_in_review_supplier">
申请审核
</button>
@if(checkPerm('BlockSupplier'))
<button type="button" class="layui-btn layui-btn-sm" id="block_supplier">
拉黑
</button>
@endif
@if(request()->user->userId==1000)
<button type="button" class="layui-btn layui-btn-sm" title="该操作可以将供应商同步到供应商" id="sync_supplier_to_erp">
金蝶同步
</button>
@endif
@if(checkPerm('ApplySupplierShare'))
{{-- @if(checkPerm('BlockSupplier'))--}}
<button type="button" class="layui-btn layui-btn-sm" id="apply_supplier_share">
共用申请
</button>
@endif
@if(checkPerm('AuditSupplierShare'))
<button type="button" class="layui-btn layui-btn-sm" id="audit_supplier_share_apply">
共用审核
@if (!empty($shareApplyCount))
({{$shareApplyCount}})
<span style="margin-left: 0" class="layui-badge-dot layui-bg-orange"></span>
@endif
</button>
@endif
</div>
<button type="button" id="refreshWindow" style="display: none">刷新页面</button>
<table class="layui-table" id="list" lay-filter="list"></table>
......
......@@ -23,14 +23,6 @@
width: 100%;
z-index: 10;
}
/*.layui-form-label {*/
/* width: 150px;*/
/*}*/
/*.layui-input-block {*/
/* margin-left: 180px;*/
/*}*/
</style>
<div class="layui-card">
<form class="layui-form" action="">
......@@ -57,15 +49,22 @@
公司性质 : {{$supplier['supplier_group_name']}}
</div>
<div class="layui-col-md2">
合作类型:{{$supplier['stockup_type_name']}}
合作类型 :
@if (mb_strlen($supplier['stockup_type_name'])>12)
<span title="{{$supplier['stockup_type_name']}}">
{{mb_substr($supplier['stockup_type_name'],0,12)}}...
</span>
@else
{{$supplier['stockup_type_name']}}
@endif
</div>
<div class="layui-col-md2">
<span title="{{$supplier['channel_username']}}">
采购员 : {{str_limit($supplier['channel_username'],35,'...')}}
</span>
云芯采购员 : {{$supplier['yunxin_channel_username']}}
</div>
<div class="layui-col-md3">
云芯采购员 : {{$supplier['yunxin_channel_username']}}
<span title="{{$supplier['channel_username']}}">
采购员 : {{str_limit($supplier['channel_username'],50,'...')}}
</span>
</div>
<div class="layui-col-md3"></div>
</div>
......@@ -111,6 +110,12 @@
@endif
id="ruler">特殊规则
</li>
<li
@if(request()->get('tab')=='sku_ruler')
class="layui-this"
@endif
id="sku_ruler">SKU概况
</li>
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item @if(request()->get('tab')=='base_info'||empty(request()->get('tab'))) layui-show @endif">
......@@ -123,24 +128,28 @@
<blockquote class="layui-elem-quote layui-text">
<b>系统设置</b>
</blockquote>
<div class="layui-row" style="margin-bottom: 10px">
<div class="layui-col-md2">
供应商编码 :{{$supplier['supplier_code']}}
<div class="layui-row" style="margin-bottom: 10px;margin-left: 30px;">
<div class="layui-col-md3">
<div class="layui-inline">
供应商编码 :&nbsp;{{$supplier['supplier_code']}}
</div>
</div>
<div class="layui-col-md3" style="margin-left: 18px">
供应商ID :{{$supplier['supplier_id']}}
<div class="layui-col-md3" style="margin-left: 15px;">
<div class="layui-inline">
供应商ID :&nbsp;&nbsp;{{$supplier['supplier_id']}}
</div>
</div>
</div>
<div class="layui-row">
<div class="layui-col-md3">
<div class="layui-inline" style="margin-left: -40px">
<div class="layui-inline">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('trading_method','交易方式 : ',
isset($supplier)?$supplier['trading_method']:'',config('fixed.TradingMethod'),['required'=>false]) !!}
</div>
</div>
<div class="layui-col-md3">
<div class="layui-inline" style="margin-left: -150px">
<div class="layui-inline">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('pay_type','付款方式 : ',
isset($supplier)?$supplier['pay_type']:'',config('fixed.SupplierPayType'),['required'=>false]) !!}
......@@ -206,7 +215,7 @@
<div class="layui-col-md2">
最近修改人:{{$supplier['last_update_name']}}
</div>
<div class="layui-col-md2">
<div class="layui-col-md3">
最近修改时间:{{$supplier['last_update_time']}}
</div>
</div>
......@@ -226,10 +235,12 @@
@include('web.supplier.SupplierRuler')
</div>
</div>
<div class="layui-tab-item">内容4</div>
<div class="layui-tab-item">内容5</div>
<div class="layui-tab-item" @if(request()->get('tab')=='sku_ruler') layui-show @endif">
@include('web.supplier.SkuRuler')
</div>
<div class="layui-tab-item">内容5</div>
</div>
</div>
</form>
</div>
</form>
</div>
......@@ -71,7 +71,7 @@
</div>
<div class="layui-form-item">
<div align="center" style="margin-top: 20px">
<button type="button" class="layui-btn layui-btn-info submit-loading" lay-submit lay-filter="load">保存</button>
<button type="button" class="layui-btn layui-btn-info submit-loading" lay-submit lay-filter="load">确认</button>
</div>
</div>
</form>
......
<blockquote class="layui-elem-quote layui-text">
<b>SKU配置</b>
</blockquote>
<div class="layui-form-item">
<div class="layui-col-md3">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('sku_tag','SKU 标签',!empty($supplier)?$supplier['sku_tag']:'',config('field.SkuTag'),['width'=>'150px']) !!}
</div>
<div class="layui-col-md3">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('sku_mode','SKU 模式',!empty($supplier)?$supplier['sku_mode']:'',config('field.SkuMode'),['width'=>'150px']) !!}
</div>
<div class="layui-col-md6">
</div>
</div>
<blockquote class="layui-elem-quote layui-text">
<b>SKU相关设置 - 联营库存数据</b>
</blockquote>
<div class="layui-form-item">
<div class="layui-inline" style="width: 100%">
<label class="layui-form-label">数据新增规则 : </label>
<div class="layui-input-inline" style="width: 380px">
@if(!empty($supplier['sku_upload_ruler']))
@foreach($supplier['sku_upload_ruler'] as $key=>$flag)
@if(!empty(array_get(config('fixed.SkuUploadRuler'),$key)))
<input type="checkbox" name="sku_upload_ruler[{{$key}}]"
lay-skin="primary"
@if($flag)
checked
@endif
title="{{array_get(config('fixed.SkuUploadRuler'),$key)}}">
@endif
@endforeach
@else
@foreach(config('fixed.SkuUploadRuler') as $key=>$flag)
<input type="checkbox" name="sku_upload_ruler[{{$key}}]"
lay-skin="primary"
title="{{$flag}}">
@endforeach
@endif
</div>
<div class="layui-form-mid layui-word-aux">
SKU数据导入条件勾选后只要满足该条件,就可以导入数据;默认导入条件是有库存、价格、起订量且起订量>库存
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline" style="width: 100%">
<label class="layui-form-label">审核内容配置 : </label>
<div class="layui-input-inline" style="width: 205px">
<input type="radio" name="sku_audit_ruler[skip]" lay-filter="is_skip" @if($supplier['sku_audit_ruler']['skip']==1) checked @endif value="1" title="无需审核">
<input type="radio" name="sku_audit_ruler[skip]" lay-filter="is_skip" @if($supplier['sku_audit_ruler']['skip']==0) checked @endif value="0" title="需要审核内容">
</div>
<div class="layui-input-inline" style="width: 700px">
@if(!empty($supplier['sku_audit_ruler']))
@foreach($supplier['sku_audit_ruler']['audit_ruler'] as $key=>$flag)
@if(!empty(array_get(config('fixed.SkuAuditRuler.audit_ruler'),$key)))
<input type="checkbox" name="sku_audit_ruler[{{$key}}]"
lay-skin="primary"
class="audit_ruler_item"
@if($flag)
checked
@endif
title="{{array_get(config('fixed.SkuAuditRuler.name_map'),$key)}}">
@endif
@endforeach
@else
@foreach(config('fixed.SkuAuditRuler.audit_ruler') as $key=>$flag)
<input type="checkbox" name="sku_audit_ruler[{{$key}}]"
lay-skin="primary" checked class="audit_ruler_item"
title="{{array_get(config('fixed.SkuAuditRuler.name_map'),$key)}}">
@endforeach
@endif
</div>
</div>
</div>
@include('script.supplier.SkuRulerScript')
\ No newline at end of file
......@@ -52,7 +52,7 @@
config('fixed.Region'),['required'=>true,'width'=>'150px']) !!}
</div>
<div class="layui-col-md8">
<div class="city-div" style="display: none">
<div class="city-div" style="display: none">
<label class="layui-form-label">选择省市 : </label>
<div class="city-selector" id="city-selector"></div>
</div>
......@@ -66,6 +66,16 @@
value="{{$supplier['supplier_address'] or ''}}">
</div>
</div>
@if($operate=='add')
<div class="layui-col-md12">
<label class="layui-form-label">发货地址 : </label>
<div class="layui-input-block">
<input type="text" name="shipping_address" id="shipping_address"
placeholder="请输入发货地址" class="layui-input"
value="{{$address['shipping_address'] or ''}}">
</div>
</div>
@endif
</div>
</div>
<div class="layui-form-item">
......@@ -101,6 +111,7 @@
</div>
<div class="layui-form-item">
<label class="layui-form-label">
<span class="require">*</span>
主营品牌</label>
<div class="layui-input-block" style="margin-top: 15px">
<div id="brand_selector" class="layui-input-inline" style="width: 100%;">
......@@ -110,6 +121,15 @@
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">3-5家客户 :
</label>
<div class="layui-input-block">
<input type="text" name="main_customers" id="main_customers"
placeholder="请输入3-5家客户" class="layui-input"
value="{{$supplier['main_customers'] or ''}}">
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label"><span class="require">*</span>合作类型</label>
<div class="layui-input-block">
......@@ -131,7 +151,7 @@
<div class="layui-col-md4">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('supplier_group','公司性质',!empty($supplier)?array_get($supplier,'supplier_group',null):'',
config('fixed.SupplierGroup'),['required'=>true,'width'=>'150px']) !!}
config('fixed.SupplierGroup'),['required'=>true]) !!}
</div>
</div>
</div>
......@@ -153,7 +173,64 @@
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">到票时间 :
</label>
<div class="layui-input-block">
<input type="text" style="width: 170px" name="ticket_time" id="ticket_time"
placeholder="请输入到票时间" class="layui-input"
value="{{$supplier['ticket_time'] or ''}}">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label"><span class="require">*</span>账期详情</label>
<div class="layui-input-block">
<input type="text" name="billing_period_detail" style="width: 470px" placeholder="请输入账期详情"
class="layui-input"
value="{{$supplier['billing_period_detail'] or ''}}">
</div>
</div>
</div>
@include('web.supplier.SupplierFile')
@if($operate!='add' && checkPerm('UpdateSupplierTags'))
<blockquote class="layui-elem-quote layui-text">
<b>供应商标签 : </b>
</blockquote>
<div class="layui-form-item">
<div class="layui-col-md3">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('level','等级',!empty($supplier)?$supplier['level']:'',['A'=>'A','B'=>'B','C'=>'C','D'=>'D','E'=>'E'],['width'=>'150px']) !!}
</div>
<div class="layui-col-md3">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('has_certification','认证',!empty($supplier)?$supplier['has_certification']:'',[1=>'认证',-1=>'非认证'],['width'=>'150px']) !!}
</div>
<div class="layui-col-md6">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">
系统标签 : </label>
<div class="layui-input-block" style="margin-top: 15px">
<div id="system_tags_selector" class="layui-input-inline" style="width: 100%;">
</div>
<input type="hidden" name="system_tags" value="{{$supplier['system_tags'] or ''}}"
id="system_tags">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">
自定义标签 : </label>
<div class="layui-input-block" style="margin-top: 15px">
<input name="customer_tags" id="customer_tags" value="{{$supplier['customer_tags'] or ''}}">
</div>
</div>
@endif
@if($operate=='add')
<blockquote class="layui-elem-quote layui-text">
<b>跟进人</b>
......@@ -184,7 +261,7 @@
</div>
<div class="layui-col-md2">
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-col-md5">
<label class="layui-form-label"><span class="require">*</span>邮箱</label>
......@@ -242,36 +319,39 @@
@endif
@include('script.supplier.SupplierBaseScript')
@if($operate=='add')
<div style="height: 100px"></div>
<div class="fix-button">
<div class="layui-row" style="width: 90%;">
<hr>
<div class="layui-col-md8">
<p>
<b>特别说明:</b>
</p>
<p>
1.在创建新的供应商前,请先查询该供应商是否已经存在。如果供应商已存在,则不允许新增。
</p>
<p>
2.附件上传支持小于20M的PDF/ZIP/JPG/PNG/BMP格式,每个类型最多支持上传一个文件
</p>
<P>
3.此处新增供应商基本信息以及配置跟进人,其他信息补全必须进入编辑页面
</P>
</div>
<div class="layui-col-md4" style="margin-top: 30px">
<div class="layui-row" style="text-align: right">
<button type="button" class="layui-btn layui-btn submit-loading" lay-submit
lay-filter="addSupplier">确认
</button>
<button lay-filter="cancelAddSupplier"
type="button" lay-submit
class="layui-btn layui-btn-primary">取消
</button>
<div style="height: 100px"></div>
<div class="fix-button">
<div class="layui-row" style="width: 90%;">
<hr>
<div class="layui-col-md8">
<p>
<b>特别说明:</b>
</p>
<p>
1.在创建新的供应商前,请先查询该供应商是否已经存在。如果供应商已存在,则不允许新增。
</p>
<p>
2.附件上传支持小于20M的PDF/ZIP/JPG/PNG/BMP格式,每个类型最多支持上传一个文件
</p>
<P>
3.此处新增供应商基本信息以及配置跟进人,其他信息补全必须进入编辑页面
</P>
</div>
<div class="layui-col-md4" style="margin-top: 30px">
<div class="layui-row" style="text-align: right">
<button type="button" class="layui-btn layui-btn submit-loading" lay-submit
lay-filter="addAndApplySupplier">申请审核
</button>
<button type="button" class="layui-btn layui-btn submit-loading" lay-submit
lay-filter="addSupplier">确认
</button>
<button lay-filter="cancelAddSupplier"
type="button" lay-submit
class="layui-btn layui-btn-primary">取消
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
@endif
\ No newline at end of file
......@@ -2,6 +2,7 @@
.main_filter {
cursor: pointer;
}
.status_filter {
cursor: pointer;
}
......@@ -16,9 +17,13 @@
</div>
</div>
<div class="split-item" id="s2" style="text-align: center">
<div class="layui-row">
<a class="status_filter" id="need_review" data-value="-1">
</a>
</div>
@if(checkPerm('SupplierPendingList'))
<div class="layui-row">
<a class="status_filter" id="pending" data-value="-1">
<a class="status_filter" id="pending" data-value="0">
</a>
</div>
@endif
......@@ -28,22 +33,15 @@
</a>
</div>
@endif
@if(checkPerm('SupplierPassedList'))
<div class="layui-row">
<a class="status_filter" id="passed" data-value="2">
</a>
</div>
@endif
@if(checkPerm('SupplierRejectList'))
<div class="layui-row">
<a class="status_filter" id="rejected" data-value="3">
<a class="status_filter" id="rejected" data-value="-2">
</a>
</div>
@endif
@if(checkPerm('SupplierDisableList'))
@if(checkPerm('SupplierPassedList'))
<div class="layui-row">
<a class="status_filter" id="disable" data-value="-2">
<a class="status_filter" id="passed" data-value="2">
</a>
</div>
@endif
......@@ -55,6 +53,12 @@
</a>
</div>
@endif
@if(checkPerm('SupplierNoChannelUidList'))
<div class="layui-row">
<a title="采购员为空的供应商" class="main_filter" id="no_channel_uid">
</a>
</div>
@endif
@if(checkPerm('SupplierInvalidChannelUidList'))
<div class="layui-row">
<a title="非禁止交易状态联系人绑定的采购员姓名不在组织架构中(采购员离职)的供应商" class="main_filter"
......@@ -69,6 +73,11 @@
</a>
</div>
@endif
<div class="layui-row">
<a title="联系人中存在非必填字段未填写" class="main_filter"
id="contact_no_complete">
</a>
</div>
</div>
<div class="split-item" id="s4" style="text-align: center">
@if(checkPerm('SupplierToFollowUpList'))
......@@ -84,8 +93,31 @@
</a>
</div>
@endif
<div class="layui-row">
<a title="公司性质为贸易商性质的供应商没有上传品质协议" class="main_filter" id="no_quality_assurance_agreement">
</a>
</div>
</div>
<div class="split-item" id="s5" style="text-align: center">
@if(checkPerm('SupplierBlockList'))
<div class="layui-row">
<a class="status_filter" id="block" data-value="-3">
</a>
</div>
@endif
@if(checkPerm('SupplierDisableList'))
<div class="layui-row">
<a class="status_filter" id="disable" data-value="-2">
</a>
</div>
@endif
<div class="layui-row">
<a class="main_filter" title="系统标签中贴有客户指定的供应商" id="has_supplier_tag">
</a>
</div>
</div>
<div class="split-item" id="s5">
<div class="split-item" id="s6">
</div>
</div>
</div>
......@@ -110,28 +142,34 @@
</div>
<div class="layui-inline">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('status','供应商状态','',config('fixed.SupplierStatus')) !!}
</div>
<div class="layui-inline">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('stockup_type','合作类型','',config('fixed.StockupType')) !!}
</div>
<div class="layui-inline">
@inject('transformableSelectPresenter','App\Presenters\Filter\TransformableSelectPresenter')
{!! $transformableSelectPresenter->render(['channel_uid'=>'采购员','purchase_uid'=>'开发员','create_uid'=>'创建人'],$userCodes) !!}
</div>
</div>
<div class="layui-row">
<div class="layui-inline">
@inject('multiTransformableSelectPresenter','App\Presenters\Filter\MultiTransformableSelectPresenter')
{!! $multiTransformableSelectPresenter->render(['has_sku'=>'SKU上传','sku_tag'=>'SKU标准','sku_mode'=>'SKU模式'],
['has_sku'=>[-1=>'否',1=>'是'],'sku_tag'=>config('field.SkuTag'),'sku_mode'=>config('field.SkuMode')]) !!}
</div>
@if(checkPerm('ViewFakeSupplier'))
<div class="layui-inline">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('is_type','正式供应商','',[0=>'是',1=>'否'],['width'=>'100px']) !!}
{!! $statusPresenter->render('is_type','正式供应商','',[0=>'是',1=>'否']) !!}
</div>
@endif
</div>
<div class="layui-row">
<div class="layui-inline">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('has_sku','SKU上传','',[-1=>'否',1=>'是']) !!}
</div>
<div class="layui-inline">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('status','供应商状态','',config('fixed.SupplierStatus')) !!}
</div>
{{-- <div class="layui-inline">--}}
{{-- @inject('statusPresenter','App\Presenters\StatusPresenter')--}}
{{-- {!! $statusPresenter->render('has_sku','SKU上传','',[-1=>'否',1=>'是']) !!}--}}
{{-- </div>--}}
<div class="layui-inline" style="width: 600px">
@inject('transformableTimeIntervalPresenter','App\Presenters\Filter\TransformableTimeIntervalPresenter')
{!! $transformableTimeIntervalPresenter->render(['update_time'=>'更新时间','create_time'=>'创建时间']) !!}
......@@ -154,14 +192,22 @@
<script>
//一进来就去获取统计数据
function supplierStatistics() {
let res = ajax('/api/supplier_statistics/GetSupplierStatistics');
if (res.err_code === 0) {
$.each(res.data, function (index, value) {
let menuObj = $('#' + index);
menuObj.text('');
menuObj.append(value);
});
}
$.ajax({
url:'/api/supplier_statistics/GetSupplierStatistics',
type:'post',
async: true,
dataType:'json',
timeout:10000,
success:function (res) {
if (res.err_code === 0) {
$.each(res.data, function (index, value) {
let menuObj = $('#' + index);
menuObj.text('');
menuObj.append(value);
});
}
}
})
}
supplierStatistics();
......
......@@ -99,68 +99,4 @@
</div>
</div>
<blockquote class="layui-elem-quote layui-text">
<b>SKU相关设置 - 联营库存数据</b>
</blockquote>
<div class="layui-form-item">
<div class="layui-inline" style="width: 100%">
<label class="layui-form-label">数据新增规则 : </label>
<div class="layui-input-inline" style="width: 380px">
@if(!empty($supplier['sku_upload_ruler']))
@foreach($supplier['sku_upload_ruler'] as $key=>$flag)
@if(!empty(array_get(config('fixed.SkuUploadRuler'),$key)))
<input type="checkbox" name="sku_upload_ruler[{{$key}}]"
lay-skin="primary"
@if($flag)
checked
@endif
title="{{array_get(config('fixed.SkuUploadRuler'),$key)}}">
@endif
@endforeach
@else
@foreach(config('fixed.SkuUploadRuler') as $key=>$flag)
<input type="checkbox" name="sku_upload_ruler[{{$key}}]"
lay-skin="primary"
title="{{$flag}}">
@endforeach
@endif
</div>
<div class="layui-form-mid layui-word-aux">
SKU数据导入条件勾选后只要满足该条件,就可以导入数据;默认导入条件是有库存、价格、起订量且起订量>库存
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline" style="width: 100%">
<label class="layui-form-label">审核内容配置 : </label>
<div class="layui-input-inline" style="width: 205px">
<input type="radio" name="sku_audit_ruler[skip]" lay-filter="is_skip" @if($supplier['sku_audit_ruler']['skip']==1) checked @endif value="1" title="无需审核">
<input type="radio" name="sku_audit_ruler[skip]" lay-filter="is_skip" @if($supplier['sku_audit_ruler']['skip']==0) checked @endif value="0" title="需要审核内容">
</div>
<div class="layui-input-inline" style="width: 700px">
@if(!empty($supplier['sku_audit_ruler']))
@foreach($supplier['sku_audit_ruler']['audit_ruler'] as $key=>$flag)
@if(!empty(array_get(config('fixed.SkuAuditRuler.audit_ruler'),$key)))
<input type="checkbox" name="sku_audit_ruler[{{$key}}]"
lay-skin="primary"
class="audit_ruler_item"
@if($flag)
checked
@endif
title="{{array_get(config('fixed.SkuAuditRuler.name_map'),$key)}}">
@endif
@endforeach
@else
@foreach(config('fixed.SkuAuditRuler.audit_ruler') as $key=>$flag)
<input type="checkbox" name="sku_audit_ruler[{{$key}}]"
lay-skin="primary" checked class="audit_ruler_item"
title="{{array_get(config('fixed.SkuAuditRuler.name_map'),$key)}}">
@endforeach
@endif
</div>
</div>
</div>
@include('script.supplier.SupplierRulerScript')
\ No newline at end of file
......@@ -12,8 +12,12 @@ return array(
'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
'2c102faa651ef8ea5874edb585946bce' => $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php',
'bd9634f2d41831496de0d3dfe4c94881' => $vendorDir . '/symfony/polyfill-php56/bootstrap.php',
'7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
'5255c38a0faeba867671b61dfda6d864' => $vendorDir . '/paragonie/random_compat/lib/random.php',
'e7223560d890eab89cda23685e711e2c' => $vendorDir . '/psy/psysh/src/Psy/functions.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
'f0906e6318348a765ffb6eb24e0d0938' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/helpers.php',
'58571171fd5812e6e447dce228f52f4d' => $vendorDir . '/laravel/framework/src/Illuminate/Support/helpers.php',
'cdab8ec77ae0402ce2cb2fdd82a8a401' => $baseDir . '/app/Http/function.php',
......
......@@ -30,6 +30,7 @@ return array(
'SuperClosure\\' => array($vendorDir . '/jeremeamia/superclosure/src'),
'Psy\\' => array($vendorDir . '/psy/psysh/src/Psy'),
'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'),
'Prophecy\\' => array($vendorDir . '/phpspec/prophecy/src/Prophecy'),
'Predis\\' => array($vendorDir . '/predis/predis/src'),
'PhpParser\\' => array($vendorDir . '/nikic/php-parser/lib/PhpParser'),
......@@ -38,6 +39,9 @@ return array(
'League\\Flysystem\\' => array($vendorDir . '/league/flysystem/src'),
'JakubOnderka\\PhpConsoleColor\\' => array($vendorDir . '/jakub-onderka/php-console-color/src'),
'Illuminate\\' => array($vendorDir . '/laravel/framework/src/Illuminate'),
'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'),
'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'),
'Faker\\' => array($vendorDir . '/fzaninotto/faker/src/Faker'),
'Dotenv\\' => array($vendorDir . '/vlucas/phpdotenv/src'),
'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'),
......
Copyright (c) 2011-2016 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Guzzle, PHP HTTP client
=======================
[![Build Status](https://travis-ci.org/guzzle/guzzle.svg?branch=master)](https://travis-ci.org/guzzle/guzzle)
Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and
trivial to integrate with web services.
- Simple interface for building query strings, POST requests, streaming large
uploads, streaming large downloads, using HTTP cookies, uploading JSON data,
etc...
- Can send both synchronous and asynchronous requests using the same interface.
- Uses PSR-7 interfaces for requests, responses, and streams. This allows you
to utilize other PSR-7 compatible libraries with Guzzle.
- Abstracts away the underlying HTTP transport, allowing you to write
environment and transport agnostic code; i.e., no hard dependency on cURL,
PHP streams, sockets, or non-blocking event loops.
- Middleware system allows you to augment and compose client behavior.
```php
$client = new \GuzzleHttp\Client();
$res = $client->request('GET', 'https://api.github.com/repos/guzzle/guzzle');
echo $res->getStatusCode();
// 200
echo $res->getHeaderLine('content-type');
// 'application/json; charset=utf8'
echo $res->getBody();
// '{"id": 1420053, "name": "guzzle", ...}'
// Send an asynchronous request.
$request = new \GuzzleHttp\Psr7\Request('GET', 'http://httpbin.org');
$promise = $client->sendAsync($request)->then(function ($response) {
echo 'I completed! ' . $response->getBody();
});
$promise->wait();
```
## Help and docs
- [Documentation](http://guzzlephp.org/)
- [Stack Overflow](http://stackoverflow.com/questions/tagged/guzzle)
- [Gitter](https://gitter.im/guzzle/guzzle)
## Installing Guzzle
The recommended way to install Guzzle is through
[Composer](http://getcomposer.org).
```bash
# Install Composer
curl -sS https://getcomposer.org/installer | php
```
Next, run the Composer command to install the latest stable version of Guzzle:
```bash
php composer.phar require guzzlehttp/guzzle
```
After installing, you need to require Composer's autoloader:
```php
require 'vendor/autoload.php';
```
You can then later update Guzzle using composer:
```bash
composer.phar update
```
## Version Guidance
| Version | Status | Packagist | Namespace | Repo | Docs | PSR-7 | PHP Version |
|---------|------------|---------------------|--------------|---------------------|---------------------|-------|-------------|
| 3.x | EOL | `guzzle/guzzle` | `Guzzle` | [v3][guzzle-3-repo] | [v3][guzzle-3-docs] | No | >= 5.3.3 |
| 4.x | EOL | `guzzlehttp/guzzle` | `GuzzleHttp` | [v4][guzzle-4-repo] | N/A | No | >= 5.4 |
| 5.x | Maintained | `guzzlehttp/guzzle` | `GuzzleHttp` | [v5][guzzle-5-repo] | [v5][guzzle-5-docs] | No | >= 5.4 |
| 6.x | Latest | `guzzlehttp/guzzle` | `GuzzleHttp` | [v6][guzzle-6-repo] | [v6][guzzle-6-docs] | Yes | >= 5.5 |
[guzzle-3-repo]: https://github.com/guzzle/guzzle3
[guzzle-4-repo]: https://github.com/guzzle/guzzle/tree/4.x
[guzzle-5-repo]: https://github.com/guzzle/guzzle/tree/5.3
[guzzle-6-repo]: https://github.com/guzzle/guzzle
[guzzle-3-docs]: http://guzzle3.readthedocs.org/en/latest/
[guzzle-5-docs]: http://guzzle.readthedocs.org/en/5.3/
[guzzle-6-docs]: http://guzzle.readthedocs.org/en/latest/
{
"name": "guzzlehttp/guzzle",
"type": "library",
"description": "Guzzle is a PHP HTTP client library",
"keywords": ["framework", "http", "rest", "web service", "curl", "client", "HTTP client"],
"homepage": "http://guzzlephp.org/",
"license": "MIT",
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"require": {
"php": ">=5.5",
"guzzlehttp/psr7": "^1.4",
"guzzlehttp/promises": "^1.0"
},
"require-dev": {
"ext-curl": "*",
"phpunit/phpunit": "^4.0 || ^5.0",
"psr/log": "^1.0"
},
"autoload": {
"files": ["src/functions_include.php"],
"psr-4": {
"GuzzleHttp\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"GuzzleHttp\\Tests\\": "tests/"
}
},
"suggest": {
"psr/log": "Required for using the Log middleware"
},
"extra": {
"branch-alias": {
"dev-master": "6.2-dev"
}
}
}
<?php
namespace GuzzleHttp;
use GuzzleHttp\Promise\PromiseInterface;
use GuzzleHttp\Exception\GuzzleException;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\UriInterface;
/**
* Client interface for sending HTTP requests.
*/
interface ClientInterface
{
const VERSION = '6.2.1';
/**
* Send an HTTP request.
*
* @param RequestInterface $request Request to send
* @param array $options Request options to apply to the given
* request and to the transfer.
*
* @return ResponseInterface
* @throws GuzzleException
*/
public function send(RequestInterface $request, array $options = []);
/**
* Asynchronously send an HTTP request.
*
* @param RequestInterface $request Request to send
* @param array $options Request options to apply to the given
* request and to the transfer.
*
* @return PromiseInterface
*/
public function sendAsync(RequestInterface $request, array $options = []);
/**
* Create and send an HTTP request.
*
* Use an absolute path to override the base path of the client, or a
* relative path to append to the base path of the client. The URL can
* contain the query string as well.
*
* @param string $method HTTP method.
* @param string|UriInterface $uri URI object or string.
* @param array $options Request options to apply.
*
* @return ResponseInterface
* @throws GuzzleException
*/
public function request($method, $uri, array $options = []);
/**
* Create and send an asynchronous HTTP request.
*
* Use an absolute path to override the base path of the client, or a
* relative path to append to the base path of the client. The URL can
* contain the query string as well. Use an array to provide a URL
* template and additional variables to use in the URL template expansion.
*
* @param string $method HTTP method
* @param string|UriInterface $uri URI object or string.
* @param array $options Request options to apply.
*
* @return PromiseInterface
*/
public function requestAsync($method, $uri, array $options = []);
/**
* Get a client configuration option.
*
* These options include default request options of the client, a "handler"
* (if utilized by the concrete client), and a "base_uri" if utilized by
* the concrete client.
*
* @param string|null $option The config option to retrieve.
*
* @return mixed
*/
public function getConfig($option = null);
}
<?php
namespace GuzzleHttp\Cookie;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
/**
* Cookie jar that stores cookies as an array
*/
class CookieJar implements CookieJarInterface
{
/** @var SetCookie[] Loaded cookie data */
private $cookies = [];
/** @var bool */
private $strictMode;
/**
* @param bool $strictMode Set to true to throw exceptions when invalid
* cookies are added to the cookie jar.
* @param array $cookieArray Array of SetCookie objects or a hash of
* arrays that can be used with the SetCookie
* constructor
*/
public function __construct($strictMode = false, $cookieArray = [])
{
$this->strictMode = $strictMode;
foreach ($cookieArray as $cookie) {
if (!($cookie instanceof SetCookie)) {
$cookie = new SetCookie($cookie);
}
$this->setCookie($cookie);
}
}
/**
* Create a new Cookie jar from an associative array and domain.
*
* @param array $cookies Cookies to create the jar from
* @param string $domain Domain to set the cookies to
*
* @return self
*/
public static function fromArray(array $cookies, $domain)
{
$cookieJar = new self();
foreach ($cookies as $name => $value) {
$cookieJar->setCookie(new SetCookie([
'Domain' => $domain,
'Name' => $name,
'Value' => $value,
'Discard' => true
]));
}
return $cookieJar;
}
/**
* @deprecated
*/
public static function getCookieValue($value)
{
return $value;
}
/**
* Evaluate if this cookie should be persisted to storage
* that survives between requests.
*
* @param SetCookie $cookie Being evaluated.
* @param bool $allowSessionCookies If we should persist session cookies
* @return bool
*/
public static function shouldPersist(
SetCookie $cookie,
$allowSessionCookies = false
) {
if ($cookie->getExpires() || $allowSessionCookies) {
if (!$cookie->getDiscard()) {
return true;
}
}
return false;
}
/**
* Finds and returns the cookie based on the name
*
* @param string $name cookie name to search for
* @return SetCookie|null cookie that was found or null if not found
*/
public function getCookieByName($name)
{
// don't allow a null name
if($name === null) {
return null;
}
foreach($this->cookies as $cookie) {
if($cookie->getName() !== null && strcasecmp($cookie->getName(), $name) === 0) {
return $cookie;
}
}
}
public function toArray()
{
return array_map(function (SetCookie $cookie) {
return $cookie->toArray();
}, $this->getIterator()->getArrayCopy());
}
public function clear($domain = null, $path = null, $name = null)
{
if (!$domain) {
$this->cookies = [];
return;
} elseif (!$path) {
$this->cookies = array_filter(
$this->cookies,
function (SetCookie $cookie) use ($path, $domain) {
return !$cookie->matchesDomain($domain);
}
);
} elseif (!$name) {
$this->cookies = array_filter(
$this->cookies,
function (SetCookie $cookie) use ($path, $domain) {
return !($cookie->matchesPath($path) &&
$cookie->matchesDomain($domain));
}
);
} else {
$this->cookies = array_filter(
$this->cookies,
function (SetCookie $cookie) use ($path, $domain, $name) {
return !($cookie->getName() == $name &&
$cookie->matchesPath($path) &&
$cookie->matchesDomain($domain));
}
);
}
}
public function clearSessionCookies()
{
$this->cookies = array_filter(
$this->cookies,
function (SetCookie $cookie) {
return !$cookie->getDiscard() && $cookie->getExpires();
}
);
}
public function setCookie(SetCookie $cookie)
{
// If the name string is empty (but not 0), ignore the set-cookie
// string entirely.
$name = $cookie->getName();
if (!$name && $name !== '0') {
return false;
}
// Only allow cookies with set and valid domain, name, value
$result = $cookie->validate();
if ($result !== true) {
if ($this->strictMode) {
throw new \RuntimeException('Invalid cookie: ' . $result);
} else {
$this->removeCookieIfEmpty($cookie);
return false;
}
}
// Resolve conflicts with previously set cookies
foreach ($this->cookies as $i => $c) {
// Two cookies are identical, when their path, and domain are
// identical.
if ($c->getPath() != $cookie->getPath() ||
$c->getDomain() != $cookie->getDomain() ||
$c->getName() != $cookie->getName()
) {
continue;
}
// The previously set cookie is a discard cookie and this one is
// not so allow the new cookie to be set
if (!$cookie->getDiscard() && $c->getDiscard()) {
unset($this->cookies[$i]);
continue;
}
// If the new cookie's expiration is further into the future, then
// replace the old cookie
if ($cookie->getExpires() > $c->getExpires()) {
unset($this->cookies[$i]);
continue;
}
// If the value has changed, we better change it
if ($cookie->getValue() !== $c->getValue()) {
unset($this->cookies[$i]);
continue;
}
// The cookie exists, so no need to continue
return false;
}
$this->cookies[] = $cookie;
return true;
}
public function count()
{
return count($this->cookies);
}
public function getIterator()
{
return new \ArrayIterator(array_values($this->cookies));
}
public function extractCookies(
RequestInterface $request,
ResponseInterface $response
) {
if ($cookieHeader = $response->getHeader('Set-Cookie')) {
foreach ($cookieHeader as $cookie) {
$sc = SetCookie::fromString($cookie);
if (!$sc->getDomain()) {
$sc->setDomain($request->getUri()->getHost());
}
if (0 !== strpos($sc->getPath(), '/')) {
$sc->setPath($this->getCookiePathFromRequest($request));
}
$this->setCookie($sc);
}
}
}
/**
* Computes cookie path following RFC 6265 section 5.1.4
*
* @link https://tools.ietf.org/html/rfc6265#section-5.1.4
*
* @param RequestInterface $request
* @return string
*/
private function getCookiePathFromRequest(RequestInterface $request)
{
$uriPath = $request->getUri()->getPath();
if ('' === $uriPath) {
return '/';
}
if (0 !== strpos($uriPath, '/')) {
return '/';
}
if ('/' === $uriPath) {
return '/';
}
if (0 === $lastSlashPos = strrpos($uriPath, '/')) {
return '/';
}
return substr($uriPath, 0, $lastSlashPos);
}
public function withCookieHeader(RequestInterface $request)
{
$values = [];
$uri = $request->getUri();
$scheme = $uri->getScheme();
$host = $uri->getHost();
$path = $uri->getPath() ?: '/';
foreach ($this->cookies as $cookie) {
if ($cookie->matchesPath($path) &&
$cookie->matchesDomain($host) &&
!$cookie->isExpired() &&
(!$cookie->getSecure() || $scheme === 'https')
) {
$values[] = $cookie->getName() . '='
. $cookie->getValue();
}
}
return $values
? $request->withHeader('Cookie', implode('; ', $values))
: $request;
}
/**
* If a cookie already exists and the server asks to set it again with a
* null value, the cookie must be deleted.
*
* @param SetCookie $cookie
*/
private function removeCookieIfEmpty(SetCookie $cookie)
{
$cookieValue = $cookie->getValue();
if ($cookieValue === null || $cookieValue === '') {
$this->clear(
$cookie->getDomain(),
$cookie->getPath(),
$cookie->getName()
);
}
}
}
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