其余文件

This commit is contained in:
2026-04-14 17:46:22 +08:00
parent 294b68fe37
commit 3691f4db22
1343 changed files with 189847 additions and 0 deletions

View File

@ -0,0 +1,23 @@
<?php
namespace app\common\model\distribution;
use app\common\basics\Models;
use think\model\concern\SoftDelete;
class Distribution extends Models
{
use SoftDelete;
protected $deleteTime = 'delete_time';
/**
* @notes 成为分销会员时间
* @param $value
* @return false|string
* @author Tab
* @date 2021/9/2 18:59
*/
public function getDistributionTimeAttr($value)
{
return empty($value) ? '' : date('Y-m-d H:i:s', $value);
}
}

View File

@ -0,0 +1,11 @@
<?php
namespace app\common\model\distribution;
use app\common\basics\Models;
use think\model\concern\SoftDelete;
class DistributionGoods extends Models
{
use SoftDelete;
protected $deleteTime = 'delete_time';
}

View File

@ -0,0 +1,86 @@
<?php
namespace app\common\model\distribution;
use app\common\basics\Models;
use think\model\concern\SoftDelete;
class DistributionLevel extends Models
{
use SoftDelete;
protected $deleteTime = 'delete_time';
/**
* 升级条件允许的字段
* singleConsumptionAmount 单笔消费金额
* cumulativeConsumptionAmount 累计消费金额
* cumulativeConsumptionTimes 累计消费次数
* returnedCommission 已结算佣金收入
*/
const UPDATE_CONDITION_FIELDS = ['singleConsumptionAmount', 'cumulativeConsumptionAmount', 'cumulativeConsumptionTimes', 'returnedCommission'];
/**
* @notes 获取键对应值的字段名
* @param $key
* @return string
* @author Tab
* @date 2021/9/1 14:58
*/
public static function getValueFiled($key)
{
switch($key) {
case 'singleConsumptionAmount':
case 'cumulativeConsumptionAmount':
case 'returnedCommission':
return 'value_decimal';
case 'cumulativeConsumptionTimes':
return 'value_int';
default:
return 'value_text';
}
}
/**
* @notes 权重描述获取器
* @param $value
* @param $data
* @return string
* @author Tab
* @date 2021/9/1 11:40
*/
public function getWeightsDescAttr($value, $data)
{
return $data['is_default'] ? $value . '级(默认等级)' : $value . '级';
}
/**
* @notes 等级下分销会员数量
* @param $value
* @param $data
* @return int
* @author Tab
* @date 2021/9/1 11:41
*/
public function getMembersNumAttr($value, $data)
{
$num = Distribution::where('level_id', $data['id'])->count();
return $num;
}
public static function getLevelName($levelId)
{
$level = self::field('name,weights')->findOrEmpty($levelId)->toArray();
if (empty($level)) {
return '';
}
return $level['name']. '(' . $level['weights'] . ')级';
}
public static function getLevelNameTwo($levelId)
{
$level = self::field('name,weights')->findOrEmpty($levelId)->toArray();
if (empty($level)) {
return '';
}
return $level['name'];
}
}

View File

@ -0,0 +1,11 @@
<?php
namespace app\common\model\distribution;
use app\common\basics\Models;
use think\model\concern\SoftDelete;
class DistributionLevelUpdate extends Models
{
use SoftDelete;
protected $deleteTime = 'delete_time';
}

View File

@ -0,0 +1,43 @@
<?php
namespace app\common\model\distribution;
use app\common\basics\Models;
class DistributionMemberApply extends Models
{
/**
* 分销会员申请状态
*/
const STATUS_WAIT_AUDIT = 0; //待审核
const STATUS_AUDIT_SUCCESS = 1; //审核通过
const STATUS_AUDIT_ERROR = 2; //审核拒绝
/**
* @Notes: 关联用户模型
* @Author: 张无忌
*/
public function user()
{
return $this->hasOne('app\common\model\user\User', 'id', 'user_id');
}
/**
* @Notes: 分销会员申请状态
* @param bool $status
* @return array|mixed|string
*/
public static function getApplyStatus($status = true)
{
$desc = [
self::STATUS_WAIT_AUDIT => '待审核',
self::STATUS_AUDIT_SUCCESS => '审核通过',
self::STATUS_AUDIT_ERROR => '审核拒绝',
];
if ($status === true) {
return $desc;
}
return $desc[$status] ?? '未知';
}
}

View File

@ -0,0 +1,94 @@
<?php
namespace app\common\model\distribution;
use app\common\basics\Models;
use app\common\server\UrlServer;
class DistributionOrderGoods extends Models
{
//分销订单状态
const STATUS_WAIT_HANDLE = 1;//待返佣
const STATUS_SUCCESS = 2;//已结算
const STATUS_ERROR = 3;//已失效
public function getStatusDescAttr($value)
{
$statusDesc = [
1 => '待返佣',
2 => '已结算',
3 => '已失效',
];
return $statusDesc[$value];
}
public function getDistributionCreateTimeAttr($value)
{
return date('Y-m-d H:i:s', $value);
}
/**
* Notes: 更新指定分佣订单状态
* @param $distribution_id
* @param $status
* @author 段誉(2021/4/23 10:10)
* @return DistributionOrder
*/
public static function updateOrderStatus($distribution_id, $status)
{
return self::where('id', $distribution_id)
->update([
'status' => $status,
'update_time' => time()
]);
}
/**
* @notes 获取指定用户佣金情况
* @param $userId
* @return array
* @author Tab
* @date 2021/9/2 19:14
*/
public static function getEarnings($userId)
{
// 待返佣
$wait = self::where([
'user_id' => $userId,
'status' => 1,
])->sum('money');
// 已入账
$success = self::where([
'user_id' => $userId,
'status' => 2,
])->sum('money');
// 已失效
$fail = self::where([
'user_id' => $userId,
'status' => 3,
])->sum('money');
return [
'wait' => $wait,
'success' => $success,
'fail' => $fail,
];
}
public function getSettlementTimeAttr($value)
{
return empty($value) ? '' : date('Y-m-d H:i:s', $value);
}
/**
* @notes 商品图片
* @param $fieldValue
* @param $data
* @return string
* @author lbzy
* @datetime 2023-07-26 10:35:04
*/
function getGoodsImageAttr($fieldValue, $data)
{
return UrlServer::getFileUrl($fieldValue);
}
}