Commit d95eeaf8 by 杨树贤

Merge branch 'master' into ysx-SKU上传同步芯链选项交互优化&新建供应商期货默认项更改-20250804

parents 6718b5ba 3d7ac1b2
# Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv) # Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv)
vendor/ vendor/
storage/
public/
...@@ -20,6 +20,7 @@ use App\Http\Services\SyncSupplierService; ...@@ -20,6 +20,7 @@ use App\Http\Services\SyncSupplierService;
use App\Http\Validators\SupplierValidator; use App\Http\Validators\SupplierValidator;
use App\Http\Services\StandardBrandService; use App\Http\Services\StandardBrandService;
use App\Http\Services\SupplierAuditService; use App\Http\Services\SupplierAuditService;
use App\Http\Services\SupplierContactService;
use App\Http\Transformers\SupplierTransformer; use App\Http\Transformers\SupplierTransformer;
use App\Http\Controllers\Filter\SupplierFilter; use App\Http\Controllers\Filter\SupplierFilter;
use App\Http\Services\SupplierStatisticsService; use App\Http\Services\SupplierStatisticsService;
...@@ -511,6 +512,8 @@ class SupplierApiController extends Controller ...@@ -511,6 +512,8 @@ class SupplierApiController extends Controller
$result = $service->allocateChannelUser($supplierId, $channelUid, $channelUserType); $result = $service->allocateChannelUser($supplierId, $channelUid, $channelUserType);
} }
} }
$supplierContactService = new SupplierContactService();
$supplierContactService->updateSupplierCodeData($supplierId);
} }
if (!$result) { if (!$result) {
......
...@@ -42,16 +42,16 @@ class SupplierContractApiController extends Controller ...@@ -42,16 +42,16 @@ class SupplierContractApiController extends Controller
$validator = \Validator::make($data, [ $validator = \Validator::make($data, [
'supplier_id' => 'required|integer', 'supplier_id' => 'required|integer',
'end_time' => 'required|date', 'end_time' => 'required|date',
'recall_time' => 'required|date',
'commission_rate' => 'numeric|max:100|min:1', 'commission_rate' => 'numeric|max:100|min:1',
'check_date' => 'required|integer|min:1|max:31' 'check_date' => 'required|integer|min:1|max:31'
], [ ], [
'supplier_id.required' => '供应商ID不能为空', 'supplier_id.required' => '供应商ID不能为空',
'supplier_id.integer' => '供应商ID必须为整数', 'supplier_id.integer' => '供应商ID必须为整数',
'start_time.required' => '合同开始时间不能为空',
'start_time.date' => '合同开始时间必须为日期格式',
'end_time.required' => '合同结束时间不能为空', 'end_time.required' => '合同结束时间不能为空',
'end_time.date' => '合同结束时间必须为日期格式', 'end_time.date' => '合同结束时间必须为日期格式',
'end_time.after' => '合同结束时间必须大于合同开始时间', 'recall_time.required' => '召回期不能为空',
'recall_time.date' => '召回期必须为日期格式',
'commission_rate.required' => '抽佣比率不能为空', 'commission_rate.required' => '抽佣比率不能为空',
'commission_rate.numeric' => '抽佣比率必须为数字', 'commission_rate.numeric' => '抽佣比率必须为数字',
'commission_rate.max' => '抽佣比率不能大于100', 'commission_rate.max' => '抽佣比率不能大于100',
......
...@@ -262,10 +262,10 @@ class SupplierFilter ...@@ -262,10 +262,10 @@ class SupplierFilter
}); });
// 额外显示的特殊状态(如果有权限) // 额外显示的特殊状态(如果有权限)
if ($canViewBlockSupplier) { if ($canViewBlockSupplier && !checkPerm('ViewAllSupplier')) {
$mainQuery->orWhere('status', SupplierChannelModel::STATUS_BLOCK); $mainQuery->orWhere('status', SupplierChannelModel::STATUS_BLOCK);
} }
if ($canViewDisableSupplier) { if ($canViewDisableSupplier && !checkPerm('ViewAllSupplier')) {
$mainQuery->orWhere('status', SupplierChannelModel::STATUS_DISABLE); $mainQuery->orWhere('status', SupplierChannelModel::STATUS_DISABLE);
} }
}); });
......
...@@ -59,6 +59,7 @@ class SupplierContractController extends Controller ...@@ -59,6 +59,7 @@ class SupplierContractController extends Controller
$contract = $model->with('supplier')->where('id', $id)->first()->toArray(); $contract = $model->with('supplier')->where('id', $id)->first()->toArray();
$contract['start_time'] = date('Y-m-d H:i:s', $contract['start_time']); $contract['start_time'] = date('Y-m-d H:i:s', $contract['start_time']);
$contract['end_time'] = date('Y-m-d H:i:s', $contract['end_time']); $contract['end_time'] = date('Y-m-d H:i:s', $contract['end_time']);
$contract['recall_time'] = $contract['recall_time'] ? date('Y-m-d H:i:s', $contract['recall_time']) : '';
$this->data['contract'] = $contract; $this->data['contract'] = $contract;
} }
$this->data['supplierList'] = $supplierList; $this->data['supplierList'] = $supplierList;
......
...@@ -203,7 +203,6 @@ class SupplierController extends Controller ...@@ -203,7 +203,6 @@ class SupplierController extends Controller
} else { } else {
$this->data['title'] = '添加供应商'; $this->data['title'] = '添加供应商';
} }
return $this->view('新增供应商'); return $this->view('新增供应商');
} }
...@@ -248,7 +247,7 @@ class SupplierController extends Controller ...@@ -248,7 +247,7 @@ class SupplierController extends Controller
$supplier['customer_tags'] = $customerTags ? implode(',', $customerTags['list']) : ''; $supplier['customer_tags'] = $customerTags ? implode(',', $customerTags['list']) : '';
$supplierModel = new SupplierChannelModel(); $supplierModel = new SupplierChannelModel();
$supplierModel->where('supplier_id', $supplierId)->update([ $supplierModel->where('supplier_id', $supplierId)->update([
'customer_tags' => $supplier['customer_tags']?:'', 'customer_tags' => $supplier['customer_tags'] ?: '',
]); ]);
$this->data['supplier'] = $supplier; $this->data['supplier'] = $supplier;
$this->data['address'] = $supplierService->getAddress($supplierId); $this->data['address'] = $supplierService->getAddress($supplierId);
......
...@@ -5,6 +5,7 @@ namespace App\Http\Services; ...@@ -5,6 +5,7 @@ namespace App\Http\Services;
use App\Model\LogModel; use App\Model\LogModel;
use App\Model\RedisModel;
use App\Model\SupplierChannelModel; use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel; use App\Model\SupplierContactModel;
...@@ -98,6 +99,8 @@ class SupplierContactService ...@@ -98,6 +99,8 @@ class SupplierContactService
$logService->AddLog($contact['supplier_id'], LogModel::UPDATE_OPERATE, '修改供应商基本资料', $content, $remark); $logService->AddLog($contact['supplier_id'], LogModel::UPDATE_OPERATE, '修改供应商基本资料', $content, $remark);
} }
$this->updateSupplierCodeData($supplierId);
return $result; return $result;
} }
...@@ -197,4 +200,18 @@ class SupplierContactService ...@@ -197,4 +200,18 @@ class SupplierContactService
} }
return $result; return $result;
} }
public function updateSupplierCodeData($supplierId)
{
//还要把采购员的列表写到特定redis字段给商品新增服务使用
$supplier = SupplierChannelModel::where('supplier_id', $supplierId)->select(['supplier_code', 'channel_uid'])->first();
$redis = new RedisModel();
$supplierCodeData = $redis->hget('supplier_code', $supplier->supplier_code);
if ($supplierCodeData) {
$supplierCodeData = json_decode($supplierCodeData, true);
$supplierCodeData['channel_uid'] = $supplier->channel_uid;
$redis->hset('supplier_code', $supplier->supplier_code, json_encode($supplierCodeData));
}
}
} }
...@@ -33,6 +33,7 @@ class SupplierContractService ...@@ -33,6 +33,7 @@ class SupplierContractService
try { try {
\DB::connection('web')->beginTransaction(); \DB::connection('web')->beginTransaction();
$data['end_time'] = strtotime($data['end_time']); $data['end_time'] = strtotime($data['end_time']);
$data['recall_time'] = strtotime($data['recall_time']);
// 检查是否已存在相同供应商的合同 // 检查是否已存在相同供应商的合同
if (empty($data['id'])) { if (empty($data['id'])) {
...@@ -61,6 +62,7 @@ class SupplierContractService ...@@ -61,6 +62,7 @@ class SupplierContractService
'end_time' => '合同有效期', 'end_time' => '合同有效期',
'commission_rate' => '抽佣比率', 'commission_rate' => '抽佣比率',
'check_date' => '对账日期', 'check_date' => '对账日期',
'recall_time' => '召回期',
]; ];
$diffArr = []; $diffArr = [];
$oldData = $oldData->toArray(); $oldData = $oldData->toArray();
...@@ -124,7 +126,7 @@ class SupplierContractService ...@@ -124,7 +126,7 @@ class SupplierContractService
} catch (\Exception $e) { } catch (\Exception $e) {
\DB::connection('web')->rollBack(); \DB::connection('web')->rollBack();
\Log::error(json_encode($e->getMessage()) . ' ' . $e->getLine()); \Log::error(json_encode($e->getMessage()) . ' ' . $e->getLine());
return $e->getMessage(); return $e->getMessage().' '.$e->getLine();
} }
} }
......
...@@ -295,7 +295,7 @@ class SupplierValidator ...@@ -295,7 +295,7 @@ class SupplierValidator
//如果付款方式为账期,那么月结天数一定要选 //如果付款方式为账期,那么月结天数一定要选
if ($validateData['pay_type'] == 1) { if ($validateData['pay_type'] == 1) {
if (!array_get($validateData, 'pay_type_value')) { if (!array_get($validateData, 'pay_type_value')) {
$errorMessageList[] = '付款方式选择账期,月结天数必须设置'; $errorMessageList[] = '付款方式选择账期,具体的付款周期值必填';
} }
} }
......
...@@ -15,9 +15,10 @@ ...@@ -15,9 +15,10 @@
use App\Model\RedisModel; use App\Model\RedisModel;
use App\Http\Services\CrmService; use App\Http\Services\CrmService;
use App\Http\Services\SkuService; use App\Http\Services\SkuService;
use App\Http\Services\DataService;
use App\Model\SupplierChannelModel; use App\Model\SupplierChannelModel;
use App\Model\SupplierContractModel;
use App\Http\Services\CompanyService; use App\Http\Services\CompanyService;
use App\Http\Services\DataService;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
use App\Http\Services\DepartmentService; use App\Http\Services\DepartmentService;
...@@ -90,5 +91,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function () ...@@ -90,5 +91,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
}); });
Route::match(['get', 'post'], '/test', function () { Route::match(['get', 'post'], '/test', function () {
DataService::repairSupplierCpTime(); SupplierContractModel::where('id', 22)->update(['recall_time' => 0]);
}); });
...@@ -373,4 +373,10 @@ return [ ...@@ -373,4 +373,10 @@ return [
5 => '4年内', 5 => '4年内',
6 => '5年内', 6 => '5年内',
], ],
'SupplierPayTypeExtra' => [
'天' => '月结',
'当月' => '当月',
'当周' => '当周',
]
]; ];
...@@ -60,5 +60,8 @@ return [ ...@@ -60,5 +60,8 @@ return [
'sign_com_id' => '签约公司id', 'sign_com_id' => '签约公司id',
'sign_com_name' => '签约公司名称', 'sign_com_name' => '签约公司名称',
'sku_optional_batch_text' => 'SKU可选批次', 'sku_optional_batch_text' => 'SKU可选批次',
'pay_type_name' => '付款周期',
'pay_type_value' => '付款周期值',
'pay_type_extra' => '付款周期类型',
] ]
]; ];
...@@ -63,8 +63,6 @@ ...@@ -63,8 +63,6 @@
}); });
}); });
{{--index.setTabTitle('供应商详情 - {{$supplier['supplier_code'] or ''}}');--}}
function openLogView() { function openLogView() {
// 打开右侧面板 // 打开右侧面板
layer.open({ layer.open({
...@@ -80,7 +78,7 @@ ...@@ -80,7 +78,7 @@
@if(checkPerm('SupplierLog')) @if(checkPerm('SupplierLog'))
setTimeout(function () { setTimeout(function () {
openLogView(); openLogView();
}, 100); }, 1000);
@endif @endif
//判断是否要切换tab //判断是否要切换tab
......
<script>
layui.use(['table', 'form', 'element', 'layer', 'admin'], function () {
let admin = layui.admin;
let form = layui.form;
let element = layui.element;
$('#supplier_email').blur(function () {
let value = $(this).val();
value = value.trim();
if (value !== '') {
let reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
if (!reg.test(value)){
layer.msg('邮箱格式不对', {icon: 5});
}
}
});
form.on('submit(load)', function (data) {
// layer.confirm('确定要保存联系人吗?一旦保存,该供应商就会再次进入审核阶段', function (index) {
let supplierId = getQueryVariable('supplier_id');
let url = '/api/supplier_contact/SaveSupplierContact?supplier_id=' + supplierId;
let res = ajax(url, data.field);
if (!res) {
layer.msg('网络错误,请重试', {icon: 6});
} else {
if (res.err_code === 0) {
admin.putTempData("needFreshList", 1);
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
...@@ -2,6 +2,21 @@ ...@@ -2,6 +2,21 @@
layui.use(['table', 'form', 'element', 'layer', 'admin'], function () { layui.use(['table', 'form', 'element', 'layer', 'admin'], function () {
let admin = layui.admin; let admin = layui.admin;
let form = layui.form; let form = layui.form;
// 页面加载时初始化,确保当周期类型为空时,对应的下拉框不显示
$(document).ready(function() {
// 检查所有周期类型选择框,如果值为空,则隐藏对应的子选项
$('select[name="pay_type_extra"]').each(function() {
const payTypeExtra = $(this).val();
const parentDiv = $(this).parents('.pay_type_div');
// 如果周期类型为空,隐藏所有子选项
if (!payTypeExtra) {
parentDiv.find('.pay_type_1_days_div, .pay_type_1_monthly_div, .pay_type_1_weekly_div').hide();
}
});
});
//要根据付款类型的不同选项,切换不同的显示 //要根据付款类型的不同选项,切换不同的显示
form.on('select(pay_type)', function (data) { form.on('select(pay_type)', function (data) {
const payType = data.value; const payType = data.value;
...@@ -9,6 +24,7 @@ ...@@ -9,6 +24,7 @@
parentDiv.find('.pay_type_' + payType + '_div').show(); parentDiv.find('.pay_type_' + payType + '_div').show();
parentDiv.find('.pay_type_' + payType + '_div').find('.valueInput').first().attr('name', 'pay_type_value'); parentDiv.find('.pay_type_' + payType + '_div').find('.valueInput').first().attr('name', 'pay_type_value');
parentDiv.find('.pay_type_' + payType + '_div').find('.valueInput').eq(1).attr('name', 'pay_type_extra'); parentDiv.find('.pay_type_' + payType + '_div').find('.valueInput').eq(1).attr('name', 'pay_type_extra');
$('.pay_type_1_days_div, .pay_type_1_monthly_div, .pay_type_1_weekly_div').hide();
if (payType === '1') { if (payType === '1') {
parentDiv.find('.pay_type_2_div').hide(); parentDiv.find('.pay_type_2_div').hide();
parentDiv.find('.pay_type_2_div').find('.valueInput').attr('name', ''); parentDiv.find('.pay_type_2_div').find('.valueInput').attr('name', '');
...@@ -50,27 +66,50 @@ ...@@ -50,27 +66,50 @@
} }
}); });
$(document).on('click', '.delete_pay_type', function () { // 处理周期类型选择变化
let count = $('.pay_type_div').size(); form.on('select(pay_type_extra)', function (data) {
if (count <= 1) { const payTypeExtra = data.value;
layer.msg('至少要保留一个付款方式', {icon: 5}); // 隐藏所有子选项
return; $('.pay_type_1_days_div, .pay_type_1_monthly_div, .pay_type_1_weekly_div').hide();
// 清空所有值
$('#pay_type_value, #pay_type_value_monthly, #pay_type_value_weekly').val('');
// 根据选择的类型显示对应的选项
if (payTypeExtra === '天') {
$('.pay_type_1_days_div').show();
} else if (payTypeExtra === '当月') {
$('.pay_type_1_monthly_div').show();
} else if (payTypeExtra === '当周') {
$('.pay_type_1_weekly_div').show();
} else {
// 当周期类型为空时,确保所有子选项都隐藏
$('.pay_type_1_days_div, .pay_type_1_monthly_div, .pay_type_1_weekly_div').hide();
} }
var self = $(this);
layer.confirm('确定要删除付款方式吗?', function (index) {
self.parents('.pay_type_div').remove();
layer.closeAll();
});
});
$(document).on('click', '.add_pay_type', function () { // 更新隐藏字段值
$('#pay_type_div_list').append($('#pay_type_template').html()); $('[name="pay_type_extra"]').val(payTypeExtra);
//不知道为什么元素的name总会变来变去,所以手动固定死,确保提交的时候,顺序和名称都是对的
$("input[name^='pay_type_value[']").attr('name','pay_type_value')
$("input[name^='pay_type_extra[']").attr('name','pay_type_extra')
$("select[name^='pay_type[']").attr('name','pay_type')
form.render('select'); form.render('select');
}); });
// 处理days
form.on('select(pay_type_days)', function (data) {
const value = data.value;
$('[name="pay_type_value"]').val(value);
});
// 处理月结天数选择
form.on('select(pay_type_monthly)', function (data) {
const value = data.value;
$('[name="pay_type_value"]').val(value);
});
// 处理当周结星期选择
form.on('select(pay_type_weekly)', function (data) {
const value = data.value;
$('[name="pay_type_value"]').val(value);
});
}); });
</script> </script>
\ No newline at end of file
...@@ -257,7 +257,7 @@ ...@@ -257,7 +257,7 @@
<div class="layui-col-md3"> <div class="layui-col-md3">
付款周期 :{{$supplier['pay_type_name'] }} 付款周期 :{{$supplier['pay_type_name'] }}
@if($supplier['pay_type'] == 1) @if($supplier['pay_type'] == 1)
(月结{{$supplier['pay_type_value'].$supplier['pay_type_extra']}}) ({{'按'.$supplier['pay_type_extra'].' '.$supplier['pay_type_value']}})
@endif @endif
</div> </div>
</div> </div>
......
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