修改:权重值 - 经销商赠送权重值设置方法重构

This commit is contained in:
wuhui_zzw 2023-10-16 17:11:21 +08:00
parent aafa0e92ac
commit 0cd0069f0f
4 changed files with 208 additions and 33 deletions

View File

@ -10,6 +10,7 @@ use Illuminate\Support\Str;
use Yunshop\TeamDividend\admin\models\LevelRedPack;
use Yunshop\TeamDividend\models\TeamDividendLevelModel;
use Yunshop\TeamDividend\models\TeamDividendLevelUpgrade;
use Yunshop\WeightValue\models\GoodsWeightValue;
class TeamDividendLevelSetController extends BaseController
{
@ -80,6 +81,13 @@ class TeamDividendLevelSetController extends BaseController
$upgrade_modle->save();
// 权重值处理
$wv = request()->wv ?? [];
$wv['is_open'] = 1;// 经销商设置 默认开启
if($wv) GoodsWeightValue::relationSave($team_dividend_level_model->id, $wv, 'created',true);
return $this->message('经销商等级操作成功', yzWebUrl('plugin.team-dividend.admin.team-dividend-level-set'), 'success');
}
}
@ -236,6 +244,11 @@ class TeamDividendLevelSetController extends BaseController
$upgrade_modle->save();
}
// 权重值处理
$wv = request()->wv ?? [];
$wv['is_open'] = 1;// 经销商设置 默认开启
if($wv) GoodsWeightValue::relationSave($id, $wv, 'updated',true);
return $this->message('经销商等级操作成功', yzWebUrl('plugin.team-dividend.admin.team-dividend-level-set'), 'success');
}
}
@ -245,6 +258,12 @@ class TeamDividendLevelSetController extends BaseController
$goldSet = array_pluck(\Setting::getAllByGroup('Love')->toArray(), 'value', 'key');
$goldTitle = $goldSet['name'] ? $goldSet['name'] : '爱心值';
$settingData = \Setting::get('plugin.team_dividend');
// 权重值信息
$wv = (new GoodsWeightValue())->getGoodsSet($id,true)->first();
$wv = $wv ? $wv->toArray() : [];
return view('Yunshop\TeamDividend::admin.level-set-add', [
'dividend' => $dividend_model,
'code_num' => $dividend_model->code_num,
@ -258,6 +277,7 @@ class TeamDividendLevelSetController extends BaseController
'goldTitle' => $goldTitle,
'settingData' => $settingData,
'goods' => $goods,
'wv' => $wv
])->render();
}

View File

