pull/5/head
zengyyh 4 months ago
parent 8851983a77
commit c6c16124d4
  1. 44
      app/api/controller/Invite.php
  2. 1
      app/common/model/dealer/Setting.php
  3. 31
      app/common/model/successful.php
  4. 27
      app/store/controller/Store.php
  5. 100
      app/store/controller/Successful.php

@ -12,7 +12,7 @@ use cores\exception\BaseException;
use think\db\exception\DbException;
use think\response\Json;
use app\common\model\UploadFile;
use app\common\model\store\Setting;
use app\common\model\dealer\Setting;
use app\store\model\User;
use app\store\model\user\GradeLog;
@ -110,6 +110,7 @@ class Invite extends Controller
->order('id desc')
->paginate(15);
foreach ($list as &$item) {
$item['user_type'] = User::withoutGlobalScope()->where('user_id',$item['user_id'])->value('user_type');
$item['avatar_url'] = (UploadFile::withoutGlobalScope()->where('file_id',$item['avatar_id'])->find())['preview_url'];
$item['desensitization_mobile'] = hide_mobile($item['mobile']);
@ -129,47 +130,48 @@ class Invite extends Controller
{
$storeId = $this->storeId;
//1.查询需要的邀请人数是多少
$setting = Setting::withoutGlobalScope()->where(['key'=>'trade','store_id'=>$storeId])->field('values')->find();
$invite_num = $setting['values']['order']['invite_num']??10;
$setting = Setting::where(['key'=>'condition'])->field('values')->find();
$setting = json_decode($setting,true);
$invite_num = $setting['values']['invite_num'] ?? 10;
//2.查询当前用户邀请的人数,判断比较
$model = new InviteLog();
$user_ids = $model->inviteeUserIds();
if (count($user_ids) < $invite_num) {
return $this->renderError('邀请人数不够');
}
// 获取当前日期时间
$now = time();
// 获取明年今天的日期时间
$nextYearToday = strtotime("+1 year", $now);
// 格式化日期时间为 Y-m-d H:i:s
$formattedDate = date("Y-m-d", $nextYearToday);
if ($user_ids) {
$applyModel = new Apply();
$list_count = $applyModel->whereIn('user_id', $user_ids)
->with(['avatarImg'])
->where(['status' => 20])
->order('id desc')
->count();
if($list_count > $invite_num){
$data = [
$applyModel = new Apply();
$list_count = $applyModel->whereIn('user_id', $user_ids)
->with(['avatarImg'])
->where(['status' => 20])
->count();
if($list_count >= $invite_num){
$data = [
'user_type' => 30,
'fx_effective_time' => $formattedDate,
'update_time'=>time()
];
];
User::withoutGlobalScope()->where('user_id',$this->user['user_id'])->where('store_id',$storeId)->save($data);
User::where('user_id',$this->user['user_id'])->save($data);
$gradeLog = [
$gradeLog = [
'user_id' => $this->user['user_id'],
'store_id' => $storeId,
'change_type' => 20,
'remark' => '邀请人数达到升级服务商',
'create_time' => time(),
];
GradeLog::withoutGlobalScope()->insert($gradeLog);
GradeLog::create($gradeLog);
return $this->renderSuccess('升级成功');
}
}
return $this->renderSuccess('升级失败,邀请人数不够');
return $this->renderError('升级失败,邀请人数不够');
}
}

@ -170,6 +170,7 @@ class Setting extends BaseModel
'becomeBuyGoodsIds' => [],
// 成为下线条件
'downline' => 10, // 参数值:10首次点击分享链接
'invite_num'=>10, // 参数值:10邀请人数
]
],
'commission' => [

@ -32,12 +32,37 @@ class successful extends BaseModel
* @param array $param 查询参数
* @return \think\Paginator
*/
public function list($page): \think\Paginator
public function list($page ,$pageSize): \think\Paginator
{
// 假设从数据库查询数据
$query = self::order('sort', 'desc')->select();
$query = self::order('sort', 'asc')->paginate($pageSize);
// 使用分页方法
return $query->paginate($page,10);
return $query;
}
/**
* @notes:新增
* @param $data
* @return bool
*/
public function add($data): bool
{
$data['store_id'] = self::$storeId;
return $this->save($data);
}
/**
* @notes:删除
* @param array $IdentityId
* @return bool
* @author: wanghousheng
*/
public function remove(array $ids): bool
{
if (static::whereIn('id', $ids)->delete()) {
return true;
}
return false;
}
}

