格式化代码

This commit is contained in:
liaofei 2019-11-19 17:57:27 +08:00
parent 2762c576b1
commit 326c3734e6
6 changed files with 278 additions and 249 deletions

View File

@ -1,4 +1,5 @@
<?php
namespace app\models\article;
use app\models\store\StoreProduct;
@ -47,7 +48,8 @@ class Article extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function getArticleOne($id = 0){
public static function getArticleOne($id = 0)
{
if (!$id) return [];
$list = self::where('status', 1)->where('hide', 0)->where('id', $id)->order('id desc')->find();
if ($list) {
@ -55,8 +57,7 @@ class Article extends BaseModel
$list = $list->hidden(['hide', 'status', 'admin_id', 'mer_id'])->toArray();
$list["content"] = Db::name('articleContent')->where('nid', $id)->value('content');
return $list;
}
else return [];
} else return [];
}
/**
@ -85,7 +86,8 @@ class Article extends BaseModel
* @param string $field
* @return mixed]
*/
public static function getArticleListHot($field = 'id,title,image_input,visit,add_time,synopsis,url'){
public static function getArticleListHot($field = 'id,title,image_input,visit,add_time,synopsis,url')
{
$model = new self();
$model = $model->field($field);
$model = $model->where('status', 1);
@ -100,7 +102,8 @@ class Article extends BaseModel
* @param string $field
* @return mixed
*/
public static function getArticleListBanner($field = 'id,title,image_input,visit,add_time,synopsis,url'){
public static function getArticleListBanner($field = 'id,title,image_input,visit,add_time,synopsis,url')
{
$model = new self();
$model = $model->field($field);
$model = $model->where('status', 1);

View File

@ -1,4 +1,5 @@
<?php
namespace app\models\article;
use crmeb\traits\ModelTrait;
@ -33,7 +34,8 @@ class ArticleCategory extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function getArticleCategory(){
public static function getArticleCategory()
{
return self::where('hidden', 0)->where('is_del', 0)->where('status', 1)->where('pid', 0)->order('sort DESC')->field('id,title')->select();
}
@ -43,7 +45,8 @@ class ArticleCategory extends BaseModel
* @param string $field $field 字段
* @return mixed|string
*/
public static function getArticleCategoryField($id,$field = 'title'){
public static function getArticleCategoryField($id, $field = 'title')
{
if (!$id) return '';
return self::where('id', $id)->value($field);
}

View File

@ -1,4 +1,5 @@
<?php
namespace app\models\routine;
use crmeb\services\MiniProgramService;
@ -8,7 +9,8 @@ use crmeb\services\MiniProgramService;
* Class RoutineCode
* @package app\models\routine
*/
class RoutineCode{
class RoutineCode
{
/**
* TODO 获取小程序二维码
@ -22,7 +24,8 @@ class RoutineCode{
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function getShareCode($thirdId, $thirdType, $page, $imgUrl){
public static function getShareCode($thirdId, $thirdType, $page, $imgUrl)
{
$res = RoutineQrcode::routineQrCodeForever($thirdId, $thirdType, $page, $imgUrl);
$resCode = MiniProgramService::qrcodeService()->appCodeUnlimit($res->id, $page, 280);
if ($resCode) {
@ -38,7 +41,8 @@ class RoutineCode{
* @param int $width
* @return mixed
*/
public static function getPageCode($page = '', $pramam = "?uid=1&product=1",$width = 280){
public static function getPageCode($page = '', $pramam = "?uid=1&product=1", $width = 280)
{
return MiniProgramService::qrcodeService()->appCodeUnlimit($pramam, $page, $width);
}
}

View File

@ -1,4 +1,5 @@
<?php
namespace app\models\routine;
use crmeb\basic\BaseModel;
@ -30,7 +31,8 @@ class RoutineFormId extends BaseModel
* @return bool
* @throws \Exception
*/
public static function delStatusInvalid(){
public static function delStatusInvalid()
{
return self::where('status', 2)->where('stop_time', '<', time())->delete();
}
@ -43,7 +45,8 @@ class RoutineFormId extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function getFormIdOne($uid = 0, $isArray = false){
public static function getFormIdOne($uid = 0, $isArray = false)
{
$formId = self::where('status', 1)->where('stop_time', '>', time())->where('uid', $uid)->order('id asc')->find();
if ($isArray) return $formId;
if ($formId) return $formId['form_id'];
@ -55,7 +58,8 @@ class RoutineFormId extends BaseModel
* @param string $formId
* @return $this|bool
*/
public static function delFormIdOne($formId = ''){
public static function delFormIdOne($formId = '')
{
if ($formId == '') return true;
return self::where('form_id', $formId)->update(['status' => 2]);
}

View File

@ -1,4 +1,5 @@
<?php
namespace app\models\routine;
@ -38,7 +39,8 @@ class RoutineQrcode extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function routineQrCodeForever($thirdId = 0,$thirdType = 'spread',$page = '',$qrCodeLink = ''){
public static function routineQrCodeForever($thirdId = 0, $thirdType = 'spread', $page = '', $qrCodeLink = '')
{
$count = self::where('third_id', $thirdId)->where('third_type', $thirdType)->count();
if ($count) return self::where('third_id', $thirdId)->where('third_type', $thirdType)->field('id')->find();
return self::setRoutineQrcodeForever($thirdId, $thirdType, $page, $qrCodeLink);
@ -50,7 +52,8 @@ class RoutineQrcode extends BaseModel
* @param int $thirdId
* @return object
*/
public static function setRoutineQrcodeForever($thirdId = 0,$thirdType = 'spread',$page = '',$qrCodeLink = ''){
public static function setRoutineQrcodeForever($thirdId = 0, $thirdType = 'spread', $page = '', $qrCodeLink = '')
{
$data['third_type'] = $thirdType;
$data['third_id'] = $thirdId;
$data['status'] = 0;
@ -67,7 +70,8 @@ class RoutineQrcode extends BaseModel
* @param array $data
* @return bool
*/
public static function setRoutineQrcodeFind($id = 0,$data = array()){
public static function setRoutineQrcodeFind($id = 0, $data = array())
{
if (!$id) return false;
$count = self::getRoutineQrcodeFind($id);
if (!$count) return false;
@ -79,7 +83,8 @@ class RoutineQrcode extends BaseModel
* @param int $id
* @return int|string
*/
public static function getRoutineQrcodeFind($id = 0){
public static function getRoutineQrcodeFind($id = 0)
{
if (!$id) return 0;
return self::where('id', $id)->count();
}
@ -93,7 +98,8 @@ class RoutineQrcode extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function getRoutineQrcodeFindType($id = 0,$field = 'third_type,third_id,page'){
public static function getRoutineQrcodeFindType($id = 0, $field = 'third_type,third_id,page')
{
if (!$id) return false;
$count = self::getRoutineQrcodeFind($id);
if (!$count) return false;

View File

@ -65,7 +65,6 @@ class User extends BaseModel
'uid' => $wechatUser['uid'],
'user_type' => 'wechat'
]);
}
@ -179,7 +178,8 @@ class User extends BaseModel
* @param int $spread_uid
* @return object
*/
public static function setRoutineUser($routineUser,$spread_uid = 0){
public static function setRoutineUser($routineUser, $spread_uid = 0)
{
self::beginTrans();
$res1 = true;
if ($spread_uid) $res1 = self::where('uid', $spread_uid)->inc('spread_count', 1)->update();
@ -239,7 +239,8 @@ class User extends BaseModel
* @param int $uid
* @return bool
*/
public static function isUserSpread($uid = 0){
public static function isUserSpread($uid = 0)
{
if (!$uid) return false;
$status = (int)sysConfig('store_brokerage_statu');
$isPromoter = true;
@ -319,7 +320,8 @@ class User extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function backOrderBrokerageTwo($orderInfo){
public static function backOrderBrokerageTwo($orderInfo)
{
//TODO 获取购买商品的用户
$userInfo = User::getUserInfo($orderInfo['uid']);
//TODO 获取上推广人
@ -405,12 +407,14 @@ class User extends BaseModel
{
return self::edit(['avatar' => $avatar, 'nickname' => $nickname], $uid, 'uid');
}
/**
* TODO 获取推广人数 一级
* @param int $uid
* @return bool|int|string
*/
public static function getSpreadCount($uid = 0){
public static function getSpreadCount($uid = 0)
{
if (!$uid) return false;
return self::where('spread_uid', $uid)->count();
}
@ -419,7 +423,8 @@ class User extends BaseModel
* 修改当前用户的推广人数
* @param $uid
*/
public static function setUserSpreadCount($uid){
public static function setUserSpreadCount($uid)
{
self::where('uid', $uid)->update(['spread_count' => self::getSpreadCount($uid)]);
}
@ -428,7 +433,8 @@ class User extends BaseModel
* @param int $uid
* @return bool|int|string
*/
public static function getSpreadLevelCount($uid = 0){
public static function getSpreadLevelCount($uid = 0)
{
if (!$uid) return false;
$uidSubordinate = self::where('spread_uid', $uid)->column('uid');
if (!count($uidSubordinate)) return 0;
@ -445,7 +451,8 @@ class User extends BaseModel
* @param int $limit
* @return array|bool
*/
public static function getUserSpreadGrade($uid = 0,$grade = 0,$orderBy = '',$keyword = '',$page = 0,$limit = 20){
public static function getUserSpreadGrade($uid = 0, $grade = 0, $orderBy = '', $keyword = '', $page = 0, $limit = 20)
{
if (!$uid) return [];
$gradeGroup = [0, 1];
if (!in_array($grade, $gradeGroup)) return self::setErrorInfo('等级错误');
@ -519,7 +526,8 @@ class User extends BaseModel
* @param $spreadUid
* @return bool|int
*/
public static function validSpread($uid, $spreadUid){
public static function validSpread($uid, $spreadUid)
{
if (!$uid || !$spreadUid) return false;
return self::where('uid', $uid)->where('spread_uid', $spreadUid)->count();
}
@ -629,7 +637,8 @@ class User extends BaseModel
* @param $data
* @return array
*/
public static function brokerageRank($data){
public static function brokerageRank($data)
{
$model = self::where('status', 1);
switch ($data['type']) {
case 'week':