重构:权重值转赠 - 由经销商直接可以赠送修改为只能同等级或者成为过该等级的经销商可以互相赠送,添加密码支持,添加手续费支持。
This commit is contained in:
parent
4a0bdf1436
commit
bbb78240f2
|
|
@ -1,110 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* Author:
|
||||
* Date: 2017/4/2
|
||||
* Time: 下午5:37
|
||||
*/
|
||||
|
||||
namespace app\frontend\modules\finance\controllers;
|
||||
|
||||
use app\common\components\ApiController;
|
||||
use app\common\models\Member;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Yunshop\TeamDividend\models\TeamDividendAgencyModel;
|
||||
|
||||
class WeightValueController extends ApiController{
|
||||
/**
|
||||
* Common: 获取权重值首页信息
|
||||
* Author: wu-hui
|
||||
* Time: 2023/09/27 16:00
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function index(){
|
||||
$uid = \YunShop::app()->getMemberId();
|
||||
$data = [
|
||||
'weight_value' => sprintf("%.2f",Member::where('uid', $uid)->value('weight_value')),
|
||||
'list' => WeightValueLog::uniacid()->where('member_id',$uid)->limit(10)->get(['type','change_type','change_quantity','change_after','remark','created_at']),
|
||||
];
|
||||
|
||||
return $this->successJson('成功', $data);
|
||||
}
|
||||
/**
|
||||
* Common: 获取用户权重值信息
|
||||
* Author: wu-hui
|
||||
* Time: 2023/09/27 16:31
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function memberWeightValue(){
|
||||
if ($memberInfo = Member::where('uid', \YunShop::app()->getMemberId())->first()) {
|
||||
$data['weight_value'] = $memberInfo->weight_value;
|
||||
$data['has_password'] = $memberInfo->yzMember->hasPayPassword();
|
||||
$data['need_password'] = false;//(new PasswordService())->isNeed('balance', 'transfer');
|
||||
|
||||
return $this->successJson('获取数据成功', $data);
|
||||
}
|
||||
return $this->errorJson('未获取到会员数据');
|
||||
}
|
||||
/**
|
||||
* Common: 权重值转账
|
||||
* Author: wu-hui
|
||||
* Time: 2023/09/27 17:17
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function transfer(){
|
||||
// 参数获取
|
||||
$uid = \YunShop::app()->getMemberId();
|
||||
$transferId = (int)request()->input('transfer_id');
|
||||
$transferMoney = abs((float)request()->input('transfer_money'));
|
||||
if($transferId <= 0 || $transferMoney <= 0) return $this->errorJson('无受让人或者转赠数量为0!');
|
||||
// 判断:双方必须都是经销商
|
||||
$currentMemberIs = (int)TeamDividendAgencyModel::uniacid()->where('uid',$uid)->value('id');
|
||||
$transferMemberIs = (int)TeamDividendAgencyModel::uniacid()->where('uid',$transferId)->value('id');
|
||||
if($currentMemberIs <= 0 || $transferMemberIs <= 0) return $this->errorJson('身份非法,双方都必须为经纪人才能进行当前操作!');
|
||||
DB::beginTransaction();
|
||||
try{
|
||||
// 获取用户信息
|
||||
$currentMemberName = Member::uniacid()->where('uid',$uid)->value('nickname');
|
||||
$transferMemberName = Member::uniacid()->where('uid',$transferId)->value('nickname');
|
||||
// 减少当前用户持有权重值
|
||||
(new WeightValueLog())->weightValueOperate($uid,$transferMoney,0,"赠送给【{$transferMemberName}】");
|
||||
// 增加受让人持有权重值
|
||||
(new WeightValueLog())->weightValueOperate($transferId,$transferMoney,1,"来自【{$currentMemberName}】的赠送");
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $this->successJson('操作成功');
|
||||
}catch(\Exception $e){
|
||||
DB::rollBack();
|
||||
return $this->errorJson($e->getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Common: 获取权重值变更记录列表
|
||||
* Author: wu-hui
|
||||
* Time: 2023/09/27 17:40
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function record(){
|
||||
//参数获取
|
||||
$pageSize = request()->input('page_size',10);
|
||||
$search = request()->input('search');
|
||||
$search['member_id'] = \YunShop::app()->getMemberId();
|
||||
// 列表获取
|
||||
$field = ['id','member_id','type','change_type','change_quantity','change_front','change_after','remark','created_at'];
|
||||
$result = WeightValueLog::getList($pageSize,$search,$field);
|
||||
$data = [
|
||||
'current_page' => $result['current_page'],
|
||||
'last_page' => $result['last_page'],
|
||||
'list' => $result['data'],
|
||||
'income' => WeightValueLog::getChangeTypeSum($search['member_id'],1),
|
||||
'expenditure' => WeightValueLog::getChangeTypeSum($search['member_id'],0),
|
||||
];
|
||||
|
||||
|
||||
return $this->successJson('成功', $data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -6,6 +6,8 @@ use app\common\helpers\PaginationHelper;
|
|||
use Yunshop\TeamDividend\models\TeamDividendLevelModel;
|
||||
use Yunshop\WeightValue\models\WeightValue;
|
||||
use Yunshop\WeightValue\models\WeightValueLog;
|
||||
use app\common\facades\Setting;
|
||||
use app\common\helpers\Url;
|
||||
|
||||
class IndexController extends BaseController{
|
||||
|
||||
|
|
@ -75,6 +77,34 @@ class IndexController extends BaseController{
|
|||
'is_get' => $isGet,
|
||||
])->render();
|
||||
}
|
||||
/**
|
||||
* Common: 设置信息编辑
|
||||
* Author: wu-hui
|
||||
* Time: 2023/10/20 14:33
|
||||
* @return array|mixed|string|void
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function set(){
|
||||
// 获取设置信息 判断是否为设置
|
||||
$setInfo = request()->input('weight_value');
|
||||
if ($setInfo) {
|
||||
// 信息校验
|
||||
if((int)$setInfo['is_open_commission'] == 1 && ((float)$setInfo['commission'] <= 0 || (float)$setInfo['commission'] > 100)){
|
||||
return $this->message('手续费比例填写错误','','error');
|
||||
}
|
||||
// 设置信息
|
||||
if (Setting::set('plugin.weight_value', $setInfo)) return $this->message('设置成功', Url::absoluteWeb('plugin.weight-value.admin.index.set'));
|
||||
else $this->message('设置失败','','error');
|
||||
}else{
|
||||
// 获取信息
|
||||
$set = Setting::get('plugin.weight_value');
|
||||
|
||||
return view('Yunshop\WeightValue::index.set',[
|
||||
'set' => $set,
|
||||
])->render();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,12 +3,17 @@
|
|||
namespace Yunshop\WeightValue\Api;
|
||||
|
||||
use app\common\components\ApiController;
|
||||
use app\common\facades\Setting;
|
||||
use app\common\models\Income;
|
||||
use app\common\models\Member;
|
||||
use app\common\models\member\MemberChildren;
|
||||
use app\common\services\password\PasswordService;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Yunshop\TeamDividend\models\TeamDividendAgencyModel;
|
||||
use Yunshop\TeamDividend\models\TeamDividendLevelModel;
|
||||
use Yunshop\WeightValue\models\WeightValue;
|
||||
use Yunshop\WeightValue\models\WeightValueLog;
|
||||
use Yunshop\WeightValue\models\WeightValueTransfer;
|
||||
|
||||
class IndexController extends ApiController{
|
||||
/**
|
||||
|
|
@ -91,6 +96,137 @@ class IndexController extends ApiController{
|
|||
'last_page' => (int)$result['last_page'],
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* Common: 获取我的权重值信息
|
||||
* Author: wu-hui
|
||||
* Time: 2023/10/20 13:42
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function myWeightValue(){
|
||||
// 基本参数
|
||||
$uid = \YunShop::app()->getMemberId();
|
||||
$teamLevelId = (int)request()->input('team_level_id');// 经销商等级id
|
||||
// 信息获取
|
||||
$weightValue = WeightValue::getWeightValueQuantity((int)$uid,(int)$teamLevelId);
|
||||
$logList = WeightValueLog::uniacid()
|
||||
->where('member_id',$uid)
|
||||
->when($teamLevelId > 0,function($query) use ($teamLevelId){
|
||||
$query->where('team_dividend_agency_level_id',$teamLevelId);
|
||||
})
|
||||
->with([
|
||||
'level' => function($query){
|
||||
$query->select(['id','level_name']);
|
||||
},
|
||||
])
|
||||
->orderBy('created_at','DESC')
|
||||
->limit(10)
|
||||
->get(['team_dividend_agency_level_id','change_type','change_quantity','change_after','remark','created_at'])
|
||||
->toArray();
|
||||
$levelName = '我的';
|
||||
if($teamLevelId > 0) $levelName = TeamDividendLevelModel::uniacid()->where('id',$teamLevelId)->value('level_name');
|
||||
|
||||
return $this->successJson('成功',[
|
||||
'weight_value' => $weightValue,
|
||||
'level_name' => $levelName . '权重值',
|
||||
'list' => $logList
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* Common: 获取用户权重值转赠相关信息
|
||||
* Author: wu-hui
|
||||
* Time: 2023/10/20 16:51
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function transferInfo(){
|
||||
// 基本参数
|
||||
$uid = \YunShop::app()->getMemberId();
|
||||
$teamLevelId = (int)request()->input('team_level_id');// 经销商等级id
|
||||
if($teamLevelId <= 0) return $this->errorJson('非法请求,等级不明确!');
|
||||
$levelName = TeamDividendLevelModel::uniacid()->where('id',$teamLevelId)->value('level_name');
|
||||
// 信息处理
|
||||
if ($memberInfo = Member::where('uid', $uid)->first()) {
|
||||
$set = Setting::get('plugin.weight_value');
|
||||
// 信息获取
|
||||
$data = [
|
||||
'weight_value' => WeightValue::getWeightValueQuantity((int)$uid,(int)$teamLevelId),
|
||||
'has_password' => $memberInfo->yzMember->hasPayPassword(),
|
||||
'need_password' => (int)$set['is_password'],
|
||||
'is_open_commission' => (int)$set['is_open_commission'],
|
||||
'commission' => (float)$set['commission'],
|
||||
'level_name' => $levelName,
|
||||
];
|
||||
|
||||
return $this->successJson('获取数据成功', $data);
|
||||
}
|
||||
|
||||
return $this->errorJson('未获取到会员数据');
|
||||
}
|
||||
/**
|
||||
* Common: 权重值转账
|
||||
* Author: wu-hui
|
||||
* Time: 2023/10/20 18:01
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function transfer(){
|
||||
// 参数获取
|
||||
$uid = \YunShop::app()->getMemberId();
|
||||
$teamLevelId = (int)request()->input('team_level_id');// 经销商等级id
|
||||
$transferId = (int)request()->input('transfer_id');
|
||||
$transferMoney = abs((float)request()->input('transfer_money'));
|
||||
$password = request()->input('password');
|
||||
if($transferId <= 0 || $transferMoney <= 0) return $this->errorJson('无受让人或者转赠数量为0!');
|
||||
if($teamLevelId <= 0) return $this->errorJson('非法请求,等级不明确!');
|
||||
$levelName = TeamDividendLevelModel::uniacid()->where('id',$teamLevelId)->value('level_name');
|
||||
$set = Setting::get('plugin.weight_value');
|
||||
// 开始处理
|
||||
DB::beginTransaction();
|
||||
try{
|
||||
// 判断:受让人不能是本人
|
||||
if($uid == $transferId) throw new \Exception("身份非法,受让人不能是自己!");
|
||||
// 判断:密码是否正确
|
||||
if((int)$set['is_password'] == 1) (new PasswordService())->checkPayPassword($uid, $password);
|
||||
// 判断:双方必须存在当前等级的权重值信息
|
||||
$currentMember = WeightValue::uniacid()->where('member_id',$uid)->where('team_dividend_agency_level_id',$teamLevelId)->first();// 当前用户
|
||||
$transferMember = WeightValue::uniacid()->where('member_id',$transferId)->where('team_dividend_agency_level_id',$teamLevelId)->first();// 受让人
|
||||
if((int)$currentMember->id <= 0 || (int)$transferMember->id <= 0) throw new \Exception("身份非法,双方都必须为${$levelName}才能进行当前操作!");
|
||||
// 计算手续费和减少金额
|
||||
$reduceMoney = $transferMoney;// 减少数量 默认为转赠数量
|
||||
$commission = (int)0;// 默认手续费
|
||||
if((int)$set['is_open_commission'] == 1 && (float)$set['commission'] > 0){
|
||||
$commission = (float)sprintf("%.2f", $transferMoney * (float)$set['commission'] / 100);// 手续费
|
||||
$reduceMoney = (float)sprintf("%.2f",$transferMoney + $commission);// 添加手续费后的减少数量
|
||||
}
|
||||
// 获取用户信息
|
||||
$currentMemberName = Member::uniacid()->where('uid',$uid)->value('nickname');
|
||||
$transferMemberName = Member::uniacid()->where('uid',$transferId)->value('nickname');
|
||||
// 减少当前用户持有权重值
|
||||
(new WeightValueLog())->transferHandle((int)$uid,(float)$reduceMoney,0,"赠送给【{$transferMemberName}】", (int)$teamLevelId);
|
||||
// 增加受让人持有权重值
|
||||
(new WeightValueLog())->transferHandle((int)$transferId,(float)$transferMoney,1,"来自【{$currentMemberName}】的赠送",(int)$teamLevelId);
|
||||
// 记录转赠信息
|
||||
WeightValueTransfer::insert([
|
||||
'uniacid' => \YunShop::app()->uniacid,
|
||||
'team_dividend_agency_level_id' => $teamLevelId,
|
||||
'member_id' => $uid,
|
||||
'transfer_member_id' => $transferId,
|
||||
'transfer_num' => $transferMoney,
|
||||
'receipt_num' => $transferMoney,
|
||||
'service_charge' => $commission,
|
||||
'remark' => "【{$currentMemberName}】赠送给【{$transferMemberName}】",
|
||||
'created_at' => time(),
|
||||
]);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $this->successJson('操作成功');
|
||||
}catch(\Exception $e){
|
||||
DB::rollBack();
|
||||
return $this->errorJson($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -401,6 +401,7 @@ class WeightValue extends BaseModel{
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Common: 统计信息 - 全部统计信息获取及处理
|
||||
* Author: wu-hui
|
||||
|
|
|
|||
|
|
@ -61,7 +61,44 @@ class WeightValueLog extends BaseModel{
|
|||
|
||||
return $list ? $list->toArray() : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Common: 转赠后权重值变更处理
|
||||
* Author: wu-hui
|
||||
* Time: 2023/10/20 17:59
|
||||
* @param int $uid
|
||||
* @param float $money
|
||||
* @param int $changeType
|
||||
* @param string $remark
|
||||
* @param int $teamLevelId
|
||||
*/
|
||||
public function transferHandle(int $uid,float $money,int $changeType,string $remark,int $teamLevelId){
|
||||
// 获取当前用户持有数量
|
||||
$changeFront = (float)WeightValue::getWeightValueQuantity((int)$uid,(int)$teamLevelId);
|
||||
// 变更后的数量
|
||||
$changeAfter = $changeType == 1 ? $changeFront + $money : $changeFront - $money;
|
||||
// 变更记录
|
||||
$data = [
|
||||
'uniacid' => \YunShop::app()->uniacid,
|
||||
'member_id' => $uid,// 用户id
|
||||
'team_dividend_agency_level_id' => $teamLevelId,// 经销商等级id
|
||||
'goods_id' => 0,// 商品id
|
||||
'order_id' => 0,// 订单id
|
||||
'order_goods_id' => 0,// 订单商品id
|
||||
'change_type' => $changeType,// 变更类型:0=减少,1=增加
|
||||
'change_quantity' => $money,// 变更数量
|
||||
'change_front' => (float)$changeFront,// 变更前拥有的数量
|
||||
'change_after' => sprintf("%.2f",$changeAfter),// 变更后拥有的数量
|
||||
'remark' => $remark,// 备注
|
||||
'created_at' => time(),// 变更时间
|
||||
'source' => 2,// 变更时间
|
||||
];
|
||||
$this->insert($data);
|
||||
// 修改用户持有
|
||||
WeightValue::uniacid()
|
||||
->where('member_id',$uid)
|
||||
->where('team_dividend_agency_level_id',$teamLevelId)
|
||||
->update(['quantity' => $changeAfter]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Common: 一对一关联 用户信息
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
namespace Yunshop\WeightValue\models;
|
||||
|
||||
|
||||
use app\common\models\BaseModel;
|
||||
|
||||
|
||||
class WeightValueTransfer extends BaseModel{
|
||||
|
||||
public $table = 'yz_weight_value_transfer';
|
||||
public $timestamps = false;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,267 +1,41 @@
|
|||
@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>
|
||||
<style></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">
|
||||
<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="weight_value[is_open_commission]" value="0" @if ($set['is_open_commission'] != 1) checked="checked" @endif /> 无手续费
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="weight_value[is_open_commission]" value="1" @if ($set['is_open_commission'] == 1) checked="checked" @endif /> 有手续费
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group commission-value @if ($set['is_open_commission'] != 1) hide @endif">
|
||||
<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='weight_value[commission]' class="form-control" value="{{$set['commission']}}"/>
|
||||
<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-4 col-xs-6">
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="weight_value[is_password]" value="0" @if ($set['is_password'] != 1) checked="checked" @endif /> 不需要
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="weight_value[is_password]" value="1" @if ($set['is_password'] == 1) checked="checked" @endif /> 需要密码
|
||||
</label>
|
||||
<span class='help-block'>转赠是否需要密码</span>
|
||||
</div>
|
||||
</div>
|
||||
{{--提交按钮--}}
|
||||
<div class="form-group"></div>
|
||||
<div class="form-group">
|
||||
|
|
@ -272,249 +46,17 @@
|
|||
</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;
|
||||
},
|
||||
$(document).on('change',"[name='weight_value[is_open_commission]']",function(){
|
||||
let val = $(this).val();
|
||||
if(val == 1) $(".commission-value").removeClass('hide');
|
||||
else $(".commission-value").addClass('hide');
|
||||
});
|
||||
|
||||
|
||||
|
||||
},
|
||||
})
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue