新增双向增值
This commit is contained in:
parent
31684afd8b
commit
78de3aadd3
|
|
@ -81,6 +81,29 @@ class PluginApplication extends \app\common\services\PluginApplication{
|
|||
],
|
||||
]
|
||||
],
|
||||
'plugin_cultural_space_fund_pool' => [
|
||||
'name' => '基金池',
|
||||
'permit' => 1,
|
||||
'menu' => 1,
|
||||
'icon' => '',
|
||||
'url' => 'plugin.cultural-space.admin.fund.index',
|
||||
'url_params' => '',
|
||||
'item' => 'plugin_cultural_space_fund',
|
||||
'parents' => ['cultural-space'],
|
||||
'child' => [
|
||||
// 权限补充
|
||||
'plugin_cultural_space_fund_index' => [
|
||||
'name' => '基金池',
|
||||
'url' => 'plugin.cultural-space.admin.fund.index',
|
||||
'url_params' => '',
|
||||
'permit' => 1,
|
||||
'menu' => 0,
|
||||
'icon' => '',
|
||||
'item' => 'plugin_cultural_space_fund_index',
|
||||
'parents' => ['cultural-space','plugin_cultural_space_fund']
|
||||
],
|
||||
]
|
||||
],
|
||||
'plugin_cultural_space_set' => [
|
||||
'name' => '基本设置',
|
||||
'permit' => 1,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
namespace Yunshop\CulturalSpace\admin;
|
||||
use app\common\components\BaseController;
|
||||
use app\common\facades\Setting;
|
||||
use Yunshop\CulturalSpace\models\CulturalFund;
|
||||
use Yunshop\CulturalSpace\models\CulturalOrderFundLog;
|
||||
use Yunshop\CulturalSpace\models\CulturalSpace;
|
||||
class FundController extends BaseController
|
||||
{
|
||||
|
||||
|
||||
public function test(){
|
||||
$n=2000;
|
||||
// for($i=0;$i<=$n;$n--){
|
||||
// $result =(new CulturalSpace())->GiveGoodsFundMoney(22,93);
|
||||
// }
|
||||
|
||||
// $result =(new CulturalSpace())->GiveGoodsFundMoney(22,93);
|
||||
|
||||
$set = Setting::get('plugin.cultural_space_set');
|
||||
$result =(new CulturalSpace())->capitalIncrease($set);
|
||||
|
||||
var_dump($result);
|
||||
}
|
||||
|
||||
public function index(){
|
||||
return view('Yunshop\CulturalSpace::fund.index')->render();
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 获取基金统计
|
||||
* @return void
|
||||
*/
|
||||
public function getfund(){
|
||||
$result =CulturalFund::getfund();
|
||||
return $this->successJson('成功',$result);
|
||||
}
|
||||
|
||||
/***
|
||||
* 获取基金记录
|
||||
* @return void
|
||||
*/
|
||||
public function getfundRecord(){
|
||||
$search = request()->input('search');
|
||||
$result =CulturalOrderFundLog::getList($search);
|
||||
return $this->successJson('成功',$result);
|
||||
}
|
||||
}
|
||||
|
|
@ -7,24 +7,18 @@ use app\common\events\order\AfterOrderPaidEvent;
|
|||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Yunshop\CulturalSpace\models\CulturalSpace;
|
||||
|
||||
use Yunshop\CulturalSpace\models\CulturalFund;
|
||||
class OrderPaidListener{
|
||||
|
||||
use DispatchesJobs;
|
||||
|
||||
public function subscribe(Dispatcher $events){
|
||||
$events->listen(AfterOrderPaidEvent::class, self::class . '@handle');
|
||||
}
|
||||
|
||||
public function handle(AfterOrderPaidEvent $event){
|
||||
date_default_timezone_set("PRC");
|
||||
$model = $event->getOrderModel();
|
||||
// 订单支付成功奖励贡献值
|
||||
(new CulturalSpace())->buyGoodsGiveContribution($model->uid,$model->id);
|
||||
(new CulturalSpace())->GiveGoodsFundMoney($model->uid,$model->id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
namespace Yunshop\CulturalSpace\models;
|
||||
use app\common\facades\Setting;
|
||||
use app\common\models\BaseModel;
|
||||
class CulturalFund extends BaseModel
|
||||
{
|
||||
public $table = 'yz_cultural_fund';
|
||||
public $timestamps = true;
|
||||
public $casts = [
|
||||
'created_at' => 'datetime:Y-m-d H:i:s',
|
||||
'updated_at' => 'datetime:Y-m-d H:i:s',
|
||||
];
|
||||
public function getfund(){
|
||||
$result = self::uniacid()
|
||||
->first();
|
||||
if(empty($result)){
|
||||
$set = Setting::get('plugin.cultural_space_set');
|
||||
$result=[
|
||||
'uniacid'=>\YunShop::app()->uniacid,
|
||||
'last_fee'=>$set['fund_start_price'],
|
||||
'current_fee'=>$set['fund_start_price'],
|
||||
'fund_money'=>0,
|
||||
'voucher_number'=>0,
|
||||
'history_number'=>0,
|
||||
'created_at'=>time(),
|
||||
'updated_at'=>time()
|
||||
];
|
||||
self::insert($result);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/***
|
||||
* 保存数据
|
||||
* @param $data
|
||||
* @return bool
|
||||
*
|
||||
*/
|
||||
public function SaveData($data){
|
||||
$result = self::uniacid()
|
||||
->update($data);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
namespace Yunshop\CulturalSpace\models;
|
||||
use app\common\facades\Setting;
|
||||
use app\common\models\BaseModel;
|
||||
class CulturalFundIncrease extends BaseModel
|
||||
{
|
||||
public $table = 'yz_cultural_fund_increase_log';
|
||||
public $timestamps = true;
|
||||
public $casts = [
|
||||
'created_at' => 'datetime:Y-m-d H:i:s',
|
||||
'updated_at' => 'datetime:Y-m-d H:i:s',
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
namespace Yunshop\CulturalSpace\models;
|
||||
use app\common\models\BaseModel;
|
||||
use app\common\models\Member;
|
||||
class CulturalOrderFundLog extends BaseModel
|
||||
{
|
||||
public $table = 'yz_goods_cultural_order_fund_log';
|
||||
public $timestamps = true;
|
||||
public $casts = [
|
||||
'created_at' => 'datetime:Y-m-d H:i:s',
|
||||
'updated_at' => 'datetime:Y-m-d H:i:s',
|
||||
];
|
||||
public function getList($search=[]){
|
||||
$where = [];
|
||||
if($search['member_id'] > 0) $where[] = ['member_id','=',$search['member_id']];
|
||||
$result = self::uniacid()
|
||||
->where($where)
|
||||
->with([
|
||||
'member' => function($query){
|
||||
$query->select(['uid','nickname','realname','avatar']);
|
||||
}
|
||||
])
|
||||
->orderBy('created_at','DESC')
|
||||
->orderBy('id','DESC')
|
||||
->paginate(10);
|
||||
return $result ? $result->toArray() : [];
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 写入日记
|
||||
* @param $data
|
||||
* @return BaseModel
|
||||
*/
|
||||
public static function InsertLog($data){
|
||||
$data['uniacid'] = \YunShop::app()->uniacid;
|
||||
$data['created_at'] = time();
|
||||
$data['updated_at'] = time();
|
||||
return self::insert($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Common: 一对一关联 用户信息
|
||||
* Author: wu-hui
|
||||
* Time: 2023/11/03 9:35
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function member(){
|
||||
return $this->hasOne(Member::class,'uid','member_id');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +1,13 @@
|
|||
<?php
|
||||
namespace Yunshop\CulturalSpace\models;
|
||||
|
||||
|
||||
use app\common\facades\Setting;
|
||||
use app\common\models\BaseModel;
|
||||
use app\common\models\Member;
|
||||
use app\common\models\member\MemberParent;
|
||||
use app\common\models\OrderGoods;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CulturalSpace extends BaseModel{
|
||||
class CulturalSpace extends BaseModel
|
||||
{
|
||||
|
||||
public $table = 'yz_cultural_space';
|
||||
public $timestamps = false;
|
||||
|
|
@ -27,27 +25,28 @@ class CulturalSpace extends BaseModel{
|
|||
* @param $search
|
||||
* @return array
|
||||
*/
|
||||
public function getList($search){
|
||||
public function getList($search)
|
||||
{
|
||||
// 条件生成
|
||||
$where = [];
|
||||
if($search['uid'] > 0) $where[] = ['uid','=',$search['uid']];
|
||||
if ($search['uid'] > 0) $where[] = ['uid', '=', $search['uid']];
|
||||
// 查询model
|
||||
$model = self::uniacid()
|
||||
->where($where)
|
||||
->with([
|
||||
'member' => function($query){
|
||||
$query->select(['uid','nickname','realname','avatar']);
|
||||
'member' => function ($query) {
|
||||
$query->select(['uid', 'nickname', 'realname', 'avatar']);
|
||||
}
|
||||
]);
|
||||
// 信息获取
|
||||
$totalContribution = $model->sum('contribution');
|
||||
$list = $model->select(['id','uid','contribution'])
|
||||
->orderBy('id','DESC')
|
||||
$list = $model->select(['id', 'uid', 'contribution'])
|
||||
->orderBy('id', 'DESC')
|
||||
->paginate(10)
|
||||
->toArray();
|
||||
foreach($list['data'] as &$item){
|
||||
$item['total_proportion'] = (float)sprintf("%.2f",$totalContribution);
|
||||
$item['ratio'] = (float)sprintf("%.2f",$item['contribution'] / $totalContribution * 100);
|
||||
foreach ($list['data'] as &$item) {
|
||||
$item['total_proportion'] = (float)sprintf("%.2f", $totalContribution);
|
||||
$item['ratio'] = (float)sprintf("%.2f", $item['contribution'] / $totalContribution * 100);
|
||||
}
|
||||
|
||||
return $list;
|
||||
|
|
@ -61,47 +60,48 @@ class CulturalSpace extends BaseModel{
|
|||
* @param $uid
|
||||
* @param $orderId
|
||||
*/
|
||||
public function buyGoodsGiveContribution($uid,$orderId){
|
||||
\Log::debug('文创空间 - 购买商品奖励贡献值',['uid' => $uid,'order_id' => $orderId]);
|
||||
public function buyGoodsGiveContribution($uid, $orderId)
|
||||
{
|
||||
\Log::debug('文创空间 - 购买商品奖励贡献值', ['uid' => $uid, 'order_id' => $orderId]);
|
||||
DB::beginTransaction();
|
||||
try{
|
||||
try {
|
||||
$set = Setting::get('plugin.cultural_space_set');
|
||||
if($set['is_give_contribution'] != 1 || (float)$set['contribution_ratio'] <= 0) throw new \Exception('文创空间 - 购买商品奖励贡献值 - 未开启贡献值奖励或者奖励比例为0');
|
||||
if ($set['is_give_contribution'] != 1 || (float)$set['contribution_ratio'] <= 0) throw new \Exception('文创空间 - 购买商品奖励贡献值 - 未开启贡献值奖励或者奖励比例为0');
|
||||
// 获取直推上级id && 获取订单商品信息
|
||||
$parentUid = (int)MemberParent::getParentId($uid);
|
||||
$orderGoodsList = (array)$this->getGoodsModel($orderId)
|
||||
->where('yz_goods_cultural_space.is_give_contribution',1)
|
||||
->where('yz_goods_cultural_space.is_give_contribution', 1)
|
||||
->get()
|
||||
->makeHidden(['buttons','after_sales','order'])
|
||||
->makeHidden(['buttons', 'after_sales', 'order'])
|
||||
->toArray();
|
||||
if(count($orderGoodsList) <= 0) throw new \Exception('文创空间 - 购买商品奖励贡献值 - 无奖励商品信息');
|
||||
if (count($orderGoodsList) <= 0) throw new \Exception('文创空间 - 购买商品奖励贡献值 - 无奖励商品信息');
|
||||
// 获取文创空间用户信息
|
||||
$memberList = $parentUid <= 0 ? $this->getCulturalSpace([$uid]) : $this->getCulturalSpace([$uid,$parentUid]);
|
||||
$userName = Member::getMemberById($uid,['realname','nickname'])->username ?? '';
|
||||
$memberList = $parentUid <= 0 ? $this->getCulturalSpace([$uid]) : $this->getCulturalSpace([$uid, $parentUid]);
|
||||
$userName = Member::getMemberById($uid, ['realname', 'nickname'])->username ?? '';
|
||||
// 循环商品处理奖励贡献值
|
||||
$changeList = [];
|
||||
foreach($orderGoodsList as $goodsInfo){
|
||||
foreach ($orderGoodsList as $goodsInfo) {
|
||||
// 计算奖励贡献值
|
||||
$contribution = (float)sprintf('%.2f',$goodsInfo['payment_amount'] * (float)$set['contribution_ratio'] / 100);
|
||||
if($contribution > 0){
|
||||
foreach($memberList as $memberInfo){
|
||||
$contribution = (float)sprintf('%.2f', $goodsInfo['payment_amount'] * (float)$set['contribution_ratio'] / 100);
|
||||
if ($contribution > 0) {
|
||||
foreach ($memberList as $memberInfo) {
|
||||
// 用户当前持有数量
|
||||
$changeFront = (float)$memberList[$memberInfo['uid']]['contribution'];
|
||||
// 变更后的数量
|
||||
$changeAfter = (float)sprintf("%.2f",$changeFront + $contribution);
|
||||
$changeAfter = (float)sprintf("%.2f", $changeFront + $contribution);
|
||||
// 记录变更信息
|
||||
$changeList[] = [
|
||||
'uniacid' => $goodsInfo['uniacid'],
|
||||
'uid' => $memberInfo['uid'],
|
||||
'goods_id' => $goodsInfo['goods_id'],
|
||||
'order_id' => $orderId,
|
||||
'order_goods_id' => $goodsInfo['id'],
|
||||
'change_type' => 1,
|
||||
'uniacid' => $goodsInfo['uniacid'],
|
||||
'uid' => $memberInfo['uid'],
|
||||
'goods_id' => $goodsInfo['goods_id'],
|
||||
'order_id' => $orderId,
|
||||
'order_goods_id' => $goodsInfo['id'],
|
||||
'change_type' => 1,
|
||||
'change_quantity' => $contribution,
|
||||
'change_front' => $changeFront,
|
||||
'change_after' => $changeAfter,
|
||||
'remark' => ($memberInfo['uid'] == $uid ? '' : "【{$userName}】") . "购买商品【{$goodsInfo['title']}】赠送",
|
||||
'created_at' => time(),
|
||||
'change_front' => $changeFront,
|
||||
'change_after' => $changeAfter,
|
||||
'remark' => ($memberInfo['uid'] == $uid ? '' : "【{$userName}】") . "购买商品【{$goodsInfo['title']}】赠送",
|
||||
'created_at' => time(),
|
||||
];
|
||||
// 刷新持有处理
|
||||
$memberList[$memberInfo['uid']]['contribution'] = $changeAfter;
|
||||
|
|
@ -109,19 +109,129 @@ class CulturalSpace extends BaseModel{
|
|||
}
|
||||
}
|
||||
// 数据操作
|
||||
if(count($changeList) > 0) {
|
||||
$this->batchUpdate($memberList,'uid','uid');
|
||||
if (count($changeList) > 0) {
|
||||
$this->batchUpdate($memberList, 'uid', 'uid');
|
||||
ContributionLog::insert($changeList);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
}catch(\Exception $e){
|
||||
\Log::debug('文创空间 - 购买商品奖励贡献值 - 错误抛出',$e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
\Log::debug('文创空间 - 购买商品奖励贡献值 - 错误抛出', $e->getMessage());
|
||||
DB::rollBack();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/***
|
||||
* 计算基金比例
|
||||
* @param $uid
|
||||
* @param $orderId
|
||||
* @return void
|
||||
*/
|
||||
public function GiveGoodsFundMoney($uid, $orderId)
|
||||
{
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$set = Setting::get('plugin.cultural_space_set');
|
||||
if ($set['is_fund_open'] == 1) {
|
||||
// 获取直推上级id && 获取订单商品信息
|
||||
$orderGoodsList = $this->getGoodsModel($orderId)
|
||||
->where('yz_goods_cultural_space.is_fund_open', 1)
|
||||
->get()
|
||||
->makeHidden(['buttons', 'after_sales', 'order'])
|
||||
->toArray();
|
||||
if (count($orderGoodsList) <= 0) throw new \Exception('文创空间 - 购买商品奖励贡献值 - 无奖励商品信息');
|
||||
$current_fee = $set['fund_start_price']; //当前价格
|
||||
$last_fee = $current_fee;
|
||||
$fund_money = 0;
|
||||
$voucher_number = 0;
|
||||
$history_number = 0;
|
||||
$history_fund_money = 0;
|
||||
$fundInfo = CulturalFund::getfund();
|
||||
if ($fundInfo) {
|
||||
$current_fee = $fundInfo['current_fee'];
|
||||
$last_fee = $current_fee;
|
||||
$fund_money = $fundInfo['fund_money'];
|
||||
$voucher_number = $fundInfo['voucher_number'];
|
||||
$history_number = $fundInfo['history_number'];
|
||||
$history_fund_money = $fundInfo['history_fund_money'];
|
||||
}
|
||||
$user_voucher_number = 0;//用户凭证数量
|
||||
$user_voucher_total = 0;//用户总计凭证数量
|
||||
foreach ($orderGoodsList as $goodsInfo) {
|
||||
$user_voucher_number = (($goodsInfo['payment_amount'] * $set['user_fund_ratio']) / 100) / $current_fee; //赠送数量
|
||||
$user_fund_money = round(($goodsInfo['payment_amount'] * $set['order_fund_ratio']) / 100, 2);//资金数量
|
||||
$fund_money += $user_fund_money;
|
||||
$user_voucher_total += $user_voucher_number;
|
||||
$voucher_number += $user_voucher_number;
|
||||
$history_number += $user_voucher_number;
|
||||
$history_fund_money += $user_fund_money;
|
||||
$data_log = [
|
||||
'member_id' => $uid,
|
||||
'order_id' => $orderId,
|
||||
'goods_id' => $goodsInfo['goods_id'],
|
||||
'good_name' => $goodsInfo['title'],
|
||||
'pay_money' => $goodsInfo['payment_amount'],
|
||||
'fund_money' => $user_fund_money,
|
||||
'voucher_number' => $user_voucher_number,
|
||||
'current_fee' => $current_fee,
|
||||
];
|
||||
CulturalOrderFundLog::InsertLog($data_log); //写入日记
|
||||
}
|
||||
$this->where('uid', $uid)->increment('voucher_number', $user_voucher_total);//用户增量
|
||||
$next_fee = round($fund_money / $voucher_number, 2);
|
||||
$FundData = [
|
||||
'last_fee' => $last_fee,
|
||||
'current_fee' => $next_fee,
|
||||
'fund_money' => $fund_money,
|
||||
'voucher_number' => $voucher_number,
|
||||
'history_number' => $history_number,
|
||||
'history_fund_money' => $history_fund_money,
|
||||
];
|
||||
$culturalFund = new CulturalFund();
|
||||
$culturalFund->SaveData($FundData);
|
||||
if ($user_voucher_number <= $set['min_number']) {
|
||||
$this->capitalIncrease($set);//小于数量增加积分倍数
|
||||
}
|
||||
// 获取文创空间用户信息
|
||||
// 数据操作
|
||||
DB::commit();
|
||||
} else {
|
||||
DB::rollBack();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* 增加资本
|
||||
* @return void
|
||||
*/
|
||||
public function capitalIncrease($config){
|
||||
$uniacid=\YunShop::app()->uniacid;
|
||||
$this->where('uniacid', $uniacid) ->update(
|
||||
[
|
||||
'voucher_number' => DB::raw('voucher_number * '.$config['fund_multiple']),
|
||||
]
|
||||
); //增加会员资本
|
||||
$culturalFund = new CulturalFund();
|
||||
$data=$culturalFund->where('uniacid', $uniacid)->first()->toArray();
|
||||
$data['up_voucher_number']=$data['voucher_number']*$config['fund_multiple'];
|
||||
$data['up_current_fee']=$data['current_fee']/$config['fund_multiple'];
|
||||
$data['fund_multiple']=$config['fund_multiple'];
|
||||
$data['created_at']=time();
|
||||
$data['updated_at']=time();
|
||||
unset($data['id']);
|
||||
DB::table('yz_cultural_fund_increase_log')->insert($data);
|
||||
$culturalFund->where('uniacid', $uniacid)->update( //增加资本数量
|
||||
[
|
||||
'voucher_number' => DB::raw('voucher_number * '.$config['fund_multiple']),
|
||||
'history_number' => DB::raw('history_number * '.$config['fund_multiple']),
|
||||
'current_fee' => DB::raw('current_fee /'.$config['fund_multiple']),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Common: 获取订单商品查询model
|
||||
* Author: wu-hui
|
||||
|
|
@ -129,7 +239,8 @@ class CulturalSpace extends BaseModel{
|
|||
* @param $orderId
|
||||
* @return mixed
|
||||
*/
|
||||
private function getGoodsModel($orderId){
|
||||
private function getGoodsModel($orderId)
|
||||
{
|
||||
return OrderGoods::uniacid()
|
||||
->select([
|
||||
'yz_order_goods.id',
|
||||
|
|
@ -140,9 +251,10 @@ class CulturalSpace extends BaseModel{
|
|||
'yz_order_goods.payment_amount',
|
||||
])
|
||||
->leftJoin('yz_goods_cultural_space', 'yz_goods_cultural_space.goods_id', 'yz_order_goods.goods_id')
|
||||
->where('yz_order_goods.order_id',$orderId)
|
||||
->where('yz_goods_cultural_space.is_open',1);
|
||||
->where('yz_order_goods.order_id', $orderId)
|
||||
->where('yz_goods_cultural_space.is_open', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Common: 根据用户ids获取用户文创空间相关信息(如果不存在则添加默认信息并且返回默认信息)
|
||||
* Author: wu-hui
|
||||
|
|
@ -150,51 +262,49 @@ class CulturalSpace extends BaseModel{
|
|||
* @param $ids
|
||||
* @return array
|
||||
*/
|
||||
private function getCulturalSpace($ids){
|
||||
private function getCulturalSpace($ids)
|
||||
{
|
||||
// 获取已经存在的信息
|
||||
$list = self::uniacid()
|
||||
->select(['id','uid','contribution'])
|
||||
->whereIn('uid',$ids)
|
||||
->select(['id', 'uid', 'contribution'])
|
||||
->whereIn('uid', $ids)
|
||||
->get()
|
||||
->keyBy('uid')
|
||||
->toArray();
|
||||
// 循环处理:不存在则添加,并且赋值默认值;存在则使用已经存在的信息
|
||||
$memberList = [];
|
||||
$insertData = [];
|
||||
foreach($ids as $userId){
|
||||
if($list[$userId]){
|
||||
foreach ($ids as $userId) {
|
||||
if ($list[$userId]) {
|
||||
// 存在
|
||||
$memberList[$userId] = $list[$userId];
|
||||
}else{
|
||||
} else {
|
||||
// 不存在
|
||||
$insertData[] = [
|
||||
'uniacid' => \YunShop::app()->uniacid,
|
||||
'uid' => $userId,
|
||||
'uid' => $userId,
|
||||
];
|
||||
$memberList[$userId] = [
|
||||
'uniacid' => \YunShop::app()->uniacid,
|
||||
'uid' => $userId,
|
||||
'uniacid' => \YunShop::app()->uniacid,
|
||||
'uid' => $userId,
|
||||
'contribution' => 0
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if($insertData) self::insert($insertData);
|
||||
if ($insertData) self::insert($insertData);
|
||||
|
||||
return $memberList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Common: 一对一关联 用户信息
|
||||
* Author: wu-hui
|
||||
* Time: 2023/11/03 9:35
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function member(){
|
||||
return $this->hasOne(Member::class,'uid','uid');
|
||||
public function member()
|
||||
{
|
||||
return $this->hasOne(Member::class, 'uid', 'uid');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class GoodsCulturalSpace extends BaseModel{
|
|||
$info->goods_id = $goodsId;// 商品ID
|
||||
$info->is_open = $data['is_open'] ?? 0;// 当前商品是否参与文创空间:0=未开启,1=开启
|
||||
$info->is_give_contribution = $data['is_give_contribution'] ?? 0;// 是否赠送贡献值:0=不赠送,1=赠送
|
||||
|
||||
$info->is_fund_open = $data['is_fund_open'] ?? 0;// 是否开启基金
|
||||
|
||||
|
||||
return $info->save();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,235 @@
|
|||
@extends('layouts.base')
|
||||
<style>
|
||||
.user{
|
||||
display: inline-flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
overflow: hidden;
|
||||
height: 80px;
|
||||
}
|
||||
.user .user-avatar{
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
margin-right: 5px;
|
||||
border-radius: 50%;
|
||||
overflow: hidden;
|
||||
}
|
||||
.user .user-avatar .avatar-image{
|
||||
width: 100% !important;
|
||||
height: 100% !important;
|
||||
}
|
||||
.user .user-info{
|
||||
height: 50px;
|
||||
text-align: left;
|
||||
}
|
||||
.user .user-info .user-nickname{
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.user .user-info .user-status{
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.level_0{
|
||||
background-color: #5bc0de!important;
|
||||
}
|
||||
.level_1{
|
||||
background-color: #f0ad4e!important;
|
||||
}
|
||||
.level_2{
|
||||
background-color: #5cb85c!important;
|
||||
}
|
||||
.level_3{
|
||||
background-color: #337ab7!important;
|
||||
}
|
||||
.level_4{
|
||||
background-color: #d9534f!important;
|
||||
}
|
||||
.panel-body .label{
|
||||
display: inline-block;
|
||||
margin-bottom: 2px;
|
||||
border-radius: 2px;
|
||||
font-size: 14px!important;
|
||||
padding: 5px !important;
|
||||
text-transform: uppercase;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
.el-pagination{
|
||||
text-align: right!important;
|
||||
margin-top: 20px!important;
|
||||
}
|
||||
.panel-body{
|
||||
padding-top: 0;
|
||||
margin-bottom: 30px;
|
||||
overflow: auto;
|
||||
padding-right: 30px;
|
||||
}
|
||||
</style>
|
||||
@section('content')
|
||||
<div class="w1200 m0a" id="weightValueIndexContent">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<el-tabs v-model="tabs_active" @tab-click="changeTabs">
|
||||
<el-tab-pane label="基金统计" name="show_detail">
|
||||
<el-row>
|
||||
<el-col :span="4">
|
||||
<div class="grid-content bg-purple">基金总数:[[fundData.fund_money || 0]]</div>
|
||||
</el-col>
|
||||
<el-col :span="4"><div class="grid-content bg-purple-light">凭证总数:[[fundData.voucher_number || 0]]</div></el-col>
|
||||
<el-col :span="4"><div class="grid-content bg-purple">当前价值:[[fundData.current_fee || 0]]</div></el-col>
|
||||
<el-col :span="4"><div class="grid-content bg-purple-light">上次价值:[[fundData.last_fee || 0]]</div></el-col>
|
||||
<el-col :span="4"><div class="grid-content bg-purple-light">历史基金:[[fundData.history_fund_money || 0]]</div></el-col>
|
||||
<el-col :span="4"><div class="grid-content bg-purple-light">历史凭证:[[fundData.history_number || 0]]</div></el-col>
|
||||
</el-row>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="明细" name="show_group">
|
||||
{{--搜索--}}
|
||||
<el-form :inline="true" :model="search_list">
|
||||
<el-form-item label="会员ID">
|
||||
<el-input v-model="search_list.member_id" placeholder="请输入会员ID"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="clickSearch">查询</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
{{--表单--}}
|
||||
<el-table :data="list" style="width: 100%">
|
||||
<el-table-column align="center" prop="id" label="ID" width="100"></el-table-column>
|
||||
<el-table-column align="center" prop="member" label="商品名称" width="300">
|
||||
<template slot-scope="scope">
|
||||
<div class="user">
|
||||
<div class="user-avatar">
|
||||
<img class="avatar-image" :src="scope.row.member.avatar_image || ''" />
|
||||
</div>
|
||||
<div class="user-info">
|
||||
<div class="user-nickname">昵称:[[scope.row.member.nickname || '']]</div>
|
||||
<div class="user-status">ID:[[scope.row.member.uid || '']]</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" prop="pay_money" label="订单金额"></el-table-column>
|
||||
<el-table-column align="center" prop="fund_money" label="入账基金"></el-table-column>
|
||||
<el-table-column align="center" prop="voucher_number" label="用户凭证"> </el-table-column>
|
||||
<el-table-column align="center" prop="created_at" label="创建时间"> </el-table-column>
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
{{--分页--}}
|
||||
<el-pagination
|
||||
v-if="total_page > 1"
|
||||
background
|
||||
layout="prev, pager, next"
|
||||
:page-count="total_page"
|
||||
:current-page="page"
|
||||
@current-change="changePage">
|
||||
</el-pagination>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
new Vue({
|
||||
el: '#weightValueIndexContent',
|
||||
delimiters: ['[[', ']]'],
|
||||
name: 'cultural_space_index_content',
|
||||
data: {
|
||||
fundData:[],
|
||||
tabs_active: 'show_detail',
|
||||
level_list: JSON.parse('{!! json_encode($level_list) !!}'),
|
||||
// 分页信息
|
||||
page: 1,
|
||||
total_page: 1,
|
||||
list: [],
|
||||
search_list: {
|
||||
member_id: '',
|
||||
team_dividend_agency_level_id: '',
|
||||
change_type: '',
|
||||
}
|
||||
},
|
||||
watch:{},
|
||||
mounted () {
|
||||
this.getData();
|
||||
},
|
||||
methods: {
|
||||
// 获取数据 根据当前选项卡获取对应的信息
|
||||
getData(){
|
||||
let _this = this;
|
||||
let loading = _this.showLoading();
|
||||
let link = "{!! yzWebUrl('plugin.cultural-space.admin.fund.getfund') !!}";
|
||||
if(_this.tabs_active === 'show_group') link = "{!! yzWebUrl('plugin.cultural-space.admin.fund.getfundRecord') !!}";
|
||||
$.ajax({
|
||||
url: link,
|
||||
type: "post",
|
||||
data: {
|
||||
page: _this.page,
|
||||
search: _this.search_list,
|
||||
is_get: 1
|
||||
},
|
||||
success: function(result) {
|
||||
loading.close(0);
|
||||
let data = result.data;
|
||||
console.log(data)
|
||||
if(parseInt(result.result) === 1){
|
||||
// 处理数据
|
||||
_this.list = data.data;
|
||||
_this.total_page = data.last_page;
|
||||
}else {
|
||||
this.fundData= data;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
// 切换选项卡
|
||||
changeTabs(){
|
||||
this.page = 1;
|
||||
this.search_list = {
|
||||
member_id: '',
|
||||
team_dividend_agency_level_id: '',
|
||||
change_type: '',
|
||||
};
|
||||
this.total_page = 1;
|
||||
this.list = [];
|
||||
this.getData();
|
||||
},
|
||||
// 数据分页
|
||||
changePage(val){
|
||||
this.page = val;
|
||||
this.getData();
|
||||
},
|
||||
// 相关搜索
|
||||
clickSearch(){
|
||||
this.page = 1;
|
||||
this.getData()
|
||||
},
|
||||
// 显示加载动画
|
||||
showLoading(){
|
||||
return this.$loading({
|
||||
lock: true,
|
||||
text: 'Loading',
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.7)'
|
||||
});
|
||||
},
|
||||
// 查看分组的变更明细
|
||||
seeDetail(member_id,level_id){
|
||||
let link = "{{yzWebUrl('plugin.cultural-space.admin.index.changeRecord')}}" + `&member_id=${member_id}&level_id=${level_id}`;
|
||||
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>
|
||||
@endsection
|
||||
|
||||
|
|
@ -42,11 +42,67 @@
|
|||
<div class="form-item_tips">周期销售额的N%用作分红总金额,根据每个人当前贡献值比例进行分红;0或者空则无贡献值奖励</div>
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
||||
<div class="vue-main-title">
|
||||
<div class="vue-main-title-left"></div>
|
||||
<div class="vue-main-title-content">基金规则</div>
|
||||
</div>
|
||||
<div class="vue-main-form">
|
||||
<el-form-item label="开启基金" prop="is_fund_open">
|
||||
<div style="line-height:40px">
|
||||
<el-radio v-model.number="set.is_fund_open" :label="0">不开启</el-radio>
|
||||
<el-radio v-model.number="set.is_fund_open" :label="1">开启</el-radio>
|
||||
</div>
|
||||
<div class="form-item_tips">基金池能力</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="基金入账比例" prop="order_fund_ratio">
|
||||
<el-input type="number" placeholder="基金池基金成交入账比例" v-model.number="set.order_fund_ratio" step="30">
|
||||
<template slot="append">%</template>
|
||||
</el-input>
|
||||
<div class="form-item_tips">基金池基金用户订单成交订单金额比例纳入基金池</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="起始价格" prop="fund_start_price">
|
||||
<el-input type="number" placeholder="起始价格" v-model.number="set.fund_start_price" step="0.5">
|
||||
<template slot="append">元</template>
|
||||
</el-input>
|
||||
<div class="form-item_tips">用户订单成交第一笔订单计算价格</div>
|
||||
</el-form-item>
|
||||
|
||||
|
||||
<el-form-item label="文豆赠送比例" prop="user_fund_ratio">
|
||||
<el-input type="number" placeholder="收益比例" v-model.number="set.user_fund_ratio" step="10">
|
||||
<template slot="append">%</template>
|
||||
</el-input>
|
||||
<div class="form-item_tips">用户购买商品活动赠送文创豆数量比例 《消费额度ⅹ赠送10%÷价格》</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="兑换余额比例" prop="balance_ratio">
|
||||
<el-input type="number" placeholder="余额兑换比例" v-model.number="set.balance_ratio" step="8">
|
||||
<template slot="append">%</template>
|
||||
</el-input>
|
||||
<div class="form-item_tips">用户将文创豆兑换余额比例</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="最小赠送" prop="min_number">
|
||||
<el-input type="number" placeholder="赠送最小个数" v-model.number="set.min_number" step="8">
|
||||
<template slot="append">个</template>
|
||||
</el-input>
|
||||
<div class="form-item_tips">当系统赠送积分小于当前数量时,系统将自动增值比例</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="增加倍数" prop="fund_multiple">
|
||||
<el-input type="number" placeholder="增加倍数" v-model.number="set.fund_multiple" step="10">
|
||||
<template slot="append">倍</template>
|
||||
</el-input>
|
||||
<div class="form-item_tips">当系统赠送积分小于指定数量,用户全局增长总量倍数</div>
|
||||
</el-form-item>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
{{--保存按钮--}}
|
||||
<el-form-item>
|
||||
<el-button type="primary" size="small" @click="onSubmit">保存</el-button>
|
||||
|
|
|
|||
|
|
@ -18,6 +18,15 @@ define({
|
|||
</el-form-item>
|
||||
</div>
|
||||
</template>
|
||||
<template >
|
||||
<div style="margin:0 auto;width:80%;">
|
||||
<el-form-item label="是否开启基金增值" label-width="155px">
|
||||
<el-radio v-model="json.is_fund_open" :label="0">不开启</el-radio>
|
||||
<el-radio v-model="json.is_fund_open" :label="1">开启</el-radio>
|
||||
<div class="form-item_tips">是否开启基金消费双向增值</div>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</template>
|
||||
</el-form>
|
||||
</div>
|
||||
`,
|
||||
|
|
@ -44,6 +53,7 @@ define({
|
|||
json: {
|
||||
is_open: 0,// 当前商品是否参与文创空间:0=未开启,1=开启
|
||||
is_give_contribution: 0,// 是否赠送贡献值:0=不赠送,1=赠送
|
||||
is_fund_open: 0,// 是否赠送贡献值:0=不赠送,1=赠送
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -55,6 +65,7 @@ define({
|
|||
console.log(cultural_space);
|
||||
this.json.is_open = cultural_space.is_open ? cultural_space.is_open : 0;
|
||||
this.json.is_give_contribution = cultural_space.is_give_contribution ? cultural_space.is_give_contribution : 0;
|
||||
this.json.is_fund_open = cultural_space.is_fund_open ? cultural_space.is_fund_open : 0;
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
|
|
|
|||
Loading…
Reference in New Issue