@ -17,6 +17,7 @@ use think\response\Json;
use app\store\model\Store as StoreModel;
use app\common\model\Channel;
use app\common\model\PriceSet;
use app\common\model\UploadFile as UploadFileModel;
/**
* 商家中心控制器
@ -147,4 +148,30 @@ class Store extends Controller
return $this->renderSuccess($data);
}
/**
* 门店入驻列表详情
*/
public function getStoreSettle(): Json
{ $pageSize = $this->request->param('pageSize') ?? 15;
$storeid = $this->storeId;
$list = StoreSettle::where('store_id', $storeid)->paginate($pageSize);
foreach ($list as $item) {
$idCard = $item['identification_photo'];
$businessCare = $item['business_license'];
if (empty($idCard)) {
$item['idCardUrl'] = null;
} else {
$idCard = explode(",", $idCard);
$item['idCardUrl'] = UploadFileModel::withoutGlobalScope()->where('file_id', 'in' , $idCard)->select(); // 或者选择特定字段
}
if (empty($businessCare)) {
$item['businessCareUrl'] = null;
} else {
$businessCareArray = explode(',', $businessCare);
$item['businessCareUrl'] = UploadFileModel::withoutGlobalScope()->whereIn('file_id', $businessCareArray)->select();
}
}
return $this->renderSuccess(compact('list'));
}
}

@ -0,0 +1,100 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\store\controller;
use app\common\model\successful as SuccessfulModel;
use app\common\model\UploadFile;
use think\response\Json;
class Successful extends Controller
{
/**
* 成功案例列表
* @return json
*/
public function getList()
{
$model = new SuccessfulModel;
$page = $this->request->param('page',1);
$pageSize = $this->request->param('pageSize',15);
$list = $model->list($page,$pageSize);
if(empty($list)){
return $this->renderSuccess('暂无数据');
}
$list->each(function ($item, $key) {
$imageUrl = UploadFile::withoutGlobalScope()->where('file_id', $item['image_id'])->find();
if ($imageUrl) {
$item['image_url'] = $imageUrl['preview_url'];
} else {
$item['image_url'] = null; // 或者设置默认图片 URL
}
});
return $this->renderSuccess(compact('list'));
}
/**
* @notes:新增
* @return Json
*
*/
public function add(): Json
{
$data = $this->postForm();
if (!$data) {
return $this->renderError('缺少必要参数');
}
$model = new SuccessfulModel();
if ($model->add($data)) {
return $this->renderSuccess('添加成功');
}
return $this->renderError($model->getError() ?: '添加失败');
}
/**
* @notes:编辑
* @param int $id
* @return Json
* @author:
*/
public function edit(int $id): Json
{
$data = $this->postForm();
if (!$data) {
return $this->renderError('缺少必要参数');
}
$model = SuccessfulModel::where('id', $id)->find();
if (!$model) {
return $this->renderError('找不到指定的数据');
}
$data['update_time']=time();
SuccessfulModel::where('id', $id)->update($data);
return $this->renderSuccess('编辑成功');
}
/**
* @notes:删除
* @param array $ids
* @return Json
* @author:
*/
public function delete(array $ids): Json
{
$model = new SuccessfulModel;
if ($model->remove($ids)) {
return $this->renderSuccess('删除成功');
}
return $this->renderError('删除失败');
}
}
Loading…
Cancel
Save