Commit 87b52648 by 杨树贤

特殊规则修改

parent a02b4b1e
......@@ -92,7 +92,7 @@ class CommonApiController extends Controller
if (!$company) {
$this->response(-1, '获取不到公司');
}
}else{
} else {
$this->response(-2, '供应商跳过天眼查校验');
}
......@@ -100,4 +100,21 @@ class CommonApiController extends Controller
}
//批量校验标准品牌,并且返回具体的id和错误信息
public function checkStandardBrandNameList(Request $request)
{
//接收的是标准品牌名称
$standardBrandNameList = $request->input('standard_brand_name_list');
if (empty($standardBrandNameList)) {
$this->response(0, 'ok', [
'invalid_brand_name_list' => [],
'valid_brand_name_list' => [],
'valid_brand_ids' => [],
]);
}
$standardBrandNameList = explode(',', trim($standardBrandNameList, ','));
$result = (new StandardBrandService())->checkStandardBrandNameList($standardBrandNameList);
$this->response(0, 'ok', $result);
}
}
......@@ -58,12 +58,17 @@ class PurchaseRemarkApiController extends Controller
$remark = $request->only([
'id',
'supplier_id',
'participate_type',
'participate_content',
'start_time',
'end_time',
'description',
'remark',
]);
$remark['start_time'] = strtotime($remark['start_time']);
if ($remark['start_time'] < time()) {
$this->response(-1,'开始时间不能低于当前日期');
}
$remark['end_time'] = strtotime($remark['end_time']);
$remarkService = new PurchaseRemarkService();
$result = $remarkService->savePurchaseRemark($id,$remark);
if (!$result) {
......@@ -71,8 +76,9 @@ class PurchaseRemarkApiController extends Controller
} else {
$logService = new LogService();
$content = !empty($remark['id']) ? '修改采购备注' : '添加采购备注';
$supplierId = $remark['supplier_id'];
$remark = json_encode($remark);
$logService->AddLog($remark['supplier_id'], LogModel::UPDATE_OPERATE, $content, $content, $remark);
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, $content, $content, $remark);
$this->response(0, '保存成功');
}
}
......
......@@ -41,6 +41,8 @@ class PurchaseRemarkController extends Controller
if (!empty($id)) {
$model = new PurchaseRemarkModel();
$remark = $model->where('id', $id)->first()->toArray();
$remark['start_time'] = date('Y-m-d', $remark['start_time']);
$remark['end_time'] = date('Y-m-d', $remark['end_time']);
$this->data['remark'] = $remark;
}
$this->data['title'] = '保存采购备注';
......
......@@ -4,11 +4,13 @@
namespace App\Http\Services;
use App\Model\BrandModel;
use App\Model\SpuBrandModel;
use App\Model\RedisModel;
use App\Model\StandardBrandMappingModel;
use App\Model\StandardBrandModel;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
class StandardBrandService
{
......@@ -95,4 +97,68 @@ class StandardBrandService
$standardBrandIds = StandardBrandModel::whereIn('brand_name', $standardBrandNames)->pluck('standard_brand_id')->toArray();
return $this->getBrandInitValue(implode(',',$standardBrandIds));
}
//根据品牌id获取标准品牌名字列表
public function getStandardBrandNameListByBrandIds($brandIds)
{
$brandIds = explode(',', trim($brandIds, ','));
if (empty($brandIds)) {
return '';
}
$redis = Redis::connection();
$brands = $redis->hmget('standard_brand', $brandIds);
$standardBrandNameList = [];
foreach ($brands as $brand) {
$brand = json_decode($brand, true);
$standardBrandNameList[] = $brand['brand_name'];
}
return $standardBrandNameList ? implode(',', $standardBrandNameList) : '';
}
public function checkStandardBrandNameList($standardBrandNameList = [])
{
//去数据库查询
$validStandardBrandList =StandardBrandModel::whereIn('brand_name',
$standardBrandNameList)
->pluck('brand_name', 'standard_brand_id')->toArray();
$validStandardBrandMap = array_flip($validStandardBrandList);
$invalidBrandNameList = [];
$validStandardBrandNameList = [];
$validStandardBrandIds = [];
//判断哪些是错误的,哪些是正确的
$redis = Redis::connection();
foreach ($standardBrandNameList as $key => $standardBrandName) {
if (in_array($standardBrandName, array_values($validStandardBrandList))) {
$validStandardBrandIds[] = $validStandardBrandMap[$standardBrandName];
$validStandardBrandNameList[] = $standardBrandName;
unset($standardBrandNameList[$key]);
}
}
//剩下没有能直接找到标准品牌的,先当作普通品牌处理,然后去找出标准品牌,如果还是找不到,那就是无效品牌了
foreach ($standardBrandNameList as $key => $checkStandardBrandName) {
//先去找对应的标准品牌
$brandId = BrandModel::where('brand_name', $checkStandardBrandName)->value('brand_id');
$standardBrandId = $redis->hget('standard_brand_mapping', $brandId);
if (empty($standardBrandId)) {
$invalidBrandNameList[] = $checkStandardBrandName;
continue;
}
$standardBrand = $redis->hget('standard_brand', $standardBrandId);
$standardBrand = json_decode($standardBrand, true);
$standardBrandName = array_get($standardBrand, 'brand_name', '');
$standardBrandId = array_get($standardBrand, 'standard_brand_id', '');
if (empty($standardBrandName)) {
$invalidBrandNameList[] = $checkStandardBrandName;
continue;
}
$validStandardBrandIds[] = $standardBrandId;
$validStandardBrandNameList[] = $standardBrandName;
}
//整合数据,返回标准的数据和无效的数据
return [
'invalid_brand_name_list' => $invalidBrandNameList,
'valid_brand_name_list' => $validStandardBrandNameList,
'valid_brand_ids' => $validStandardBrandIds,
];
}
}
\ No newline at end of file
......@@ -17,16 +17,18 @@ class PurchaseRemarkTransformer
if (!$remark) {
continue;
}
$remark['participate_type_name'] = array_get(config('field.PurchaseRemarkParticipateType'), $remark['participate_type'],'无');
$remark['participate_type_name'] = array_get(config('field.PurchaseRemarkParticipateType'), $remark['participate_type'], '无');
$remark['create_time'] = $remark['create_time'] ? date('Y-m-d H:i:s',
$remark['create_time']) : '';
$remark['update_time'] = $remark['update_time'] ? date('Y-m-d H:i:s',
$remark['update_time']) : '';
$remark['start_time'] = $remark['update_time'] ? date('Y-m-d',
$remark['end_time']) : ''; $remark['end_time'] = $remark['update_time'] ? date('Y-m-d',
$remark['status'] = $remark['end_time'] < time() ? 1 : -1;
$remark['start_time'] = $remark['start_time'] ? date('Y-m-d',
$remark['start_time']) : '';
$remark['end_time'] = $remark['start_time'] ? date('Y-m-d',
$remark['end_time']) : '';
$remark['duration'] = $remark['start_time'] . ' ~ ' . $remark['end_time'];
}
unset($remark);
return $list;
......
......@@ -31,6 +31,7 @@ Route::group(['middleware' => ['web', 'menu']], function () {
Route::match(['get', 'post'], '/log/{key}', 'LogController@Entrance');
Route::match(['get', 'post'], '/supplier_apply/{key}', 'SupplierApplyController@info');
Route::match(['get', 'post'], '/purchase_remark/{key}', 'PurchaseRemarkController@info');
Route::match(['get', 'post'], '/shipping_cost_ruler/{key}', 'ShippingCostRulerController@info');
});
Route::group(['middleware' => ['web'], 'namespace' => 'Api'], function () {
......@@ -52,6 +53,7 @@ Route::group(['middleware' => ['web'], 'namespace' => 'Api'], function () {
Route::match(['get', 'post'], '/api/sku_upload_log/{key}', 'SkuUploadLogApiController@Entrance');
Route::match(['get', 'post'], '/api/supplier_apply/{key}', 'SupplierApplyApiController@Entrance');
Route::match(['get', 'post'], '/api/purchase_remark/{key}', 'PurchaseRemarkApiController@Entrance');
Route::match(['get', 'post'], '/api/shipping_cost_ruler/{key}', 'ShippingCostRulerApiController@Entrance');
//单独的统计接口
Route::match(['get', 'post'], '/statisticsSkuNumber', function () {
(new \App\Http\Services\DataService())->statisticsSkuNumber();
......
<script>
layui.use(['table', 'form', 'element', 'table', 'layer', 'admin', 'xmSelect'], function () {
layui.use(['table', 'form', 'element', 'table', 'layer', 'admin', 'xmSelect', 'laydate'], function () {
let admin = layui.admin;
let form = layui.form;
let element = layui.element;
let laydate = layui.laydate;
let xmSelect = layui.xmSelect;
laydate.render({
elem: '#start_time'
, format: 'yyyy-MM-dd'
});
laydate.render({
elem: '#end_time'
, format: 'yyyy-MM-dd'
});
form.on('radio(participate_type)', function (data) {
let type = data.value;
if (type === '1') {
$('#participate_content').attr('disabled', true);
$('#participate_content').addClass('layui-disabled');
} else {
$('#participate_content').attr('disabled', false);
$('#participate_content').removeClass('layui-disabled');
}
});
form.on('submit(savePurchaseRemark)', function (data) {
let url = '/api/purchase_remark/SavePurchaseRemark';
data.field.supplier_id = getQueryVariable('supplier_id');
let participateType = data.field.participate_type;
//如果是品牌类型,那么就要去校验品牌是否都是对的
if (participateType == 3) {
let checkBrandRes = ajax('/api/common/checkStandardBrandNameList', {standard_brand_name_list: data.field.participate_content});
if (checkBrandRes.code == 0) {
if (checkBrandRes.data.invalid_brand_name_list.length > 0) {
let list = checkBrandRes.data.invalid_brand_name_list.join(',');
list += ' 不是标准品牌名称';
$('#checkStandardBrandNameResult').text(list);
layer.msg("标准品牌校验未通过,请修正品牌后再重新提交")
return false;
}
}
}
let res = ajax(url, data.field);
if (!res) {
layer.msg('网络错误,请重试', {icon: 6});
......@@ -23,19 +60,5 @@
form.on('submit(cancel)', function (data) {
admin.closeThisDialog();
});
form.on('submit(delete)', function (data) {
layer.confirm('确定要删除该条采购备注吗?', function (index) {
let id = getQueryVariable('id');
let res = ajax('/api/purchase_remark/DeletePurchaseRemark', {id: id})
if (res.err_code === 0) {
layer.msg(res.err_msg, {icon: 6})
setTimeout(function () {
admin.closeThisDialog();
},1000);
} else {
layer.msg(res.err_msg, {icon: 5})
}
});
});
});
</script>
\ No newline at end of file
<script>
layui.use(['table', 'form', 'element', 'layer', 'admin', 'laydate', 'xmSelect'], function () {
let admin = layui.admin;
let form = layui.form;
let table = layui.table;
let layDate = layui.laydate;
let element = layui.element;
let xmSelect = layui.xmSelect;
table.render({
elem: '#purchaseRemarkList',
url: '/api/purchase_remark/GetPurchaseRemarkList',
method: 'get',
cellMinWidth: 80,//全局定义常规单元格的最小宽度
where: {
supplier_id: getQueryVariable("supplier_id")
},
loading: true,
first: true,//不显示首页
last: false,//不显示尾页
cols: [[
{field: 'participate_type_name', title: '参与类型', align: 'center', width: 140},
{field: 'participate_content', title: '传真', align: 'center', width: 140},
{field: 'duration', title: '开始时间 - 截至时间', align: 'center', width: 300},
{field: 'remark', title: '备注内容', align: 'center'},
]],
id: 'purchaseRemarkList',
page: {},
});
//新增联系方式
$("#savePurchaserRemark").click(function () {
let supplierId = getQueryVariable('supplier_id');
layer.open({
type: 2,
content: '/purchase_remark/SavePurchaseRemark?view=iframe&supplier_id=' + supplierId,
area: ['800px', '725px'],
title: '新增采购备注',
end: function () { // 监听弹窗关闭
table.reload('purchaseRemarkList');
}
});
})
});
</script>
\ No newline at end of file
......@@ -38,7 +38,7 @@
},
{field: 'description', title: '附件说明', align: 'center', width: 250},
{field: 'validity_period', title: '<span class="require">* </span>有效期', align: 'center', width: 220},
{field: 'create_name', title: '上传人', align: 'center', width: 100},
{field: 'create_name', title: '内部采购', align: 'center', width: 100},
{field: 'create_time', title: '上传时间', align: 'center', width: 150},
]],
id: 'attachmentList',
......
......@@ -8,45 +8,65 @@
<form class="layui-form" action="">
<div class="layui-form-item">
@inject('singleSelectPresenter','App\Presenters\SingleSelectPresenter')
{!! $singleSelectPresenter->render('participate_type','参与类型 :',!empty($remark)?$remark['participate_type']:1,config('field.PurchaseRemarkParticipateType'),['required'=>true]) !!}
{!! $singleSelectPresenter->render('participate_type','参与类型 :',!empty($remark)?$remark['participate_type']:1,config('field.PurchaseRemarkParticipateType'),['required'=>true,'disable' => !empty($remark)?true:false]) !!}
</div>
<div class="layui-form-item">
<label class="layui-form-label"><span style="color: red">*</span>参与内容 : </label>
<div class="layui-input-block">
<input type="text" name="register_company_name" id="register_company_name"
placeholder="请输入注册公司名,注册公司名必须同执照" class="layui-input"
value="{{$remark['register_company_name'] or ''}}">
<div id="participate_content_div">
<textarea rows="7" name="participate_content"
placeholder="请输入 型号/标准品牌 全称,多个以英文逗号隔开,如果选择品牌类型,会去校验标准品牌是否正确"
class="layui-textarea @if(empty($remark) || (!empty($remark) && $remark['participate_type']==1)) layui-disabled @endif"
@if(empty($remark)|| (!empty($remark) && $remark['participate_type']==1)) disabled @endif
id="participate_content">{{$remark['participate_content'] or ''}}</textarea>
</div>
<blockquote class="layui-elem-quote layui-text">
<b style="color: red" id="checkStandardBrandNameResult"></b>
</blockquote>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label"><span style="color: red">*</span>参与时间 : </label>
<div class="layui-input-block">
<input type="text" id="established_time" name="established_time"
placeholder="请输入成立时间"
<div class="layui-col-xs4">
<div class="layui-input-inline">
<input type="text" id="start_time" name="start_time"
placeholder="请输入开始时间"
class="layui-input"
autocomplete="off"
value="{{$supplier['established_time'] or ''}}">
value="{{$remark['start_time'] or ''}}">
</div>
</div>
<div class="layui-col-xs1">
<span style="width: 10px"> --</span>
</div>
<div class="layui-col-xs7" style="margin-left: -25px">
<div class="layui-input-inline">
<input type="text" id="end_time" name="end_time"
placeholder="请输入截止时间"
class="layui-input"
autocomplete="off"
value="{{$remark['end_time'] or ''}}">
</div>
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label"><span style="color: red">*</span>备注内容 : </label>
<div class="layui-input-block">
<textarea rows="7" name="remark_content" placeholder="活动内容(展示在【询报价系统】供销售查看的内容通知)"
<textarea rows="7" name="remark" placeholder="活动内容(展示在【询报价系统】供销售查看的内容通知)"
class="layui-textarea"
id="remark_content">{{$remark['remark_content'] or ''}}</textarea>
id="remark">{{$remark['remark'] or ''}}</textarea>
</div>
</div>
<div class="layui-form-item">
<div align="right" style="margin-top: 20px">
<button type="button" class="layui-btn layui-btn-sm layui-btn-info submit-loading" lay-submit
lay-filter="load">确认
lay-filter="savePurchaseRemark">确认
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-primary" lay-submit
lay-filter="cancel">关闭
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-danger" lay-submit
lay-filter="delete">删除
</button>
</div>
</div>
......
......@@ -133,12 +133,6 @@
@endif
id="examination">检测记录
</li>
<li @if (!checkPerm('ViewOrderRemark')) style="display: none" @endif
@if(request()->get('tab')=='order_remark')
class="layui-this"
@endif
id="order_remark">下单备注
</li>
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item
......@@ -259,10 +253,6 @@
@include('web.SupplierExaminationList')
</div>
</div>
{{--下单备注--}}
<div class="layui-tab-item @if(request()->get('tab')=='order_remark') layui-show @endif">
@include('web.supplier.OrderRemark')
</div>
</div>
</div>
@include('web.supplier.ApplyAuditReason')
......
<blockquote class="layui-elem-quote layui-text">
<b>采购备注<span
style="color: orange;margin-left: 10px">PS:设置后的备注信息,将会应用在【询报价系统】供销售看到(仅做为提示)</span></b>
</blockquote>
<div class="layui-form-item">
<button class="layui-btn layui-btn-sm" type="button" id="savePurchaserRemark">添加备注</button>
<table class="layui-table" lay-filter="purchaseRemarkList" id="purchaseRemarkList"></table>
</div>
<div style="margin-bottom: 300px"></div>
<blockquote class="layui-elem-quote layui-text">
<b>采购附加费设置</b>
</blockquote>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">商品总价不满</label>
<div class="layui-input-inline" style="width: 100px;">
<input class="layui-input" type="text" name="cn[max]" id="cn_max"
value="{{$supplier['extra_fee']['cn']['max'] or ''}}"
lay-verify="num">
</div>
<div class="layui-form-label" style="width: 100px;margin-left: -20px">元(人民币),收取</div>
<div class="layui-input-inline" style="width: 100px;">
<input class="layui-input" type="text" name="cn[price]"
value="{{$supplier['extra_fee']['cn']['price'] or ''}}"
lay-verify="float" value="">
</div>
<div class="layui-form-label" style="width: 40px;margin-left: -20px">元运费</div>
<div class="layui-input-inline" style="width: 100px;">
<input type="checkbox" title="全渠道收费" lay-skin="primary" lay-filter="cn_filter">
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">商品总价不满</label>
<div class="layui-input-inline" style="width: 100px;">
<input class="layui-input" type="text" name="hk[max]" id="hk_max"
value="{{$supplier['extra_fee']['hk']['max'] or ''}}"
lay-verify="num" value="">
</div>
<div class="layui-form-label" style="width: 55px;margin-left: -20px">美金,收取</div>
<div class="layui-input-inline" style="width: 100px;">
<input class="layui-input" type="text" name="hk[price]"
value="{{$supplier['extra_fee']['hk']['price'] or ''}}"
lay-verify="float" value="">
</div>
<div class="layui-form-label" style="width: 40px;margin-left: -20px">元运费</div>
<div class="layui-input-inline" style="width: 100px;">
<input type="checkbox" title="全渠道收费" lay-skin="primary" lay-filter="hk_filter">
</div>
</div>
</div>
<blockquote class="layui-elem-quote layui-text">
<b>采购价格系数调整</b>
</blockquote>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">人民币系数</label>
<div class="layui-input-inline" style="width: 50px">
<input type="text" name="cn_ratio" value="{{$supplier['cn_ratio'] or 1}}"
placeholder="请输入人民币系数" autocomplete="off" class="layui-input" style="display: inline-block">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">美金系数</label>
<div class="layui-input-inline" style="width: 50px">
<input type="text" name="us_ratio" value="{{$supplier['us_ratio'] or 1}}"
placeholder="请输入采购附加费" autocomplete="off" class="layui-input">
</div>
<div class="layui-form-mid layui-word-aux">
基数为1,如利润为10%,请填写1.1
</div>
</div>
</div>
<blockquote class="layui-elem-quote layui-text">
<b>货期调整</b>
</blockquote>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">大陆交期</label>
<div class="layui-input-inline" style="width: 50px">
<input type="text" name="cn_delivery_time" value="{{$supplier['cn_delivery_time'] or 1}}"
autocomplete="off" class="layui-input">
</div>
<div class="layui-input-inline" style="width: 50px">
<select name="cn_delivery_time_period">
<option value="天" @if($supplier['cn_delivery_time_period'] == '天') selected @endif></option>
<option value="周" @if($supplier['cn_delivery_time_period'] == '周') selected @endif></option>
</select>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">香港交期</label>
<div class="layui-input-inline" style="width: 50px">
<input type="text" name="us_delivery_time" value="{{$supplier['us_delivery_time'] or 1}}"
autocomplete="off" class="layui-input">
</div>
<div class="layui-input-inline" style="width: 50px">
<select name="us_delivery_time_period">
<option value="天" @if($supplier['us_delivery_time_period'] == '天') selected @endif></option>
<option value="周" @if($supplier['us_delivery_time_period'] == '周') selected @endif></option>
</select>
</div>
<div class="layui-form-mid layui-word-aux">
单位为工作日,周。格式2-6工作日,1-2周
</div>
</div>
</div>
@include('script.supplier.OrderRemarkScript')
\ No newline at end of file
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