@ -5,14 +5,62 @@
.radio-inline + .radio-inline {
margin: 0;
}
.row {
width: 100%;
}
#goodsthumb {
margin-left: 20px;
}
.weight-value-content{}
.weight-value-content .title{
display: flex;
height: 30px;
line-height: 32px;
font-size: 16px;
color: #333;
font-weight: 600;
}
.weight-value-content .title-left{
width: 4px;
height: 18px;
margin-top: 6px;
background: #29ba9c;
display: inline-block;
margin-right: 10px;
}
.weight-value-content .title-content{
font-size: 14px;
flex: 1;
}
.weight-value-content .weight-value-top-content{
height: 34px;
display: -webkit-inline-box;
}
.weight-value-content .weight-value-top-content .weight-value-lable{
width: 70px!important;
height: 34px;
line-height: 20px;
}
.weight-value-content .weight-value-top-content .weight-value-radio{
padding-right: 55px;
height: 34px;
}
.weight-value-content .weight-value-top-content .radio-inline{
padding: 0px!important;
width: 50%;
margin-left: 10px;
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
justify-content: flex-start;
}
.weight-value-content .weight-value-top-content .radio-inline:nth-child(2){
margin-left: 20px!important;
}
.del-ladder-btn{
cursor: pointer;
}
</style>
<div class="w1200 ">
<div class=" rightlist ">
@ -34,7 +82,6 @@
<span class="help-block">等级权重,数字越大级别越高。</span>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span
style="color:red">*</span> 等级名称</label>
@ -43,7 +90,6 @@
value="{{$dividend->level_name}}"/>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">等级人数限制</label>
<div class="col-sm-6 col-xs-6">
@ -54,7 +100,6 @@
<span class="help-block">当前等级总人数达到指定数量后其他人则不能升级到当前等级。为空或者0则不限制人数</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-6 col-xs-6">
@ -79,7 +124,6 @@
<span class="help-block">超过层级限制,无法获得经销商提成,感恩奖也随之无法获得</span>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">升级条件</label>
<div class="col-xs-12 col-sm-9 col-md-10">
@ -709,8 +753,6 @@
</span>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
<div class="col-xs-6">
@ -727,14 +769,12 @@
</div>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
<div class="col-xs-6">
<span class='help-block'><input type="button" value="添加分组[选择升级方式编号,英文逗号分隔]" class="btn btn-success add-upgrade"/></span>
</div>
</div>
@if($settingData['is_activation_code'])
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">激活码发放</label>
@ -791,18 +831,73 @@
</div>
</div>
@endif
{{-- 升级奖励 start--}}
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">升级奖励积分</label>
<label class="col-xs-12 col-sm-3 col-md-2 control-label">升级奖励</label>
<div class="col-sm-6 col-xs-6">
<div class='input-group'>
<input type='text' name='dividend[upgrade_reward_point]'
class="form-control discounts_value"
value="{{$dividend->upgrade_reward_point?$dividend->upgrade_reward_point:0}}"/>
<div class='input-group-addon waytxt'>积分</div>
<input type='text' name='dividend[upgrade_reward_point]' class="form-control discounts_value" value="{{$dividend->upgrade_reward_point?$dividend->upgrade_reward_point:0}}"/>
<div class='input-group-addon waytxt'></div>
</div>
<div class='input-group'>
<div class='input-group-addon waytxt'>数藏画</div>
<input type='number' name='dividend[upgrade_reward_draw]' max="99" class="form-control discounts_value" value="{{$dividend->upgrade_reward_draw?$dividend->upgrade_reward_draw:0}}"/>
<div class='input-group-addon waytxt'></div>
</div>
<span class="help-block">数藏画仅第一次升级到当前等级赠送。如果降级后重新升级到当前等级则不会赠送</span>
{{-- 权重值 --}}
<div class="weight-value-content">
<div class="title">
<div class="title-left"></div>
<div class="title-content">权重值设置</div>
</div>
<div class="input-group weight-value-top-content">
<div class='input-group-addon waytxt weight-value-lable'>赠送方式</div>
<div class='input-group-addon waytxt weight-value-radio'>
<label class="radio-inline">
<input type="radio" name="wv[gift_type]" value="0" @if ((int)$wv['gift_type'] != 1) checked @endif> 固定值
</label>
<label class="radio-inline">
<input type="radio" name="wv[gift_type]" value="1" @if ((int)$wv['gift_type'] == 1) checked @endif> 阶梯赠送
</label>
</div>
</div>
<span class="help-block">普通赠送-赠送指定的权重值;阶梯赠送-根据用户成为经销商的时间顺序排序,获取对应的权重值;超过最大名次则不赠送权重值</span>
<div class="input-group weight-value-top-content">
<div class='input-group-addon waytxt weight-value-lable'>赠送级别</div>
<div class='input-group-addon waytxt weight-value-radio'>
<label class="radio-inline">
<input type="radio" name="wv[lv_type]" value="0" @if ((int)$wv['lv_type'] != 1) checked @endif> 二级
</label>
<label class="radio-inline">
<input type="radio" name="wv[lv_type]" value="1" @if ((int)$wv['lv_type'] == 1) checked @endif> 三级
</label>
</div>
</div>
<span class="help-block">二级-赠送购买人、购买人上级;三级-赠送购买人、购买人上级、购买人上级的上级</span>
{{--赠送固定值--}}
<div class='input-group wv-gift-type-num @if ((int)$wv['gift_type'] == 1) hide @endif'>
<div class='input-group-addon waytxt'>赠送</div>
<input type='number' name='wv[quantity]' class="form-control discounts_value" value="{{$wv['quantity']?:0}}"/>
<div class='input-group-addon waytxt'>权重值</div>
</div>
{{--阶梯赠送 - 根据成为当前等级经销商的等级排名 进行赠送--}}
<div class="ladder-content wv-gift-type-num @if ((int)$wv['gift_type'] != 1) hide @endif">
<div id="ladder-content-list">
{{--阶梯内容渲染--}}
</div>
<span class="help-block">例如设置小于等于10赠送100权重值小于等于32赠送120权重值。则第1~10位经销商赠送100权重值第11~32位经销商赠送120权重值第33位及之后所有经销商均不赠送权重值</span>
<span class='help-block'>
<input type="button" value="添加阶梯" class="btn btn-success add-ladder"/>
</span>
</div>
</div>
{{-- 权重值 end --}}
<span class="help-block">权重值仅第一次升级到当前等级赠送。如果降级后重新升级到当前等级则不会赠送</span>
</div>
</div>
{{-- 升级奖励 end--}}
@if($isPluginGold)
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">升级奖励{{$goldTitle}}</label>
@ -816,7 +911,6 @@
</div>
</div>
@endif
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">基金奖励</label>
<div class="col-sm-6 col-xs-6">
@ -826,7 +920,6 @@
</div>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">红包奖励比例</label>
<div class="col-sm-6 col-xs-6">
@ -838,7 +931,6 @@
</div>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">日期</label>
<div class="col-sm-6 col-xs-6">
@ -854,7 +946,6 @@
</div>
</div>
</div>
@if(is_null($settingData['withdraw_type']) || $settingData['withdraw_type'] == 0)
<div class="form-group" id="day" style="display: block">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">自动提现日期</label>
@ -875,7 +966,6 @@
</div>
</div>
@endif
<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">
@ -918,7 +1008,6 @@
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-9">
<div id="modal-module-menus-goods" class="modal fade" tabindex="-1">
@ -951,7 +1040,6 @@
</div>
</div>
</div>
<div id="modal-goods" class="modal fade" tabindex="-1">
<div class="modal-dialog" style='width: 920px;'>
<div class="modal-content">
@ -969,7 +1057,6 @@
</div>
</div>
</div>
<div class="form-group"></div>
<script language='javascript'>
function search_goods() {
@ -986,7 +1073,6 @@
)
;
}
function search_goods_two() {
if( $.trim($('#search-kwd-goods-dividend').val())==''){
Tip.focus('#search-kwd-goods-dividend','请输入关键词');
@ -999,7 +1085,6 @@
$('#module-menus-goods-two').html(dat);
});
}
function select_good(o) {
$("#goodsid").val(o.id);
$("#goodsthumb").show();
@ -1007,7 +1092,6 @@
$("#goods").val("[" + o.id + "]" + o.title);
$("#modal-module-menus-goods .close").click();
}
function select_good_two(o) {
var html = '<div class="multi-item" style="height: 220px" openid="' + o.id + '">';
html += '<img class="img-responsive img-thumbnail" src="' + o.thumb + '" onerror="this.src=\'{{static_url('resource/images/nopic.jpg')}}\'; this.title=\'图片未找到.\'">';
@ -1029,7 +1113,6 @@
});
$('#many_good').val(nickname);
}
{{--var i = "{{ $income_count }}";--}}
var i = "{{ count($upgrade_type['group']) }}";
$('.add-upgrade').click(function () {
@ -1071,5 +1154,70 @@
})
})
</script>
<script type="text/javascript">
let ladder = JSON.parse(`{!! $wv['ladder'] ?? json_encode([]) !!}`) || {};
$(function () {
// 权重值 - 赠送方式改变
$(document).on('change',"[name='wv[gift_type]']",function(){
let val = $(this).val();
val = parseInt(val) && !isNaN(parseInt(val)) ? parseInt(val) : parseInt(0);
// 控制显示隐藏 固定值|阶梯列表
$(".wv-gift-type-num").addClass('hide');
if(val === parseInt(0)) $('.wv-gift-type-num:eq(0)').removeClass('hide');
else $('.wv-gift-type-num:eq(1)').removeClass('hide');
});
// 权重值 - 点击添加阶梯
$(document).on('click',".add-ladder",function(){
ladder = Object.values(ladder).concat({where: '', num: ''});
handleLadder();
});
// 权重值 - 修改条件
$(document).on('keyup',".change-ladder-where",function(){
let index = $(this).parent(".input-group").attr("index");
let val = $(this).val();
val = parseInt(val) && !isNaN(parseInt(val)) ? parseInt(val) : parseInt(0);
ladder[index]['where'] = val;
});
// 权重值 - 修改数量
$(document).on('change',".change-ladder-num",function(){
let index = $(this).parent(".input-group").attr("index");
let val = $(this).val();
val = parseInt(val) && !isNaN(parseInt(val)) ? parseInt(val) : parseInt(0);
ladder[index]['num'] = val;
});
// 权重值 - 点击删除阶梯
$(document).on('click',".del-ladder-btn",function(){
let index = $(this).parent(".input-group").attr("index");
let newLadder = Object.assign({},ladder);
delete newLadder[index];
ladder = Object.values(newLadder);
handleLadder();
});
// 页面加载完成后执行一次
handleLadder();
});
// 循环渲染阶梯设置
function handleLadder(){
let html = '';
Object.values(ladder).forEach((item,index)=>{
html += `<div class='input-group' index='${index}'>
<div class='input-group-addon waytxt'>小于等于</div>
<input type='number' name='wv[ladder][${index}][where]' class="form-control change-ladder-where" value="${item['where']}"/>
<div class='input-group-addon waytxt'>名,赠送</div>
<input type='number' name='wv[ladder][${index}][num]' class="form-control change-ladder-num" value="${item['num']}"/>
<div class='input-group-addon waytxt'>权重值</div>
<div class='input-group-addon waytxt del-ladder-btn'>
<i class="fa fa-trash"></i>
</div>
</div>`;
});
$("#ladder-content-list").html(html);
}
</script>
@endsection

