添加:后台添加文创豆充值功能

This commit is contained in:
wuhui_zzw 2024-01-05 11:42:16 +08:00
parent 4948bb5744
commit 687e9daf83
4 changed files with 165 additions and 6 deletions

View File

@ -2,6 +2,7 @@
namespace Yunshop\CulturalSpace\admin;
use app\common\components\BaseController;
use app\common\facades\Setting;
use app\common\helpers\Url;
use Yunshop\CulturalSpace\models\CulturalFund;
use Yunshop\CulturalSpace\models\CulturalOrderFundLog;
use Yunshop\CulturalSpace\models\CulturalSpace;
@ -15,16 +16,20 @@ class FundController extends BaseController
// $result =(new CulturalSpace())->GiveGoodsFundMoney(22,93);
// }
$result =(new CulturalSpace())->GiveGoodsFundMoney(33,96);
// $result =(new CulturalSpace())->GiveGoodsFundMoney(33,96);
// $set = Setting::get('plugin.cultural_space_set');
// $result =(new CulturalSpace())->capitalIncrease($set);
var_dump($result);
// var_dump($result);
}
public function index(){
return view('Yunshop\CulturalSpace::fund.index')->render();
$selectedTab = request()->input('selected_tab');
return view('Yunshop\CulturalSpace::fund.index',[
'selected_tab' => $selectedTab
])->render();
}
@ -46,4 +51,40 @@ class FundController extends BaseController
$result =CulturalOrderFundLog::getList($search);
return $this->successJson('成功',$result);
}
/**
* Common: 文创豆充值(后台手动充值)
* Author: wu-hui
* Time: 2024/01/05 11:39
* @return array|mixed|string
* @throws \Throwable
*/
public function recharge(){
if(\Request::isMethod('post')){
$data = request()->input('data');
$errorLink = Url::absoluteWeb('plugin.cultural-space.admin.fund.index',['selected_tab'=>'show_user']);
if((int)$data['uid'] <= 0) return $this->message('充值用户不明确!', $errorLink, 'error');
if((float)$data['recharge_money'] <= 0) return $this->message('充值文创豆数量必须大于0!', $errorLink, 'error');
// 获取用户文创空间信息
try{
(new CulturalSpace())->getCulturalSpace([$data['uid']]);
// 增加用户持有文创豆
(new CulturalOrderFundLog())->transferHandle((int)$data['uid'],(float)$data['recharge_money'],0,"后台充值增加", 3);
return $this->message('充值成功!', $errorLink, 'success');
}catch(\Exception $e){
return $this->message($e->getMessage(), $errorLink, 'error');
}
}
return view('Yunshop\CulturalSpace::fund.recharge')->render();
}
}

View File

@ -297,7 +297,7 @@ class CulturalSpace extends BaseModel
* @param $ids
* @return array
*/
private function getCulturalSpace($ids)
public function getCulturalSpace($ids)
{
// 获取已经存在的信息
$list = self::uniacid()

View File

@ -79,7 +79,8 @@
<el-input v-model="search_list.uid" placeholder="请输入会员ID"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="clickSearch">查询</el-button>
<el-button @click="clickSearch">查询</el-button>
<el-button type="primary" @click="rechargeLegumes">充值</el-button>
</el-form-item>
</el-form>
{{--表单--}}
@ -176,7 +177,7 @@
name: 'cultural_space_index_content',
data: {
fundData:[],
tabs_active: 'show_detail',
tabs_active: "{{$selected_tab}}" || 'show_detail',
level_list: JSON.parse('{!! json_encode($level_list) !!}'),
// 分页信息
page: 1,
@ -262,6 +263,17 @@
this.tabs_active = 'show_group';
this.getData()
},
// 充值文创豆
rechargeLegumes(){
// 查看店长业绩及补助信息
let link = "{{yzWebUrl('plugin.cultural-space.admin.fund.recharge')}}";
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>

View File

@ -0,0 +1,106 @@
<style>
.select-user-btn{
height: 34px!important;
}
select{
width: calc((95% - 20px) / 3) !important;
height: 34px;
border-color: #ccc!important;
color: #555 !important;
background-color: #fff!important;
}
select:not(:last-child){
margin-right: 10px!important;
}
#member_avatar {
display: none;
}
#member_avatar img{
width:100px;
height:100px;
border:1px solid #ccc;
padding:1px
}
</style>
<div class="rightlist">
<form action="{{yzWebUrl('plugin.cultural-space.admin.fund.recharge')}}" method='post' class='form-horizontal' id="RechargeLegumes">
<div class='panel panel-default'>
<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-8">
<input type='hidden' id='member_id' name='data[uid]'/>
<div class='input-group'>
<input type="text" id="member_name" class="form-control" readonly/>
<div class='input-group-btn'>
<button class="select-user-btn btn btn-default" id="selectMemberBtn" type="button">选择用户</button>
<button class="select-user-btn btn btn-danger" id="removalBtn" type="button">清除选择</button>
</div>
</div>
<span id="member_avatar" class='help-block'>
<img src="" />
</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-8">
<input class="form-control" type='number' step="0.000001" name='data[recharge_money]'/>
</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="hidden" name="token" value="{{$var['token']}}" />
<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
</div>
</div>
</div>
</form>
</div>
<script type="text/javascript">
$(function () {
// 选择用户
$(document).on('click','#selectMemberBtn',function () {
let popup = util.selectMember('{!! yzWebUrl('member.query.selected') !!}',{},{
confirm:function (userInfo) {
// 获取用户信息
$("#member_id").val(userInfo.uid);
$("#member_avatar").show();
$("#member_avatar").find('img').attr('src',userInfo.avatar);
$("#member_name").val( userInfo.nickname);
// 关闭弹框
popup.modal('hide');
}
});
});
// 清除用户选择
$(document).on('click','#removalBtn',function () {
$('#member_id').val('');
$('#member_name').val('');
$('#member_avatar').hide()
});
// 表单验证
$("#RechargeLegumes").submit(function(){
// 表单信息处理
let list = $("#RechargeLegumes").serializeArray();
let newList = {};
$.each(list,function (k,v) {
let name = v.name.replace(/data\[/g, "").replace(/]/g, "");
newList[name] = v.value;
});
// 内容校验列表
let defaultRule = [
{name: 'uid', checkType: 'required', errorMsg: '请选择充值用户'},
{name: 'recharge_money', checkType: 'required', errorMsg: '请输入充值数量'},
];
let result = util.verify(newList,defaultRule);
return result === true;
})
})
</script>