From a4b3ee325c7354579d495bc74a777e494e5ec38c Mon Sep 17 00:00:00 2001
From: quanwei <419654421@qq.com>
Date: Fri, 06 Feb 2026 18:18:44 +0800
Subject: [PATCH] 商品可以价格面议 选择走访时显示输入走访企业名 分会添加活动时要总会审核 分类添加人数限制,添加活动选择了填写人数限制的分类时活动名额下显示该分类人数限制为15 同一个企业30天内只能走访一次,在30天内走访同一个企业时提示该企业已被走访xx天后才可以从新走访

---
 admin/app/common/model/plus/team/Apply.php |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/admin/app/common/model/plus/team/Apply.php b/admin/app/common/model/plus/team/Apply.php
index 655ecdb..6b2a393 100644
--- a/admin/app/common/model/plus/team/Apply.php
+++ b/admin/app/common/model/plus/team/Apply.php
@@ -1 +1 @@
-<?php



namespace app\common\model\plus\team;



use app\common\model\BaseModel;

use app\common\model\plus\agent\User as AgentUserModel;



/**

 * 队长申请模型

 */

class Apply extends BaseModel

{

    protected $name = 'team_apply';

    protected $pk = 'apply_id';



    /**

     * 申请状态

     * @var array

     */

    public $applyStatus = [

        10 => '待审核',

        20 => '审核通过',

        30 => '驳回',

    ];



    /**

     * 申请时间

     * @param $value

     * @return false|string

     */

    public function getApplyTimeAttr($value)

    {

        return date('Y-m-d H:i:s', $value);

    }



    /**

     * 审核时间

     * @param $value

     * @return false|int|string

     */

    public function getAuditTimeAttr($value)

    {

        return $value > 0 ? date('Y-m-d H:i:s', $value) : 0;

    }



    /**

     * 关联推荐人表

     * @return \think\model\relation\BelongsTo

     */

    public function referee()

    {

        return $this->belongsTo('app\common\model\user\User', 'referee_id')

            ->field(['user_id', 'nickName']);

    }



    /**

     * 销商申请记录详情

     * @param $where

     * @return array|\think\Model|null

     * @throws \think\db\exception\DataNotFoundException

     * @throws \think\db\exception\DbException

     * @throws \think\db\exception\ModelNotFoundException

     */

    public static function detail($where)

    {

        $filter = is_array($where) ? $where : ['apply_id' => $where];

        return (new static())->where($filter)->find();

    }



    /**

     * 根据分销判断成为队长

     * @param $userId

     * @param $appId

     * @return bool

     */

    public function becomeTeamByAgent($userId, $become_type, $appId)

    {

        //log_write($become_type);

        // 验证是否设置

        $config = Setting::getItem('basic', $appId);

        if (empty($config['is_open'])) {

            return false;

        }

        if ($config['become'] != $become_type) {

            return false;

        }

        $agent = AgentUserModel::detail($userId);

        if (!$agent) {

            return false;

        }

        $becomeTeam = false;

        //分销商总数

        if ($become_type == '40') {

            $agent_total = $agent['first_num'] + $agent['second_num'] + $agent['third_num'];

            if ($agent_total >= $config['totalfxs_down']) {

                $becomeTeam = true;

            }

        }

        //分销佣金总数

        if ($become_type == '50') {

            $agent_money = $agent['total_money'] + $agent['money'] + $agent['freeze_money'];

            if ($agent_money >= $config['total_money']) {

                $becomeTeam = true;

            }

        }
        if($become_type == '70'){
            $vipNum=(new \app\common\model\user\User)->getRefereeGradeCount([$userId],$config['referee_grade_ids']);
            $supplierNum=(new \app\common\model\supplier\User)->getSubordinateNum([$userId]);
            $user=(new \app\common\model\user\User)->where(['user_id'=>$userId,'is_delete'=>0])->find();
            if ($vipNum >= $config['totalvip_down'] && $supplierNum >= $config['totalsh_down']&&$user['purchase_count']>=$config['purchase_count']) {
                $BecomeTeam = true;
            }
        }
        // 新增队长用户

        if ($BecomeTeam) {

            User::add($userId, [

                'referee_id' => $agent['referee_id'], //推荐人id

                'app_id' => $appId,

            ]);

        }

        return true;

    }



    /**

     * 审核状态

     * @param $value

     * @return array

     */

    public function getApplyStatusAttr($value)

    {

        $method = [10 => '待审核', 20 => '审核通过', '30' => '驳回'];

        return ['text' => $method[$value], 'value' => $value];

    }



