修改:权重值 - 商品编辑 - 权重值设置重构(由在营销中设置修改为在权重值中设置,并且管理权重值插件)

This commit is contained in:
wuhui_zzw 2023-10-12 09:53:51 +08:00
parent 8ef8d416a1
commit e871b80e32
17 changed files with 1304 additions and 90 deletions

View File

@ -0,0 +1 @@
## 权重值管理

View File

@ -0,0 +1,14 @@
<?php
return [
app\common\events\PluginWasEnabled::class => function ($plugins) {
\Artisan::call('migrate',['--path'=>'plugins/weight-value/migrations','--force'=>true]);
},
app\common\events\PluginWasDisabled::class => function ($plugin) {
},
app\common\events\PluginWasDeleted::class => function () {
\Artisan::call('migrate:rollback',['--path'=>'plugins/weight-value/migrations']);
}
];

View File

@ -0,0 +1,8 @@
"use strict";
$.extend($.locales['en'], {
'welfare': {
test: "JavaScript i18n test: English"
}
});

View File

@ -0,0 +1,5 @@
<?php
return [
'title'=>'this is test title'
];

View File

@ -0,0 +1,6 @@
$.extend($.locales['zh-CN'], {
'welfare': {
test: "JavaScript i18n test: 简体中文"
}
});

View File

@ -0,0 +1,5 @@
<?php
return [
'title'=>'测试标题'
];

View File

@ -0,0 +1,11 @@
{
"name": "weight-value",
"terminal": "wechat|min|wap",
"version": "1.0.1",
"title": "权重值管理",
"description": "权重值管理",
"author": "zzw",
"url": "",
"namespace": "Yunshop\\WeightValue",
"config": "config.tpl"
}

View File

