添加:消费返利 - 基本设置

This commit is contained in:
wuhui_zzw 2024-03-13 10:47:25 +08:00
parent 72118a360f
commit c62df020e7
3 changed files with 207 additions and 67 deletions

View File

@ -3939,3 +3939,13 @@ if (!function_exists('curlPost')) {
return json_decode($result,true);
}
}
// 获取下个月的今天(如果时间超出下个月则返回下个月最后一天)
function getNextMonthDays($timestamp,$num = 1){
$nextMoneyToday = strtotime(date("Y-m-d H:i:s",$timestamp). " +{$num} month");// 获取下个月的今天
$toMoneyFirstDay = strtotime(date("Y-m-1 H:i:s", $timestamp));// 获取当月第一天
$nextMonthFirstDay = strtotime(date("Y-m-d H:i:s", $toMoneyFirstDay). " +{$num} month");// 获取下一个月第一天
$nextMonthLastDay = strtotime(date("Y-m-t H:i:s", $nextMonthFirstDay));// 获取下一个月最后一天
// 判断:如果下个月的今天时间 大于 下个月最后一天的时间;则返回下个月最后一天 否则返回下个月的今天的时间
return $nextMoneyToday > $nextMonthLastDay ? $nextMonthLastDay : $nextMoneyToday;
}

View File