    /**

     * 审核方式

     * @param $value

     * @return array

     */

    public function getApplyTypeAttr($value)

    {

        $method = [10 => '后台审核', 20 => '无需审核'];

        return ['text' => $method[$value], 'value' => $value];

    }



}
\ No newline at end of file
+<?php



namespace app\common\model\plus\team;



use app\common\model\BaseModel;

use app\common\model\order\Order as OrderModel;
use app\common\model\plus\agent\User as AgentUserModel;



/**

 * 队长申请模型

 */

class Apply extends BaseModel

{

    protected $name = 'team_apply';

    protected $pk = 'apply_id';



    /**

     * 申请状态

     * @var array

     */

    public $applyStatus = [

        10 => '待审核',

        20 => '审核通过',

        30 => '驳回',

    ];



    /**

     * 申请时间

     * @param $value

     * @return false|string

     */

    public function getApplyTimeAttr($value)

    {

        return date('Y-m-d H:i:s', $value);

    }



    /**

     * 审核时间

     * @param $value

     * @return false|int|string

     */

    public function getAuditTimeAttr($value)

    {

        return $value > 0 ? date('Y-m-d H:i:s', $value) : 0;

    }



    /**

     * 关联推荐人表

     * @return \think\model\relation\BelongsTo

     */

    public function referee()

    {

        return $this->belongsTo('app\common\model\user\User', 'referee_id')

            ->field(['user_id', 'nickName']);

    }



    /**

     * 销商申请记录详情

     * @param $where

     * @return array|\think\Model|null

     * @throws \think\db\exception\DataNotFoundException

     * @throws \think\db\exception\DbException

     * @throws \think\db\exception\ModelNotFoundException

     */

    public static function detail($where)

    {

        $filter = is_array($where) ? $where : ['apply_id' => $where];

        return (new static())->where($filter)->find();

    }



    /**

     * 根据分销判断成为队长

     * @param $userId

     * @param $appId

     * @return bool

     */

    public function becomeTeamByAgent($userId, $become_type, $appId)

    {

        //log_write($become_type);

        // 验证是否设置

        $config = Setting::getItem('basic', $appId);

        if (empty($config['is_open'])) {

            return false;

        }

        if ($config['become'] != $become_type) {

            return false;

        }

        $agent = AgentUserModel::detail($userId);

        if (!$agent) {

            return false;

        }

        $becomeTeam = false;

        //分销商总数

        if ($become_type == '40') {

            $agent_total = $agent['first_num'] + $agent['second_num'] + $agent['third_num'];

            if ($agent_total >= $config['totalfxs_down']) {

                $becomeTeam = true;

            }

        }

        //分销佣金总数

        if ($become_type == '50') {

            $agent_money = $agent['total_money'] + $agent['money'] + $agent['freeze_money'];

            if ($agent_money >= $config['total_money']) {

                $becomeTeam = true;

            }

        }
        if($become_type == '70'){
            $vipNum=(new \app\common\model\user\User)->getRefereeGradeCount([$userId],$config['referee_grade_ids']);
            $supplierNum=(new \app\common\model\supplier\Supplier)->getSubordinateNum([$userId]);
            $user=(new \app\common\model\user\User)->where(['user_id'=>$userId,'is_delete'=>0])->find();
            if ($vipNum >= $config['totalvip_down'] && $supplierNum >= $config['totalsh_down']&&$user['purchase_count']>=$config['purchase_count']) {
                $becomeTeam = true;
            }else if(!empty($config['team_buy_product_ids'])){
                if(OrderModel::getOrderProductIds($user['user_id'],$config['team_buy_product_ids'],true)){
                    $becomeTeam=true;
                }
            }
        }
        // 新增队长用户

        if ($becomeTeam) {

            User::add($userId, [

                'referee_id' => $agent['referee_id'], //推荐人id

                'app_id' => $appId,

            ]);

        }

        return true;

    }



    /**

     * 审核状态

     * @param $value

     * @return array

     */

    public function getApplyStatusAttr($value)

    {

        $method = [10 => '待审核', 20 => '审核通过', '30' => '驳回'];

        return ['text' => $method[$value], 'value' => $value];

    }



    /**

     * 审核方式

     * @param $value

     * @return array

     */

    public function getApplyTypeAttr($value)

    {

        $method = [10 => '后台审核', 20 => '无需审核'];

        return ['text' => $method[$value], 'value' => $value];

    }



}
\ No newline at end of file

--
Gitblit v1.9.2