@ -0,0 +1,137 @@
<?php
namespace Yunshop\WeightValue;
class PluginApplication extends \app\common\services\PluginApplication{
protected function setMenuConfig(){
\app\backend\modules\menu\Menu::current()->setPluginMenu('weight-value', [
'name' => '权重值管理',
'type' => 'marketing',
'url' => 'plugin.weight-value.admin.index.index',// url 可以填写http 也可以直接写路由
'url_params' => '',//如果是url填写的是路由则启用参数否则不启用
'permit' => 1,//如果不设置则不会做权限检测
'menu' => 1,//如果不设置则不显示菜单,子菜单也将不显示
'icon' => '',//菜单图标
'list_icon' => 'weight-value',
'parents' => [],
'top_show' => 0,
'left_first_show' => 0,
'left_second_show' => 1,
'child' => [
'plugin_weigh_value_index' => [
'name' => '权重值明细',
'permit' => 1,
'menu' => 1,
'icon' => '',
'url' => 'plugin.weight-value.admin.index.index',
'url_params' => '',
'item' => 'plugin_weigh_value_index',
'parents' => ['weight-value'],
'child' => [
// 权限补充
'plugin_weigh_value_index_index' => [
'name' => '权重值明细',
'url' => 'plugin.weight-value.admin.index.index',
'url_params' => '',
'permit' => 1,
'menu' => 0,
'icon' => '',
'item' => 'plugin_weigh_value_index_index',
'parents' => ['weight-value','plugin_weigh_value_index']
],
'plugin_weigh_value_index_record' => [
'name' => '变更记录',
'url' => 'plugin.weight-value.admin.index.record',
'url_params' => '',
'permit' => 1,
'menu' => 0,
'icon' => '',
'item' => 'plugin_weigh_value_index_record',
'parents' => ['weight-value','plugin_weigh_value_index']
],
]
],
'plugin_weigh_value_transfer' => [
'name' => '转账明细',
'permit' => 1,
'menu' => 1,
'icon' => '',
'url' => 'plugin.weight-value.admin.transfer.index',
'url_params' => '',
'parents' => ['weight-value'],
'child' => [
// 权限补充
'plugin_weigh_value_transfer_index' => [
'name' => '转账明细',
'url' => 'plugin.weight-value.admin.transfer.index',
'url_params' => '',
'permit' => 1,
'menu' => 0,
'icon' => '',
'item' => 'plugin_weigh_value_transfer_index',
'parents' => ['weight-value','plugin_weigh_value_transfer']
],
]
],
'plugin_weigh_value_set' => [
'name' => '基本设置',
'permit' => 1,
'menu' => 1,
'icon' => '',
'url' => 'plugin.weight-value.admin.index.set',
'url_params' => '',
'parents' => ['weight-value'],
'child' => [
// 权限补充
'plugin_weigh_value_index_set' => [
'name' => '基本设置',
'url' => 'plugin.weight-value.admin.index.set',
'url_params' => '',
'permit' => 1,
'menu' => 0,
'icon' => '',
'item' => 'plugin_weigh_value_index_set',
'parents' => ['weight-value', 'plugin_weigh_value_set'],
]
]
],
]
]);
}
public function getWidgetItems()
{
return [
'vue-goods.weight_value' => [
'title' => '权重值',
'class' => \Yunshop\WeightValue\admin\widget\WeightValueWidget::class,
],
];
}
protected function setConfig(){
\app\common\modules\shop\ShopConfig::current()->set(
'observer.goods.weight_value', [
'class' => 'Yunshop\WeightValue\models\GoodsWeightValue',
// 'function_validator'=>'relationValidator',
'function_save' => 'relationSave'
]
);
}
public function boot(){
$events = app('events');
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace Yunshop\WeightValue\admin;
use app\common\components\BaseController;
class IndexController extends BaseController{
public function index(){
return view('Yunshop\WeightValue::index.index')->render();
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace Yunshop\WeightValue\admin\widget;
use app\backend\modules\goods\widget\BaseGoodsWidget;
use Yunshop\WeightValue\models\GoodsWeightValue;
class WeightValueWidget extends BaseGoodsWidget{
public $group = 'marketing';
public $widget_key = 'weight_value';
public $code = 'weight_value';
public function pluginFileName(){
return 'goods';
}
public function getData(){
return GoodsWeightValue::uniacid()
->select(['is_open','user_type','gift_type','lv_type','quantity','ladder'])
->where('goods_id', $this->goods->id)
->first();
}
public function pagePath(){
return plugin_assets('weight-value','views/widget/');
// return $this->getPath('resources/views/goods/assets/js/components/');
}
}

View File

@ -0,0 +1,12 @@
<?php
namespace Yunshop\WeightValue\Api;
use app\common\components\ApiController;
class IndexController extends ApiController{
}

View File

@ -0,0 +1,50 @@
<?php
namespace Yunshop\WeightValue\models;
use app\common\models\BaseModel;
use app\frontend\models\Goods;
class GoodsWeightValue extends BaseModel{
public $table = 'yz_goods_weight_value';
public $timestamps = false;
public static function relationSave($goodsId, $data, $operate){
if (!$goodsId) return false;
if (!$data) return false;
$info = self::getModel($goodsId, $operate);
// 判断deleted
if ($operate == 'deleted') return $info->delete();
// 其他
$info->uniacid = \YunShop::app()->uniacid;
$info->goods_id = $goodsId;
$info->is_open = $data['is_open'] ?? 0;// 是否开启购买商品赠送权重值0=未开启1=开启
$info->user_type = $data['user_type'] ?? 0;// 受赠用户类型0=全部用户1=仅经销商
$info->gift_type = $data['gift_type'] ?? 0;// 赠送方式0=赠送固定值1=阶梯值赠送
$info->lv_type = $data['lv_type'] ?? 0;// 赠送方式0=二级1=三级
$info->quantity = $data['quantity'] ?? 0;// 固定值赠送数量
$info->ladder = json_encode($data['ladder'] ?? []);// 阶梯赠送信息
return $info->save();
}
public static function getModel($goodsId, $operate){
$model = false;
if ($operate != 'created') $model = static::where(['goods_id' => $goodsId])->first();
!$model && $model = new static;
return $model;
}
public function getGoodsSet($goodsId){
return self::where('goods_id', $goodsId);
}
//关联商品信息
public function belongsToGoods(){
return $this->belongsTo(Goods::class, 'goods_id', 'id');
}
}

View File

View File

@ -0,0 +1,355 @@
<script src="{!!resource_absolute('static/js/xlsx.full.min.js')!!}"></script>
@extends('layouts.base')
<style>
.user{
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
justify-content: flex-start;
overflow: hidden;
height: 80px;
}
.user .user-avatar{
height: 50px;
width: 50px;
margin-right: 5px;
border-radius: 50%;
overflow: hidden;
}
.user .user-avatar .avatar-image{
width: 100% !important;
height: 100% !important;
}
.user .user-info{
height: 50px;
text-align: left;
}
.user .user-info .user-nickname{
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.user .user-info .user-status{
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.margin-bottom-15{
margin-bottom: 15px;
}
.select-user-btn{
height: 34px!important;
}
select{
width: calc((100% - 20px) / 3) !important;
height: 34px;
border-color: #ccc!important;
color: #555 !important;
background-color: #fff!important;
}
select:not(:last-child){
margin-right: 10px!important;
}
.apply_image{
max-height: 80px;
max-width: 80px;
}
.image_a{
padding: 0!important;
height: 80px;
width: 80px;
display: inline-flex!important;
flex-direction: row;
justify-content: center;
align-items: flex-end;
flex-wrap: nowrap;
border: unset!important;
}
</style>
@section('content')
<div class="w1200 m0a" id="terminalMerchantsIndex">
{{--顶部搜索--}}
<div class="panel panel-info">
<div class="panel-body">
<form action="" method="post" class="form-horizontal" role="form" id="form1">
<div class="form-group">
<div class="col-sm-11 col-xs-12">
<div class="row row-fix tpl-category-container" >
<div class="col-xs-12 col-sm-8 col-lg-3">
<input class="form-control" name="search[team_dividend_agency_uid]" id="" type="text" value="{{ $search['team_dividend_agency_uid'] }}" placeholder="引荐人用户ID">
</div>
<div class="col-xs-12 col-sm-8 col-lg-3">
<input class="form-control" name="search[uid]" id="" type="text" value="{{ $search['uid'] }}" placeholder="终端商用户ID">
</div>
<div class="col-xs-12 col-sm-8 col-lg-3">
<input class="form-control" name="search[title]" id="" type="text" value="{{ $search['title'] }}" placeholder="店铺名称">
</div>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-11 col-xs-12">
<div class="row row-fix tpl-category-container" >
<div class="col-xs-12 col-sm-8 col-lg-3">
<input class="form-control" name="search[member_name]" id="" type="text" value="{{ $search['member_name'] }}" placeholder="引荐人昵称或者真实姓名">
</div>
<div class="col-xs-12 col-sm-8 col-lg-3">
<input class="form-control" name="search[contacts]" id="" type="text" value="{{ $search['contacts'] }}" placeholder="注册人姓名">
</div>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-11 col-xs-12">
<div class="row row-fix tpl-category-container" >
<input type="hidden" id="province_id" value="{{ $search['province_id']?:0 }}"/>
<input type="hidden" id="city_id" value="{{ $search['city_id']?:0 }}"/>
<input type="hidden" id="area_id" value="{{ $search['area_id']?:0 }}"/>
<div class="col-xs-12 col-sm-8 col-lg-6">
{!! app\common\helpers\AddressHelper::tplLinkedAddress(['search[province_id]','search[city_id]','search[area_id]'], []) !!}
</div>
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-12 col-sm-6 col-lg-6">
<input type="hidden" name="is_apply" value="{{$is_apply}}"/>
<button type="button" name="export" value="1" id="export" class="btn btn-default excel back ">导出 Excel</button>
@if (!$is_apply)
<button type="button" class="btn btn-primary editInfoBtn"><i class="fa fa-plus"></i> 添加</button>
@endif
<button class="btn btn-success" id="search"><i class="fa fa-search"></i> 搜索</button>
</div>
</div>
</form>
</div>
</div>
{{--信息列表--}}
<div class="panel panel-default">
<div class="panel-body" style="padding-top: 0;margin-bottom: 30px;overflow: auto;padding-right: 30px;">
<table class="table" style="min-width:1500px;overflow: auto;">
<thead>
<tr>
<th style="text-align:center;width: 80px;">ID</th>
<th style="text-align:left;">终端商信息</th>
<th style="text-align:left;">引荐人信息</th>
<th style="text-align:left;">注册人信息</th>
<th style="text-align:center;width: 100px;">营业执照</th>
<th style="text-align:center;width: 100px;">门头照片</th>
<th style="text-align:center;width: 100px;">内部照片</th>
<th style="text-align:center;width: 200px;">
@if($is_apply)
申请时间
@else
审核时间
@endif
</th>
<th style="text-align:center;width: 350px;">操作</th>
</tr>
</thead>
<tbody>
@foreach ($list as $item)
<tr style="height: 50px;">
<td style="text-align:center;">{{ $item['id'] }}</td>
<td style="text-align:left;">
<div class="user">
<div class="user-avatar">
<img class="avatar-image" src="{{$item['header_image']}}" />
</div>
<div class="user-info">
<div class="user-nickname">{{ $item['title'] }}</div>
<div class="user-nickname">
{{ $item['province_info']['areaname'] }}{{ $item['city_info']['areaname'] }}{{ $item['area_info']['areaname'] }}
</div>
<div class="user-status">
{{--状态0=待审核,1=使用中,2=驳回--}}
@if ($item['status'] == 0)
<label class="label label-default">待审核</label>
@elseif ($item['status'] == 1)
<label class="label label-success">使用中</label>
@elseif ($item['status'] == 2)
<label class="label label-danger">已驳回</label>
@endif
</div>
</div>
</div>
</td>
<td style="text-align:left;" >
<div class="user">
<div class="user-avatar">
<img class="avatar-image" src="{{$item['team_dividend_member']['avatar_image']}}" />
</div>
<div class="user-info">
<div class="user-nickname">昵称:{{ $item['team_dividend_member']['nickname'] }}</div>
<div class="user-status">ID{{ $item['team_dividend_member']['uid'] }}</div>
</div>
</div>
</td>
<td style="text-align:left;">
<div class="contacts">
注册人:{{ $item['contacts'] }}<br />
联系电话:{{ $item['contacts_phone'] }}<br />
</div>
</td>
<td style="text-align:center;">
<a target="_blank" href="{{tomedia($item['business_license_image'])}}" class="image_a">
<img class="apply_image" src='{{tomedia($item['business_license_image'])}}' /><br/>
</a>
</td>
<td style="text-align:center;">
<a target="_blank" href="{{tomedia($item['header_image'])}}" class="image_a">
<img class="apply_image" src='{{tomedia($item['header_image'])}}' /><br/>
</a>
</td>
<td style="text-align:center;">
<a target="_blank" href="{{tomedia($item['internal_image'])}}" class="image_a">
<img class="apply_image" src='{{tomedia($item['internal_image'])}}' /><br/>
</a>
</td>
<td style="text-align:center;">
@if($is_apply)
{{ $item['created_at'] }}
@else
{{ $item['to_examine_time'] }}
@endif
</td>
<td style="text-align:center;">
@if ($is_apply)
{{--审核内容--}}
@if ($item['status'] == 0)
<button onclick="pass({{$item['id']}})" type="button" class="btn btn-success btn-sm">审核通过</button>
<button type="button" onclick="popupRejectReason({{$item['id']}})" class="btn btn-danger btn-sm">驳回申请</button>
@endif
<a href="{{yzWebUrl('plugin.weight-value.admin.index.editInfo', ['id' => $item['id'], 'is_see' => TRUE])}}">
<button type="button" class="btn btn-primary btn-sm">详情</button>
</a>
@else
{{--使用中内容--}}
<a href="{{yzWebUrl('plugin.weight-value.admin.index.editInfo', ['id' => $item['id']])}}">
<button type="button" class="btn btn-success btn-sm">编辑</button>
</a>
<button onclick="del({{$item['id']}})" type="button" class="btn btn-danger btn-sm">删除</button>
<button onclick="seeSalesInfo({{$item['id']}})" type="button" class="btn btn-info btn-sm">销售统计</button>
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
{!! $pager !!}
</div>
</div>
{{--驳回弹框--}}
<div id="reject-popup" class="modal fade">
<div class="modal-dialog" style='width: 920px;'>
<div class="modal-content">
<div class="modal-header">
<button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
<h3>驳回申请</h3>
</div>
<div class="modal-body">
<div class="row">
<div class="input-group">
<textarea name="reject_reason" maxlength="200" cols="120" rows="15" placeholder="请输入驳回原因(200字以内)"></textarea>
</div>
</div>
<div id="module-menus-goods" style="padding-top:5px;"></div>
</div>
<div class="modal-footer">
<input type="button" value="确认" onclick="submitReject()" class="btn btn-primary"/>
<a href="#" class="btn btn-default" data-dismiss="modal" aria-hidden="true">关闭</a>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="{{static_url('js/area/cascade_street.js')}}"></script>
<script type="text/javascript">
var apply_id = 0;// 终端商信息id
window.history.replaceState(null, null, window.location.href);
// 地区初始化
var province_id = $('#province_id').val();
var city_id = $('#city_id').val();
var area_id = $('#area_id').val();
cascdeInit(province_id, city_id, area_id);
$(function () {
// 编辑终端商
$("#terminalMerchantsIndex").on('click','.editInfoBtn',function () {
let id = $(this).data('id') || 0;
window.location.href = "{!! yzWebUrl('plugin.weight-value.admin.index.editInfo') !!}" + '&id=' + id;
});
// 点击导出
$('#export').click(function(){
@if (!$is_apply)
$('#form1').get(0).action = "{!! yzWebUrl('plugin.weight-value.admin.index.export') !!}";
$('#form1').submit();
$('#form1').get(0).action= "{!! yzWebUrl('plugin.weight-value.admin.index.index') !!}";
@else
$('#form1').get(0).action = "{!! yzWebUrl('plugin.weight-value.admin.index.apply_export') !!}";
$('#form1').submit();
$('#form1').get(0).action= "{!! yzWebUrl('plugin.weight-value.admin.index.apply') !!}";
@endif
});
});
// 填写驳回原因
function popupRejectReason(id){
apply_id = id;
$('#reject-popup').modal();//填写驳回理由
}
// 提交驳回
function submitReject(){
var reject_reason = $("textarea[name='reject_reason']").val();
var link = "{{yzWebUrl('plugin.weight-value.admin.index.reject')}}" + '&id=' + apply_id + '&reject_reason=' + reject_reason;
// 判断:是否存在驳回原因
if(reject_reason.length <= 0){
alert('请输入驳回原因');
return false;
}
window.location.href = link;
}
// 审核通过
var is_click_button = false;
function pass(id){
// 防止重复点击
loadShow();
if(is_click_button) return false;
is_click_button = true;
// 通过审核
window.location.href = "{{yzWebUrl('plugin.weight-value.admin.index.pass')}}" + '&id=' + id;
}
// 删除终端商
function del(id){
let link = "{{yzWebUrl('plugin.weight-value.admin.index.del')}}" + '&id=' + id;
// 通过审核
let popup = util.confirm('确认删除当前终端商信息吗?',{
confirm:function () {
// 加载动画
loadShow();
// 关闭弹框
popup.modal('hide');
window.location.href = link;
}
});
}
// 查看销售信息统计
function seeSalesInfo(id){
let link = "{{yzWebUrl('plugin.weight-value.admin.sales.index')}}" + `&id=${id}`;
let popup = util.ajaxshow(link,'查看销售统计',{
width: $(window).width() * 0.8 > 1200 ? $(window).width() * 0.8 : 1200,
height: $(window).height() * 0.8 > 1200 ? $(window).height() * 0.8 : 1200,
});
}
</script>
@endsection

View File

@ -0,0 +1,520 @@
@extends('layouts.base')
@section('content')
<style>
.commission{
width: 1100px;
}
.commission .commission-box{
width: 100%;
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
justify-content: flex-start;
border-bottom: 1px solid #CCCCCC;
padding: 20px 0;
}
.commission .commission-box:first-child{
padding: 0!important;
}
.commission .commission-box:last-child{
border-bottom: none!important;
}
.commission .commission-box .level-title{
width: 220px;
text-align: center;
font-size: 15px;
border-right: 1px solid #ccc;
height: 130px;
line-height: 130px;
}
.commission .commission-box:first-child .level-title{
font-weight: bold;
height: 35px;
line-height: 35px;
border-right: none!important;
}
.commission .commission-box .commission-line-content{
width: 880px;
}
.commission .commission-box .commission-line{
width: 880px;
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
justify-content: flex-start;
margin-bottom: 15px;
}
.commission .commission-box .commission-line:last-child{
margin-bottom: 0!important;
}
.commission .commission-box:first-child .commission-line{
font-weight: bold;
height: 35px;
line-height: 35px;
margin-bottom: 0px!important;
}
.commission .commission-box .commission-line .line-cells{
width: 220px;
text-align: center;
}
.hide{
display: none;
}
.el-pagination{
margin-top: 20px;
text-align: right!important;
}
</style>
<div class="w1200 m0a">
<div class="rightlist" id="app">
{{--设置表单--}}
<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
<div class='panel panel-default form-horizontal form'>
{{--设置内容--}}
<el-tabs value="base_set">
<el-tab-pane label="基础设置" name="base_set">
<div class='panel-body'>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">结算方式</label>
<div class="col-sm-4 col-xs-6">
<label class="radio-inline">
<input type="radio" name="weigh_value[settlement_method]" value="0" @if ($set['settlement_method'] != 1) checked="checked" @endif /> 手动结算
</label>
<label class="radio-inline">
<input type="radio" name="weigh_value[settlement_method]" value="1" @if ($set['settlement_method'] == 1) checked="checked" @endif /> 自动结算
</label>
</div>
</div>
</div>
</el-tab-pane>
<el-tab-pane label="佣金设置" name="commission_set">
<div class='panel-body'>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">结算类型</label>
<div class="col-sm-4 col-xs-6">
<label class="radio-inline">
<input type="radio"
name="weigh_value[commission][is_independent_settlement]"
value="0" @if ($set['commission']['is_independent_settlement'] != 1) checked="checked" @endif
/> 一次性全部结算
</label>
<label class="radio-inline">
<input type="radio"
name="weigh_value[commission][is_independent_settlement]"
value="1" @if ($set['commission']['is_independent_settlement'] == 1) checked="checked" @endif
/> 分期结算
</label>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">平级奖(百分比)</label>
<div class="col-sm-9 col-xs-12">
<input type='number'
step="0.01"
min="0.01"
max="100"
name='weigh_value[commission][flat_ratio]'
class="form-control"
value="{{$set['commission']['flat_ratio']}}"
/>
<span class='help-block'>值必须为0.01-100;为空则无平级奖。</span>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">结算延迟天数</label>
<div class="col-sm-9 col-xs-12">
<input type='number'
name='weigh_value[commission][independent_delay_day]'
class="form-control"
value="{{$set['commission']['independent_delay_day']}}"
/>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">经销商佣金设置</label>
<div class="col-sm-9 col-xs-10">
<div class="commission">
<div class="commission-box">
<div class="level-title">经销商等级</div>
<div class="commission-line">
<div class="line-cells">商品规格</div>
<div class="line-cells">首次返佣</div>
<div class="line-cells">每期返佣</div>
<div class="line-cells">分期数量</div>
</div>
</div>
@foreach($level as $levelItem => $levelValue)
<div class="commission-box">
{{--经销商等级--}}
<div class="level-title">{{$levelValue['level_name']}}</div>
{{--规格及佣金设置--}}
<div class="commission-line-content">
@foreach($goods_label as $goodsLabelItem => $goodsLabelValue)
<div class="commission-line">
<div class="line-cells">{{$goodsLabelValue}}</div>
<div class="line-cells">
<input type="number"
step="0.01"
class="form-control"
placeholder="请输入首次返佣金额"
value="{{$set['commission'][$levelValue['id']][$goodsLabelValue]['independent_first_money']}}"
name="weigh_value[commission][{{$levelValue['id']}}][{{$goodsLabelValue}}][independent_first_money]"
/>
</div>
<div class="line-cells">
<input type="number"
step="0.01"
class="form-control"
placeholder="请输入每期返佣金额"
value="{{$set['commission'][$levelValue['id']][$goodsLabelValue]['independent_cycle_money']}}"
name="weigh_value[commission][{{$levelValue['id']}}][{{$goodsLabelValue}}][independent_cycle_money]"
/>
</div>
<div class="line-cells">
<input type="number"
class="form-control"
placeholder="请输入分期数量"
value="{{$set['commission'][$levelValue['id']][$goodsLabelValue]['independent_cycle_number']}}"
name="weigh_value[commission][{{$levelValue['id']}}][{{$goodsLabelValue}}][independent_cycle_number]"
/>
</div>
</div>
@endforeach
</div>
</div>
@endforeach
</div>
</div>
</div>
</div>
</el-tab-pane>
<el-tab-pane label="区域提成结算" name="area_set">
{{--计算金额--}}
<div class="form-group">
<label class="col-xs-12 col-md-2 control-label">计算金额</label>
<div class="col-sm-9 col-xs-12">
<div class="input-group">
<div class="input-group">
<div class="input-group-addon">G10</div>
<input type="number" step="0.01" name='weigh_value[money][g10]' class="form-control" value="{{$set['money']['g10']}}"/>
<div class="input-group-addon"></div>
<div class="input-group-addon">G15</div>
<input type="number" step="0.01" name='weigh_value[money][g15]' class="form-control" value="{{$set['money']['g15']}}"/>
<div class="input-group-addon"></div>
<div class="input-group-addon">G20</div>
<input type="number" step="0.01" name='weigh_value[money][g20]' class="form-control" value="{{$set['money']['g20']}}"/>
<div class="input-group-addon"></div>
</div>
</div>
</div>
</div>
{{--默认比例--}}
<div class="form-group">
<label class="col-xs-12 col-md-2 control-label">默认比例</label>
<div class="col-sm-9 col-xs-12">
<div class="input-group">
<div class="input-group">
<div class="input-group-addon"></div>
<input type="number" step="0.01" name='weigh_value[area][default_province]' class="form-control" value="{{$set['area']['default_province']}}"/>
<div class="input-group-addon">%</div>
<div class="input-group-addon"></div>
<input type="number" step="0.01" name='weigh_value[area][default_city]' class="form-control" value="{{$set['area']['default_city']}}"/>
<div class="input-group-addon">%</div>
<div class="input-group-addon"></div>
<input type="number" step="0.01" name='weigh_value[area][default_district]' class="form-control" value="{{$set['area']['default_district']}}"/>
<div class="input-group-addon">%</div>
</div>
</div>
</div>
</div>
{{--独立比例--}}
<div class="form-group">
<label class="col-xs-12 col-md-2 control-label">独立规则</label>
<div class="col-sm-9 col-xs-12">
{{--添加按钮--}}
<div class="input-group">
<el-button type="primary" icon="el-icon-plus" @click="areaSelectShow = true">添加地区</el-button>
</div>
{{--独立规则列表--}}
<el-table :data="config_list" style="width:100%">
<el-table-column prop="id" align="center" label="ID" width="50"></el-table-column>
<el-table-column prop="address_text" align="center" label="地区"></el-table-column>
<el-table-column prop="ratio" align="center" label="提成比例"></el-table-column>
<el-table-column prop="created_at" align="center" label="添加时间"></el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button size="mini" @click="editInfo(scope.row)">编辑</el-button>
<el-button size="mini" type="danger" @click="delSelfConfigInfo(scope.row.id)">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
background
layout="prev, pager, next"
:page-count="config_total_page"
:current-page="config_page"
@current-change="paging"
></el-pagination>
</div>
</div>
</el-tab-pane>
</el-tabs>
{{--提交按钮--}}
<div class="form-group"></div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
<div class="col-sm-9 col-xs-12">
<input type="submit" name="submit" value="保存" class="btn btn-primary col-lg-1"/>
</div>
</div>
</div>
</form>
{{--地区选择器--}}
<el-dialog title="添加地区" :visible.sync="areaSelectShow" :close-on-click-modal="false" @close="closeAddDialog">
<el-form :model="areaInfo">
<el-form-item v-if="Object.keys(province_list).length > 0" label="" :label-width="areaSelectShowLabelWidth">
<el-select v-model="areaInfo.province_id" @change="getArea($event,'city')" placeholder="请选择省">
<el-option v-for="(item,index) in province_list" :key="index" :label="item.areaname" :value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item v-if="Object.keys(city_list).length > 0" label="" :label-width="areaSelectShowLabelWidth">
<el-select v-model="areaInfo.city_id" @change="getArea($event,'district')" placeholder="请选择市">
<el-option v-for="(item,index) in city_list" :key="index" :label="item.areaname" :value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item v-if="Object.keys(district_list).length > 0" label="" :label-width="areaSelectShowLabelWidth">
<el-select v-model="areaInfo.district_id" placeholder="请选择区">
<el-option v-for="(item,index) in district_list" :key="index" :label="item.areaname" :value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="提成比例" :label-width="areaSelectShowLabelWidth">
<el-input v-model="areaInfo.ratio" max="100" min="0"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="areaSelectShow = false"> </el-button>
<el-button type="primary" @click="confirmAdd"> </el-button>
</div>
</el-dialog>
</div>
</div>
<script>
new Vue({
el: '#app',
delimiters: ['[[', ']]'],
data(){
return {
config_list: [],
config_page: 1,
config_total_page: 1,
areaSelectShow: false,
areaSelectShowLabelWidth: '120px',
areaInfo: {
id: 0,
province_id: '',// 省id
city_id: '',// 市id
district_id: '',// 区id
ratio: 0,
},
province_list: [],// 省
city_list: [],// 市
district_list: [],// 区
}
},
mounted () {
this.getArea();
this.getAreaSetList();
},
methods: {
// 获取信息列表
getAreaSetList(){
const loading = this.selfLoading();
let _this = this;
$.ajax({
url: "{!! yzWebUrl('plugin.weight-value.admin.AreaSet.getList') !!}",
data:{
page: _this.config_page,
},
success: function (result) {
if(result.result){
let data = result.data;
_this.config_list = data.data;
_this.config_total_page = data.last_page;
}
loading.close();
},
error:function (error) {
loading.close();
console.log("失败:",error);
}
})
},
// 数据分页
paging(val){
this.config_page = val;
this.getAreaSetList();
},
// 获取地址
getArea(parentid = '',type = 'province',is_init = true){
const loading = this.selfLoading();
let _this = this;
$.ajax({
url: "{!! yzWebUrl('address.get-address') !!}",
data:{
type: type,
parentid: parentid
},
cache: false,
success: function (result) {
if(type === 'province') {
_this.province_list = JSON.parse(result);
if(is_init){
_this.city_list = _this.district_list = [];
_this.areaInfo = {
province_id: '',
city_id: '',
district_id: '',
};
}
}
else if(type === 'city') {
_this.city_list = JSON.parse(result);
if(is_init){
_this.district_list = [];
_this.areaInfo.city_id = '';
_this.areaInfo.district_id = '';
}
}
else if(type === 'district') {
_this.district_list = JSON.parse(result);
if(is_init) _this.areaInfo.district_id = '';
}
loading.close();
},
error:function (error) {
loading.close();
console.log("地区获取失败:",error);
}
})
},
// 提交 添加信息|修改信息
confirmAdd(){
let _this = this;
let areaInfo = _this.areaInfo;
// 信息验证
let defaultRule = [
{name: 'province_id', checkType: 'required', errorMsg: '请选择省'},
{name: 'ratio', checkType: 'required', errorMsg: '请输入独立提成比例'},
{name: 'ratio', checkType: 'between', errorMsg: '独立提成比例必须在1 ~ 100之间',checkRule: "0,100"},
];
let result = util.validate(areaInfo,defaultRule);
if(result !== true){
_this.$alert(result);
return false;
}
// 信息提交
areaInfo.province_name = areaInfo.province_id > 0 ? _this.getAreaDesc(_this.province_list,areaInfo.province_id,'areaname') : '';
areaInfo.city_name = areaInfo.city_id > 0 ? _this.getAreaDesc(_this.city_list,areaInfo.city_id,'areaname') : '';
areaInfo.district_name = areaInfo.district_id > 0 ? _this.getAreaDesc(_this.district_list,areaInfo.district_id,'areaname') : '';
const loading = this.selfLoading();
$.ajax({
url: "{!! yzWebUrl('plugin.weight-value.admin.AreaSet.editInfo') !!}",
data: areaInfo,
cache: false,
success: function (result) {
loading.close();
_this.$alert(result.msg);
// 操作成功 关闭并且刷新
if(parseInt(result.result) === 1) {
_this.getAreaSetList();
_this.areaSelectShow = false;
}
},
error:function (error) {
loading.close();
console.log("失败:",error);
}
})
},
// 循环获取对应地区的信息
getAreaDesc(list,id,key = ''){
let info = {};
Object.values(list).some(function(res){
if(parseInt(res.id) === parseInt(id)){
info = res;
return true;
}
});
return key ? info[key] : info;
},
// 关闭添加弹框后 初始化部分内容
closeAddDialog(){
// 初始化内容
let _this = this;
_this.city_list = _this.district_list = [];
_this.areaInfo = {
province_id: '',
city_id: '',
district_id: '',
};
},
// 点击删除当前独立规则
delSelfConfigInfo(id){
let _this = this;
_this.$confirm('是否确认删除当前地区独立规则?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
// 请求删除
const loading = this.selfLoading();
$.ajax({
url: "{!! yzWebUrl('plugin.weight-value.admin.AreaSet.delInfo') !!}",
data: {
id: id
},
success: function (result) {
loading.close();
_this.$alert(result.msg).then(() => {
_this.getAreaSetList();
});
},
error:function (error) {
loading.close();
console.log("失败:",error);
}
})
}).catch(()=>{});
},
// 公共加载动画
selfLoading(){
return this.$loading({
lock: true,
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
});
},
// 编辑信息
editInfo(info){
let _this = this;
_this.areaInfo = Object.assign({},info);
_this.getArea(info.province_id,'city',!info.city_id > 0);
_this.getArea(info.city_id,'district',!info.district_id > 0);
_this.areaSelectShow = true;
},
},
})
</script>
@endsection

View File

@ -0,0 +1,124 @@
define({
name:"weight_value",
template:`
<div class="weight_value">
<el-form>
<div class="vue-main-title">
<div class="vue-main-title-left"></div>
<div class="vue-main-title-content">权重值设置</div>
</div>
<div style="margin:0 auto;width:80%;">
<el-form-item label="是否开启" label-width="155px">
<el-radio v-model="json.is_open" :label="0">关闭</el-radio>
<el-radio v-model="json.is_open" :label="1">开启</el-radio>
</el-form-item>
<template v-if="json.is_open == 1">
<el-form-item label="受赠用户类型" label-width="155px">
<el-radio v-model="json.user_type" :label="0">全部用户</el-radio>
<el-radio v-model="json.user_type" :label="1">仅经销商</el-radio>
<div class="form-item_tips">全部用户普通所有用户购买后都会赠送权重值</div>
<div class="form-item_tips">仅经销商存在经销商身份且未加入黑名单的用户会赠送权重值</div>
</el-form-item>
<el-form-item label="赠送方式" label-width="155px">
<el-radio v-model="json.gift_type" :label="0">普通赠送</el-radio>
<el-radio v-model="json.gift_type" :label="1">阶梯赠送</el-radio>
<div class="form-item_tips">普通赠送赠送指定的权重值</div>
<div class="form-item_tips">阶梯赠送根据用户成为经销商的时间顺序排序获取对应的权重值超过最大名次则不赠送权重值</div>
</el-form-item>
<el-form-item label="赠送级别" label-width="155px">
<el-radio v-model="json.lv_type" :label="0">二级</el-radio>
<el-radio v-model="json.lv_type" :label="1">三级</el-radio>
<div class="form-item_tips">二级赠送购买人购买人上级</div>
<div class="form-item_tips">三级赠送购买人购买人上级购买人上级的上级</div>
</el-form-item>
<el-form-item label="赠送数量" v-if="json.gift_type != 1" label-width="155px" prop="quantity">
<el-input v-model.trim="json.quantity" maxlength="300" type="number">
<template slot="append">权重值</template>
</el-input>
<div class="form-item_tips">如果设置为空或者0则不赠送权重值</div>
</el-form-item>
<el-form-item label="阶梯赠送" v-else label-width="155px">
<div class="ladder-content">
<div class="ladder-row" v-for="(item,index) in json.ladder" :key="index">
<el-form-item>
<el-input class="ladder-input" v-model="json.ladder[index]['where']" placeholder="名次" type="number">
<template slot="prepend">小于等于</template>
<template slot="append"></template>
</el-input>
<el-input class="ladder-input" v-model="json.ladder[index]['num']" placeholder="权重值" type="number">
<template slot="prepend">赠送</template>
<template slot="append">权重值</template>
</el-input>
<el-button type="danger" size="medium" @click="delLadder(index)">删除</el-button>
</el-form-item>
</div>
<el-button type="primary" @click="addLadder">增加阶梯</el-button>
<div class="form-item_tips">例如设置小于等于10赠送100权重值小于等于32赠送120权重值则第1~10位经销商赠送100权重值第11~32位经销商赠送120权重值第33位及之后所有经销商均不赠送权重值</div>
</div>
</el-form-item>
</template>
</div>
</el-form>
</div>
`,
style:`
.ladder-content{
min-width: 550px!important;
}
.ladder-content .ladder-row{
margin-bottom: 5px!important;
}
.ladder-content .ladder-row .ladder-input{
width: 230px!important;
}
`,
props: {
form: {
default() {
return {}
}
}
},
data() {
return {
json: {
is_open: 0,// 是否开启购买商品赠送权重值0=未开启1=开启
user_type: 0,// 受赠用户类型0=全部用户1=仅经销商
gift_type: 0,// 赠送方式0=赠送固定值1=阶梯值赠送
lv_type: 0,// 赠送方式0=二级1=三级
quantity: 0,// 赠送数量
ladder: {},// 阶梯赠送信息
}
}
},
watch: {},
mounted() {
console.log(this.form);
if (this.form) {
let weight_value = this.form || {};
this.json.is_open = weight_value.is_open ? weight_value.is_open : 0;
this.json.user_type = weight_value.user_type ? weight_value.user_type : 0;
this.json.gift_type = weight_value.gift_type ? weight_value.gift_type : 0;
this.json.lv_type = weight_value.lv_type ? weight_value.lv_type : 0;
this.json.quantity = weight_value.quantity ? weight_value.quantity : 0;
this.json.ladder = weight_value.ladder ? JSON.parse(weight_value.ladder) : {};
}
console.log(this.json);
},
methods:{
addLadder(){
this.json.ladder = Object.values(this.json.ladder).concat({where: '', num: ''});
},
delLadder(index){
let ladder = Object.assign({},this.json.ladder);
delete ladder[index];
this.json.ladder = Object.values(ladder);
},
validate(){
return this.json;
}
}
})

View File

@ -48,50 +48,6 @@ define({
<el-button @click="openAreaDialog">添加不参加包邮的地区</el-button>
</el-form-item>
</div>
<!--权重值设置-->
<div class="vue-main-title">
<div class="vue-main-title-left"></div>
<div class="vue-main-title-content">权重值设置</div>
</div>
<div style="margin:0 auto;width:80%;">
<el-form-item label="受赠用户类型" label-width="155px">
<el-radio v-model="json.weight_value_user" :label="0" :disabled="json.weight_value_type == 1">全部用户</el-radio>
<el-radio v-model="json.weight_value_user" :label="1">仅经销商</el-radio>
<div class="form-item_tips">全部用户普通所有用户购买后都会赠送权重值</div>
<div class="form-item_tips">仅经销商只有经销商用户会赠送权重值阶梯赠送必须为仅经销商</div>
</el-form-item>
<el-form-item label="赠送方式" label-width="155px">
<el-radio v-model="json.weight_value_type" :label="0">普通赠送</el-radio>
<el-radio v-model="json.weight_value_type" :label="1">阶梯赠送</el-radio>
<div class="form-item_tips">普通赠送购买人购买人上级购买人上级的上级赠送指定的权重值</div>
<div class="form-item_tips">阶梯赠送购买人购买人上级分别获取对应顺序的权重值顺序为用户成为经销商的先后顺序如果经销商身份为黑名单则不赠送权重值</div>
</el-form-item>
<el-form-item label="赠送数量" v-if="json.weight_value_type != 1" label-width="155px" prop="weight_value_num">
<el-input v-model.trim="json.weight_value_num" maxlength="300">
<template slot="append">权重值</template>
</el-input>
<div class="form-item_tips">如果设置为空或者0则不赠送权重值</div>
</el-form-item>
<el-form-item label="阶梯赠送" v-else label-width="155px">
<div class="ladder-content">
<div class="ladder-row" v-for="(item,index) in json.weight_value_ladder" :key="index">
<el-form-item>
<el-input v-model="json.weight_value_ladder[index]['where']" placeholder="名次" class="ladder-input" maxlength="300">
<template slot="prepend">小于等于</template>
<template slot="append"></template>
</el-input>
<el-input class="ladder-input" v-model="json.weight_value_ladder[index]['num']" placeholder="权重值" maxlength="300">
<template slot="prepend">赠送</template>
<template slot="append">权重值</template>
</el-input>
<el-button type="danger" size="medium" @click="delLadder(index)">删除</el-button>
</el-form-item>
</div>
<el-button type="primary" @click="addLadder">增加阶梯</el-button>
<div class="form-item_tips">例如设置小于等于10赠送100权重值小于等于32赠送120权重值则第1~10位经销商赠送100权重值第11~32位经销商赠送120权重值第33位及之后所有经销商均不赠送权重值</div>
</div>
</el-form-item>
</div>
<!--余额设置-->
<div class="vue-main-title">
@ -461,18 +417,6 @@ define({
height: 80%;
overflow-y: scroll;
}
.ladder-content{
min-width: 550px!important;
}
.ladder-content .ladder-row{
margin-bottom: 5px!important;;
}
.ladder-content .ladder-row .ladder-input{
width: 200px!important;;
}
`,
props: {
form: {
@ -549,7 +493,6 @@ define({
all_point_deduct: { validator: floatNum },
max_balance_deduct: { validator: floatNum },
min_balance_deduct: { validator: floatNum },
weight_value_num: { validator: floatNum },
},
goodsDialog: false,
areaDialog: false,
@ -596,25 +539,10 @@ define({
is_push: 0,
push_goods_ids: [],
is_store:0,
// 权重值设置
weight_value_user: 1,
weight_value_type: 0,
weight_value_num: 0,
weight_value_ladder: {},
},
};
},
watch: {
json: {
deep: true,//深度监听
handler: function () {
// 开启阶梯价的情况下 受赠用户类型必须为仅经销商
if(this.json.weight_value_type == 1) {
this.json.weight_value_user = 1;
}
}
}
},
watch: { },
mounted() {
if (this.form && this.form.sale) {
let sale = this.form.sale;
@ -642,11 +570,6 @@ define({
this.json.min_balance_deduct = sale.min_balance_deduct ? sale.min_balance_deduct : '';
this.json.is_push = sale.is_push ? sale.is_push : 0;
this.json.push_goods_ids = sale.push_goods_ids ? sale.push_goods_ids : [];
// 权重值
this.json.weight_value_user = sale.weight_value_user ? sale.weight_value_user : 1;
this.json.weight_value_type = sale.weight_value_type ? sale.weight_value_type : 0;
this.json.weight_value_num = sale.weight_value_num ? sale.weight_value_num : 0;
this.json.weight_value_ladder = sale.weight_value_ladder ? JSON.parse(sale.weight_value_ladder) : {};
}
},
methods: {
@ -783,18 +706,6 @@ define({
}
});
},
// 权重值相关处理
addLadder(){
this.json.weight_value_ladder = Object.values(this.json.weight_value_ladder).concat({where: '', num: ''});
},
delLadder(index){
let weightValueLadder = Object.assign({},this.json.weight_value_ladder);
delete weightValueLadder[index];
this.json.weight_value_ladder = Object.values(weightValueLadder);
}