@ -38,6 +38,20 @@ class IndexController extends BaseController{
// 获取信息
$set = Setting::get('plugin.rebate');
// $start = "2024-3-31 12:12:59";
// echo "购买时间:".$start."<br />";
// for($i=1;$i <= 20;$i++){
// $d = strtotime($start );
// echo "第{$i}个月返利时间:".date("Y-m-d H:i:s",getNextMonthDays($d, $i))."<br />";
// }
// die;
return view('Yunshop\Rebate::index.set',[
'set' => $set,
])->render();

View File

@ -3,59 +3,130 @@
@section('content')
<link rel="stylesheet" type="text/css" href="{{static_url('yunshop/goods/vue-goods1.css')}}"/>
<link rel="stylesheet" href="{{static_url('css/public-number.css')}}">
<style></style>
<style>
.shortInput{
width: 500px!important;
}
.quarter-block{
border: 1px solid #DCDFE6;
margin-top: 20px;
padding: 0 15px;
}
.quarter-block .tips{
font-size: 12px;
color: #737373;
line-height: 20px;
width: 100%;
}
.quarter-block .title{
height: 40px;
line-height: 40px;
font-weight: bold;
font-size: 14px;
padding-left: 10px;
position: relative;
}
.quarter-block .title:after{
content: "";
position: absolute;
left: 0;
top: 11px;
width: 4px;
height: 18px;
background: #29ba9c;
}
.quarter-block .isRepurchase{
margin-top: 15px;
margin-right: 50px;
}
.quarter-block .monthInput{
min-width: 350px;
width: calc((100% - 30px) / 4);
margin-bottom: 10px;
margin-right: 10px;
}
.quarter-block .monthInput:nth-child(4n){
margin-right: 0!important;
}
.quarter-block .monthInput .prepend-month{
font-weight: bold;
}
.quarter-block .monty-list{
margin-top: 15px;
}
</style>
<div class="all">
<div id="app">
<el-form :model="set" label-width="15%">
<div class="vue-head">
<div class="vue-main-title">
<div class="vue-main-title-left"></div>
<div class="vue-main-title-content">基本设置</div>
<div class="vue-main-title-content">返利设置</div>
</div>
<div class="vue-main-form">
<el-form-item label="字画名称">
<el-input placeholder="请输入字画名称" v-model="set.title"></el-input>
</el-form-item>
<el-form-item label="典藏室顶部图片" prop="top_thumb">
<div class="upload-box" @click="openUpload('top_thumb')" v-if="!set.top_thumb">
<i class="el-icon-plus" style="font-size:32px"></i>
</div>
<div @click="openUpload('top_thumb')" class="upload-boxed" v-if="set.top_thumb">
<img :src="set.top_thumb" alt="" style="width:150px;height:150px;border-radius: 5px;cursor: pointer;">
<i class="el-icon-close" @click.stop="clearImg('top_thumb')" title="点击清除图片"></i>
<div class="upload-boxed-text">点击重新上传</div>
</div>
</el-form-item>
<el-form-item label="高仿画图片" prop="imitation">
<div class="upload-box" @click="openUpload('imitation')" v-if="!set.imitation">
<i class="el-icon-plus" style="font-size:32px"></i>
</div>
<div @click="openUpload('imitation')" class="upload-boxed" v-if="set.imitation">
<img :src="set.imitation" alt="" style="width:150px;height:150px;border-radius: 5px;cursor: pointer;">
<i class="el-icon-close" @click.stop="clearImg('imitation')" title="点击清除图片"></i>
<div class="upload-boxed-text">点击重新上传</div>
</div>
</el-form-item>
<el-form-item label="数藏画图片" prop="collection">
<div class="upload-box" @click="openUpload('collection')" v-if="!set.collection">
<i class="el-icon-plus" style="font-size:32px"></i>
</div>
<div @click="openUpload('collection')" class="upload-boxed" v-if="set.collection">
<img :src="set.collection" alt="" style="width:150px;height:150px;border-radius: 5px;cursor: pointer;">
<i class="el-icon-close" @click.stop="clearImg('collection')" title="点击清除图片"></i>
<div class="upload-boxed-text">点击重新上传</div>
<el-form-item label="是否开启消费返利" prop="is_switch">
<div style="line-height:40px">
<el-radio v-model.number="set.is_switch" :label="0">不开启</el-radio>
<el-radio v-model.number="set.is_switch" :label="1">开启</el-radio>
</div>
</el-form-item>
<template v-if="set.is_switch == 1">
<el-form-item label="返利季度">
<el-input placeholder="请输入返利总季度" v-model.number="set.total_quarter" min="0" type="number" class="shortInput">
<template slot="prepend">总共返利</template>
<template slot="append">个季度</template>
</el-input>
{{-- 循环每个季度 --}}
<div v-for="(quarter,index) in set.quarter_list" :key="index" class="quarter-block">
<div class="title"> [[ index ]] 季度</div>
<el-input v-model.number="quarter.total_month" min="0" type="number" class="shortInput">
<template slot="prepend">本季度总</template>
<template slot="append">个月</template>
</el-input>
<div class="tips">本季度总的月数必须大于等于1</div>
<div class="isRepurchase">
是否需要复购:
<el-radio-group v-model.number="quarter.is_repurchase">
<el-radio :label="0">不需要</el-radio>
<el-radio :label="1">需要</el-radio>
</el-radio-group>
</div>
<template v-if="quarter.is_repurchase == 1">
<el-input v-model.number="quarter.repurchase_money" type="number" class="shortInput">
<template slot="prepend">复购需要支付</template>
<template slot="append"></template>
</el-input>
</template>
<div class="tips">不需要复购:在下一个季度开始返利时可以直接领取;需要复购:在本季度最后一笔返利领取后指定时间内需要重新购买指定产品,否则后续不在返利,后续未领取返利全部失效!</div>
<div class="monty-list" v-if="Object.values(quarter.month_list).length > 0">
<el-input
v-for="(month,monthIndex) in quarter.month_list"
:value="month"
:key="monthIndex"
placeholder="返利金额"
type="number"
step="0.01"
class="monthInput"
v-model="quarter.month_list[monthIndex]"
>
<template slot="prepend"> <span class="prepend-month">[[ monthIndex ]]</span> 个月返利</template>
<template slot="append"></template>
</el-input>
</div>
</div>
</el-form-item>
</template>
<el-form-item>
<el-button type="primary" size="small" @click="onSubmit">保存</el-button>
</el-form-item>
</div>
</div>
</el-form>
<upload-img :upload-show="uploadShow" :name="chooseImgName" @replace="changeProp" @sure="sureImg"></upload-img>
</div>
</div>
@include('public.admin.uploadImg')
<script>
var app = new Vue({
el:"#app",
@ -63,49 +134,94 @@
name: 'test',
data() {
return{
// 图片上传
uploadShow:false,
chooseImgName:'',
chooseIndex:-1,
type:0,
// 设置信息
set:{
title: "{{ $set['title'] ?? '' }}",
top_thumb: "{{ $set['top_thumb'] ?? '' }}",
imitation: "{{ $set['imitation'] ?? '' }}",
collection: "{{ $set['collection'] ?? '' }}",
is_switch: Number("{{ $set['is_switch'] ?? 0 }}"),
total_quarter: "{{ $set['total_quarter'] ?? '' }}",
quarter_list: JSON.parse('{!! json_encode($set['quarter_list']) !!}') || {},
},
}
},
computed:{
countTotalMonth(){
let set = Object.assign({}, this.set);
let quarterList = Object.assign({}, set.quarter_list);
return Object.values(quarterList).reduce((sum, item) => sum + item.total_month, 0);
}
},
watch:{
// 总季度信息变更
'set.total_quarter':{
handler(val, olVal) {
let value = Number(val) >= 0 ? Number(val) : 0;
let newQuarterList = {};
if(Number(value) > 0){
let quarterList = Object.assign({}, this.set.quarter_list);
for(value;value > 0;value--){
let currentQuarter = quarterList[value] || {};
if(Object.values(currentQuarter).length <= 0){
// 当前季度信息不存在
newQuarterList[value] = {
total_month: 0,// 本季度总多少月
is_repurchase: 0,// 是否需要复购
repurchase_money: 0,// 复购支付金额
month_list: {},// 每月返利金额
};
}else{
// 当前季度信息存在
newQuarterList[value] = currentQuarter;
}
}
}
this.$set(this.set, 'quarter_list', newQuarterList)
this.$forceUpdate();
},
deep:true
},
// 月度信息变更
countTotalMonth:{
handler(val, olVal) {
if(Number(val) !== Number(olVal)){
let set = Object.assign({}, this.set);
let quarterList = Object.assign({}, set.quarter_list);
// 循环处理每个季度
for(const index in quarterList){
let currentMonthInfo = quarterList[index] || {};
let totalMonth = Number(currentMonthInfo.total_month) || 0;
let monthList = currentMonthInfo.month_list || {};
let newMonthList = {};
if(totalMonth > 0){
for(totalMonth;totalMonth > 0;totalMonth--){
let currentMonth = monthList[totalMonth] || '';
newMonthList[totalMonth] = currentMonth || '';
}
}
quarterList[index].month_list = newMonthList;
}
this.$set(this.set, 'quarter_list', quarterList)
this.$forceUpdate();
}
},
deep:true
},
},
created() {},
mounted() {},
methods: {
// 点击选择图片
openUpload(str,index,type) {
this.chooseImgName = str;
this.uploadShow = true;
this.chooseIndex = index;
this.type = '2';
},
// 图片弹框显示隐藏改变
changeProp(val) {
if(val == true) this.uploadShow = false;
else this.uploadShow = true;
},
// 图片选中
sureImg(name,image,img_url) {
this.set[name] = img_url;
},
// 删除图片
clearImg(name) {
this.set[name] = '';
this.$forceUpdate();
},
// 修改 每月返利金额
// 提交
onSubmit() {
let _this = this;
_this.$http.post('{!! yzWebFullUrl('plugin.collection-room.admin.index.set') !!}', {
collection_room: _this.set
_this.$http.post('{!! yzWebFullUrl('plugin.rebate.admin.index.set') !!}', {
rebate: _this.set
}).then(function (response) {
let res = response.body;
_this.$message({