View File

@ -10,15 +10,16 @@ class GoodsWeightValue extends BaseModel{
public $table = 'yz_goods_weight_value';
public $timestamps = false;
public static function relationSave($goodsId, $data, $operate){
public static function relationSave($goodsId, $data, $operate,$isTeamDividend = false){
if (!$goodsId) return false;
if (!$data) return false;
$info = self::getModel($goodsId, $operate);
$info = self::getModel($goodsId, $operate, $isTeamDividend);
// 判断deleted
if ($operate == 'deleted') return $info->delete();
// 其他
$info->uniacid = \YunShop::app()->uniacid;
$info->goods_id = $goodsId;
$info->goods_id = $isTeamDividend ? 0 : $goodsId;// 经销商设置true goods_id = 0否则为goodsId
$info->team_dividend_level_id = $isTeamDividend ? $goodsId : 0;// 经销商设置true team_dividend_level_id = goodsId否则为0
$info->is_open = $data['is_open'] ?? 0;// 是否开启购买商品赠送权重值0=未开启1=开启
$info->gift_type = $data['gift_type'] ?? 0;// 赠送方式0=赠送固定值1=阶梯值赠送
$info->lv_type = $data['lv_type'] ?? 0;// 赠送方式0=二级1=三级
@ -31,16 +32,21 @@ class GoodsWeightValue extends BaseModel{
return $info->save();
}
public static function getModel($goodsId, $operate){
public static function getModel($goodsId, $operate,$isTeamDividend = false){
$model = false;
if ($operate != 'created') $model = static::where(['goods_id' => $goodsId])->first();
// 商品设置
if ($operate != 'created') {
if($isTeamDividend) $model = static::where(['team_dividend_level_id' => $goodsId])->first();// 经销商设置
else $model = static::where(['goods_id' => $goodsId])->first();// 经销商设置
}
!$model && $model = new static;
return $model;
}
public function getGoodsSet($goodsId){
public function getGoodsSet($goodsId,$isTeamDividend = false){
if($isTeamDividend) return self::where('team_dividend_level_id', $goodsId);
return self::where('goods_id', $goodsId);
}

View File

@ -25,6 +25,7 @@ class WeightValueLog extends BaseModel{
'change_after',
'remark',
'created_at',
'source'
];
/**