企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
``` ALTER TABLE `ims_ewei_shop_commission_level` ADD COLUMN `fhbi` decimal(11,2) NULL DEFAULT 0 , ADD COLUMN `tmshopprice` decimal(11,2) NULL DEFAULT 0 , ADD COLUMN `tmshopprices` decimal(11,2) NULL DEFAULT 0 AFTER `tmshopprice`, ADD COLUMN `fftime` int(11) NULL DEFAULT 0 AFTER `tmshopprices`; //页面设置 $dataset = m("common")->getPluginset("commission"); <div class="form-group"> <label class="col-lg control-label">全球业绩分红比例</label> <div class="col-sm-9 col-xs-12"> <div class="input-group fixmore-input-group"> <input type="text" name="data[fhbi]" class="form-control" value="{$data['fhbi']}" /> <div class="input-group-addon">%</div> </div> <span class="help-block">按全部业绩的N%分红</span> </div> </div> //agent.html <a class="btn-default btn-sm btn-op " style="color:balck;" type="button" data-toggle='batch-batch' data-confirm="昨日商城总销售额为{php echo empty($totalprice) ? 0 : $totalprice}元,奖金池为{php echo $totalbouns}元,确认要发放分红?" data-href="{php echo webUrl('commission/agent/ffbouns')}"> <i class='icow icow-shenhetongguo'></i> 发放昨日分红 </a> //列表操作 <a class="btn btn-op btn-operation" data-toggle='ajaxPost' href="{php echo webUrl('commission/agent/uptm',array('id' => $row['id']));}" target='_blank'> <span data-toggle="tooltip" data-placement="top" title="" data-original-title="更新团队人数"> <i class='icow icow-bianji2'></i> </span> </a> //level.heml <div class="page-toolbar"> <a class="btn-primary btn-sm btn-op " type="button" data-toggle='batch-batch' data-confirm="确认要发放分红?" data-href="{php echo webUrl('commission/level/ffbouns')}"> <i class='icow icow-shenhetongguo'></i> 发放商城分红 </a> 当前平台可发放销售额为{$others[0]['tmshopprice']}元,上次发放时间为{php echo date("Y-m-d H:i", $others[0]["fftime"])}。 </div> //团队分红 $tmprice = $agentuser['tmprice']+$orderprice; pdo_update('ewei_shop_member', array('tmprice'=>$tmprice), array('id' => $member['id'])); public function ffbouns() { global $_W; global $_GPC; $members = pdo_fetchall("SELECT * FROM " . tablename("ewei_shop_member") . " WHERE status = 1 and isagent = 1 and agentlevel>0 and tmshopprice>0 and uniacid=" . $_W["uniacid"]); if(empty($members)){ show_json(0, '暂无代理商需要分红!'); } $bounsdata = array( 'addtime' => time(), 'status' => 1, 'type' => 1, 'note' => '团队分红', ); foreach( $members as $member ) { $bounsdata['totalprice'] = $member['tmshopprice']; $bounsdata['memberid'] = $member['id']; $level = $this->model->getLevel($member['openid']); $bounsdata['mcommission'] = round($member['tmshopprice']*$level['tmbi']/100,2); if($bounsdata['mcommission']>0){ pdo_insert("ewei_shop_agentbouns", $bounsdata); pdo_update('ewei_shop_member', array('tmshopprice'=>0,'tmshopprices'=>$member['tmshopprices']+$member['tmshopprice']), array('id' => $member['id'])); } } show_json(1, '所有分红已成功发放!'); } //奖金池分红 public function ffbouns() { global $_W; global $_GPC; global $_S; $set = $_S['commission']; $fhbi = (int)$set['fhbi']; $level = pdo_fetch("select * from " . tablename("ewei_shop_commission_level") . " where id=1"); if($level['tmshopprice']<=0){ show_json(0, '可发放金额为空!'); } $members = pdo_fetchall("SELECT id FROM " . tablename("ewei_shop_member") . " WHERE status = 1 and isagent = 1 and agentlevel=4 and uniacid=" . $_W["uniacid"]); $mcount = count($members); if($mcount>0){ $bounsdata = array( 'addtime' => time(), 'status' => 1, 'type' => 3, 'note' => '全球业绩分红', ); $bounsdata['mcommission'] = round($level['tmshopprice']*$fhbi/$mcount/100,2); if($bounsdata['mcommission']>0){ foreach( $members as $member ) { $bounsdata['memberid'] = $member['id']; pdo_insert("ewei_shop_agentbouns", $bounsdata); } } }else{ show_json(0, '暂无分销商需要发放!'); } pdo_update('ewei_shop_commission_level', array('tmshopprice'=>0,'fftime'=>time()), array('id' => 1)); show_json(1, '成功发放!本次发放人数为'.$mcount.'人'); } ```