1.缺失信息提交

This commit is contained in:
2025-05-07 12:10:19 +08:00
parent 066c3c3420
commit 4da5dc858a
17 changed files with 2209 additions and 6 deletions

View File

@ -15,6 +15,7 @@
namespace app\common\logic;
use app\common\enum\user\AccountLogEnum;
use app\common\model\account\AccountLog;
use app\common\model\user\UserAccountLog;
use app\common\model\user\User;
@ -73,4 +74,62 @@ class AccountLogLogic extends BaseLogic
];
return UserAccountLog::create($data);
}
/**
* Notes:记录会员账户流水,如果变动类型是成长值,且是增加的,则调用更新会员等级方法。该方法应在添加用户账户后调用
* @author: cjh 2020/12/15 11:49
* @param int $user_id 用户id
* @param float $amount 变动数量
* @param int $change_type 变动类型1-增加2-减少
* @param int $source_type 来源类型
* @param string $remark 说明
* @param string $source_id 来源id
* @param string $source_sn 来源单号
* @param string $extra 额外字段说明
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function AccountRecord($user_id,$amount,$change_type,$source_type,$remark ='',$source_id ='',$source_sn='',$extra=''){
$user = User::get($user_id);
if(empty($user)){
return false;
}
$type = AccountLog::getChangeType($source_type);
$left_amount = '';
switch ($type){
case 'money':
$left_amount = $user->user_money;
break;
case 'integral':
$left_amount = $user->user_integral;
break;
case 'growth':
$left_amount = $user->user_growth;
break;
case 'earnings':
$left_amount = $user->earnings;
}
$account_log = new AccountLog();
$account_log->log_sn = createSn('account_log','log_sn','',4);
$account_log->user_id = $user_id;
$account_log->source_type = $source_type;
$account_log->source_id = $source_id;
$account_log->source_sn = $source_sn;
$account_log->change_amount = $amount;
$account_log->left_amount = $left_amount;
$account_log->remark = AccountLog::getRemarkDesc($source_type,$source_sn,$remark);
$account_log->extra = $extra;
$account_log->change_type = $change_type;
$account_log->create_time = time();
$account_log->save();
//更新会员等级
if($type === 'growth' && $change_type == 1){
UserLevelLogic::updateUserLevel($user_id);
}
return true;
}
}

View File

@ -0,0 +1,60 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\common\logic;
use app\common\model\distribution\Distribution;
use app\common\model\distribution\DistributionLevel;
use app\common\service\ConfigServer;
/**
* 分销基础信息逻辑层
* Class DistributionLogic
* @package app\common\logic
*/
class DistributionLogic
{
/**
* @notes 添加分销基础信息记录
* @param $userId
* @author Tab
*/
public static function add($userId)
{
// 默认分销会员等级
$defaultLevelId = DistributionLevel::where('is_default', 1)->value('id');
// 分销会员开通方式
$apply_condition = ConfigServer::get('distribution', 'apply_condition', 2);
$isDistribution = $apply_condition == 1 ? 1 : 0;
$data = [
'user_id' => $userId,
'level_id' => $defaultLevelId,
'is_distribution' => $isDistribution,
'is_freeze' => 0,
'remark' => '',
];
if($isDistribution) {
// 成为分销会员时间
$data['distribution_time'] = time();
}
Distribution::create($data);
}
}

View File

@ -0,0 +1,64 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\common\logic;
use think\facade\Db;
class UserLevelLogic{
/**
* note 用户升级 更新个人会员等级
* create_time 2020/11/26 18:52
*/
public static function updateUserLevel($id){
$user = Db::name('user')->where(['id'=>$id])->field('user_growth,level')->find();
$level = Db::name('user_level')
->where([['growth_value','<=',$user['user_growth']],['del','=',0]])
->order('growth_value desc')
->find();
if($level){
$growth_value = 0;
$user['level'] > 0 && $growth_value = Db::name('user_level')->where(['id'=>$user['level']])->value('growth_value');
if($level['growth_value'] > $growth_value){
Db::name('user')->where(['id'=>$id])->update(['level'=>$level['id'],'update_time'=>time()]);
}
}
return true;
}
/**
* note 用户升级 更新所有用户的等级
* create_time 2020/11/26 19:11
*/
public static function updateAllUserLevel($level_id){
$growth_value = Db::name('user_level')->where(['id'=>$level_id])->value('growth_value');
$no_update_user_ids = Db::name('user')->alias('U')
->join('user_level L','U.level = L.id')
->where('L.growth_value','>',$growth_value)
->column('U.id');
return Db::name('user')
->where([
['id','not in',$no_update_user_ids],
['del','=',0],
['user_growth','>=',$growth_value],
])->update(['level'=>$level_id,'update_time'=>time()]);
}
}