调整上传图片获取静态句柄方法名

This commit is contained in:
liaofei 2019-11-28 18:41:53 +08:00
parent 5fead1d61a
commit 8875a1e82b
34 changed files with 528 additions and 556 deletions

View File

@ -12,9 +12,7 @@ use app\admin\model\user\UserExtract as UserExtractModel;//分销
use app\admin\model\user\User as UserModel;//用户 use app\admin\model\user\User as UserModel;//用户
use app\admin\model\store\StoreProductReply as StoreProductReplyModel;//评论 use app\admin\model\store\StoreProductReply as StoreProductReplyModel;//评论
use app\admin\model\store\StoreProduct as ProductModel;//产品 use app\admin\model\store\StoreProduct as ProductModel;//产品
use crmeb\utils\Template;
use FormBuilder\Json; use FormBuilder\Json;
use think\facade\Route;
/** /**
* 首页控制器 * 首页控制器
@ -39,22 +37,6 @@ class Index extends AuthController
return $this->fetch(); return $this->fetch();
} }
public function test()
{
$res = Template::instance()->wechat()
->setTemplateCode('OPENTM207791277')
->setTemplateData([
'first'=>'亲,您购买的商品已支付成功',
'keyword1'=>'wx12545454545',
'keyword2'=>'0.99',
'remark'=>'点击查看订单详情'
])
->setTemplateOpenId('od9iXwj58C4aLy11ABMxFkgJelt0')
->setTemplateUrl(Route::buildUrl('order/detail/wx12545454545'))
->send();
var_dump($res);
}
//后台首页内容 //后台首页内容
public function main() public function main()
{ {

View File

@ -211,7 +211,7 @@ class AgentManage extends AuthController
if(!$imageInfo){ if(!$imageInfo){
$res = \app\models\routine\RoutineCode::getShareCode($uid, 'spread', '', ''); $res = \app\models\routine\RoutineCode::getShareCode($uid, 'spread', '', '');
if(!$res) throw new \think\Exception('二维码生成失败'); if(!$res) throw new \think\Exception('二维码生成失败');
$imageInfo = UploadService::getInstance()->setUploadPath('routine/spread/code')->imageStream($name,$res['res']); $imageInfo = UploadService::instance()->setUploadPath('routine/spread/code')->imageStream($name,$res['res']);
if(!is_array($imageInfo)) return $imageInfo; if(!is_array($imageInfo)) return $imageInfo;
SystemAttachment::attachmentAdd($imageInfo['name'],$imageInfo['size'],$imageInfo['type'],$imageInfo['dir'],$imageInfo['thumb_path'],1,$imageInfo['image_type'],$imageInfo['time']); SystemAttachment::attachmentAdd($imageInfo['name'],$imageInfo['size'],$imageInfo['type'],$imageInfo['dir'],$imageInfo['thumb_path'],1,$imageInfo['image_type'],$imageInfo['time']);
RoutineQrcode::setRoutineQrcodeFind($res['id'],['status'=>1,'time'=>time(),'qrcode_url'=>$imageInfo['dir']]); RoutineQrcode::setRoutineQrcodeFind($res['id'],['status'=>1,'time'=>time(),'qrcode_url'=>$imageInfo['dir']]);
@ -221,11 +221,11 @@ class AgentManage extends AuthController
} }
/* /*
* * 获取公众号二维码
* */ * */
public function wechant_code($uid) public function wechant_code($uid)
{ {
$qr_code = \crmeb\services\QrcodeService::getTemporaryQrcode('spread',$uid); $qr_code = \crmeb\services\QrcodeService::getForeverQrcode('spread',$uid);
if(isset($qr_code['url'])) if(isset($qr_code['url']))
return ['code_src'=>$qr_code['url']]; return ['code_src'=>$qr_code['url']];
else else
@ -246,7 +246,7 @@ class AgentManage extends AuthController
if(!$imageInfo){ if(!$imageInfo){
$res = \app\models\routine\RoutineCode::getShareCode($uid, 'spread', '', ''); $res = \app\models\routine\RoutineCode::getShareCode($uid, 'spread', '', '');
if(!$res) return JsonService::fail('二维码生成失败'); if(!$res) return JsonService::fail('二维码生成失败');
$imageInfo = UploadService::getInstance()->setUploadPath('routine/spread/code')->imageStream($name,$res['res']); $imageInfo = UploadService::instance()->setUploadPath('routine/spread/code')->imageStream($name,$res['res']);
if(!is_array($imageInfo)) return JsonService::fail($imageInfo); if(!is_array($imageInfo)) return JsonService::fail($imageInfo);
SystemAttachment::attachmentAdd($imageInfo['name'],$imageInfo['size'],$imageInfo['type'],$imageInfo['dir'],$imageInfo['thumb_path'],1,$imageInfo['image_type'],$imageInfo['time']); SystemAttachment::attachmentAdd($imageInfo['name'],$imageInfo['size'],$imageInfo['type'],$imageInfo['dir'],$imageInfo['thumb_path'],1,$imageInfo['image_type'],$imageInfo['time']);
RoutineQrcode::setRoutineQrcodeFind($res['id'],['status'=>1,'time'=>time(),'qrcode_url'=>$imageInfo['dir']]); RoutineQrcode::setRoutineQrcodeFind($res['id'],['status'=>1,'time'=>time(),'qrcode_url'=>$imageInfo['dir']]);

View File

@ -99,7 +99,7 @@ class Article extends AuthController
* @return \think\response\Json * @return \think\response\Json
*/ */
public function upload_image(){ public function upload_image(){
$res = Upload::getInstance()->setUploadPath('wechat/image/'.date('Ymd'))->image($_POST['file']); $res = Upload::instance()->setUploadPath('wechat/image/'.date('Ymd'))->image($_POST['file']);
if(!is_array($res)) return Json::fail($res); if(!is_array($res)) return Json::fail($res);
SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],5,$res['image_type'],$res['time']); SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],5,$res['image_type'],$res['time']);
return Json::successful('上传成功!',['url'=>$res['dir']]); return Json::successful('上传成功!',['url'=>$res['dir']]);

View File

@ -72,7 +72,7 @@ class ArticleCategory extends AuthController
* s上传图片 * s上传图片
* */ * */
public function upload(){ public function upload(){
$res = Upload::getInstance()->setUploadPath('article')->image('file'); $res = Upload::instance()->setUploadPath('article')->image('file');
if(!is_array($res)) return Json::fail($res); if(!is_array($res)) return Json::fail($res);
SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],5,$res['image_type'],$res['time']); SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],5,$res['image_type'],$res['time']);
return Json::successful('图片上传成功!',['name'=>$res['name'],'url'=>Upload::pathToUrl($res['thumb_path'])]); return Json::successful('图片上传成功!',['name'=>$res['name'],'url'=>Upload::pathToUrl($res['thumb_path'])]);

View File

@ -89,7 +89,7 @@ class WechatNews extends AuthController
* @return \think\response\Json * @return \think\response\Json
*/ */
public function upload_image(){ public function upload_image(){
$res = Upload::getInstance()->setUploadPath('wechat/image/'.date('Ymd'))->image($_POST['file']); $res = Upload::instance()->setUploadPath('wechat/image/'.date('Ymd'))->image($_POST['file']);
if(!is_array($res)) return Json::fail($res); if(!is_array($res)) return Json::fail($res);
SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],5,$res['image_type'],$res['time']); SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],5,$res['image_type'],$res['time']);
return Json::successful('上传成功!',['url'=>$res['thumb_path']]); return Json::successful('上传成功!',['url'=>$res['thumb_path']]);

View File

@ -15,8 +15,6 @@ use crmeb\services\MiniProgramService;
use crmeb\services\UtilService; use crmeb\services\UtilService;
use crmeb\services\WechatService; use crmeb\services\WechatService;
use crmeb\services\FormBuilder as Form; use crmeb\services\FormBuilder as Form;
use crmeb\services\HookService;
use crmeb\subscribes\OrderSubscribe;
use app\admin\model\order\StoreOrderStatus; use app\admin\model\order\StoreOrderStatus;
use app\admin\model\ump\StorePink; use app\admin\model\ump\StorePink;
use app\admin\model\user\User; use app\admin\model\user\User;

View File

@ -400,7 +400,7 @@ class SystemConfig extends AuthController
* 文件上传 * 文件上传
* */ * */
public function file_upload(){ public function file_upload(){
$res = Upload::getInstance()->setUploadPath('config/file')->file($this->request->param('file','file')); $res = Upload::instance()->setUploadPath('config/file')->file($this->request->param('file','file'));
if(!$res->status) return Json::fail($res->error); if(!$res->status) return Json::fail($res->error);
return Json::successful('上传成功!',['filePath'=>$res->filePath]); return Json::successful('上传成功!',['filePath'=>$res->filePath]);
} }

View File

@ -255,7 +255,7 @@ class SystemGroupData extends AuthController
public function upload() public function upload()
{ {
$res = Upload::getInstance()->setUploadPath('common')->image('file'); $res = Upload::instance()->setUploadPath('common')->image('file');
if(!is_array($res)) return Json::fail($res); if(!is_array($res)) return Json::fail($res);
SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],6,$res['image_type'],$res['time']); SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],6,$res['image_type'],$res['time']);
return Json::successful('图片上传成功!',['name'=>$res['name'],'url'=>Upload::pathToUrl($res['thumb_path'])]); return Json::successful('图片上传成功!',['name'=>$res['name'],'url'=>Upload::pathToUrl($res['thumb_path'])]);

View File

@ -770,7 +770,7 @@ class CopyTaobao extends AuthController
$size = strlen(trim($content)); $size = strlen(trim($content));
if (!$content || $size <= 2) return '图片流获取失败'; if (!$content || $size <= 2) return '图片流获取失败';
$date_dir = date('Y') . DS . date('m') . DS . date('d'); $date_dir = date('Y') . DS . date('m') . DS . date('d');
$imageInfo = UploadService::getInstance()->setUploadPath('attach/' . $date_dir)->imageStream($name, $content); $imageInfo = UploadService::instance()->setUploadPath('attach/' . $date_dir)->imageStream($name, $content);
if (!is_array($imageInfo)) return $imageInfo; if (!is_array($imageInfo)) return $imageInfo;
$date['path'] = $imageInfo['dir']; $date['path'] = $imageInfo['dir'];
$date['name'] = $imageInfo['name']; $date['name'] = $imageInfo['name'];

View File

@ -107,7 +107,7 @@ class StoreCategory extends AuthController
*/ */
public function upload() public function upload()
{ {
$res = Upload::getInstance()->setUploadPath('store/category'.date('Ymd'))->image('file'); $res = Upload::instance()->setUploadPath('store/category'.date('Ymd'))->image('file');
if(is_array($res)){ if(is_array($res)){
SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],1,$res['image_type'],$res['time']); SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],1,$res['image_type'],$res['time']);
return Json::successful('图片上传成功!',['name'=>$res['name'],'url'=>Upload::pathToUrl($res['thumb_path'])]); return Json::successful('图片上传成功!',['name'=>$res['name'],'url'=>Upload::pathToUrl($res['thumb_path'])]);

View File

@ -68,7 +68,7 @@ class StoreInfoMana extends AuthController
* */ * */
public function upload() public function upload()
{ {
$res = Upload::getInstance()->setUploadPath('article/'.date('Ymd'))->image('file'); $res = Upload::instance()->setUploadPath('article/'.date('Ymd'))->image('file');
SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],2,$res['image_type'],$res['time']); SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],2,$res['image_type'],$res['time']);
if(is_array($res)) if(is_array($res))
return Json::successful('图片上传成功!',['name'=>$res['name'],'url'=>Upload::pathToUrl($res['thumb_path'])]); return Json::successful('图片上传成功!',['name'=>$res['name'],'url'=>Upload::pathToUrl($res['thumb_path'])]);

View File

@ -176,7 +176,7 @@ class StoreProduct extends AuthController
*/ */
public function upload() public function upload()
{ {
$res = Upload::getInstance()->setUploadPath('store/product/'.date('Ymd'))->image('file'); $res = Upload::instance()->setUploadPath('store/product/'.date('Ymd'))->image('file');
SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],1,$res['image_type'],$res['time']); SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],1,$res['image_type'],$res['time']);
if(is_array($res)) if(is_array($res))
return Json::successful('图片上传成功!',['name'=>$res['name'],'url'=>Upload::pathToUrl($res['thumb_path'])]); return Json::successful('图片上传成功!',['name'=>$res['name'],'url'=>Upload::pathToUrl($res['thumb_path'])]);

View File

@ -21,7 +21,7 @@ class SystemAttachment extends AuthController
*/ */
public function upload() public function upload()
{ {
$res = Upload::getInstance()->setUploadPath('editor/'.date('Ymd'))->image('upfile'); $res = Upload::instance()->setUploadPath('editor/'.date('Ymd'))->image('upfile');
if(is_array($res)){ if(is_array($res)){
SystemAttachmentModel::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],0,$res['image_type'],$res['time']); SystemAttachmentModel::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],0,$res['image_type'],$res['time']);
$info["originalName"] = $res['name']; $info["originalName"] = $res['name'];

View File

@ -191,7 +191,7 @@ class StoreSeckill extends AuthController
*/ */
public function upload() public function upload()
{ {
$res = Upload::getInstance()->setUploadPath('store/product/'.date('Ymd'))->image('file'); $res = Upload::instance()->setUploadPath('store/product/'.date('Ymd'))->image('file');
if(is_array($res)){ if(is_array($res)){
SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],4,$res['image_type'],$res['time']); SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],4,$res['image_type'],$res['time']);
return Json::successful('图片上传成功!',['name'=>$res['name'],'url'=>Upload::pathToUrl($res['thumb_path'])]); return Json::successful('图片上传成功!',['name'=>$res['name'],'url'=>Upload::pathToUrl($res['thumb_path'])]);

View File

@ -82,7 +82,7 @@ class Reply extends AuthController
{ {
$name = $this->request->post('file'); $name = $this->request->post('file');
if(!$name) return Json::fail('请上传图片'); if(!$name) return Json::fail('请上传图片');
$res = Upload::getInstance()->setUploadType(1)->setUploadPath('wechat/image') $res = Upload::instance()->setUploadType(1)->setUploadPath('wechat/image')
->setAutoValidate(true)->image($name); ->setAutoValidate(true)->image($name);
if(!is_array($res)) return Json::fail($res); if(!is_array($res)) return Json::fail($res);
SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],0,$res['image_type'],$res['time']); SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],0,$res['image_type'],$res['time']);
@ -93,7 +93,7 @@ class Reply extends AuthController
{ {
$name = $this->request->post('file'); $name = $this->request->post('file');
if(!$name) return Json::fail('请上传声音'); if(!$name) return Json::fail('请上传声音');
$res = Upload::getInstance()->setUploadPath('wechat/voice')->setAutoValidate(true)->file($name); $res = Upload::instance()->setUploadPath('wechat/voice')->setAutoValidate(true)->file($name);
return $res->status === true ? Json::successful('上传成功',$res->filePath) : Json::fail($res->error); return $res->status === true ? Json::successful('上传成功',$res->filePath) : Json::fail($res->error);
} }

View File

@ -91,7 +91,7 @@ class StoreService extends AuthController
$f[] = Form::input('nickname','客服名称',$service["nickname"]); $f[] = Form::input('nickname','客服名称',$service["nickname"]);
$f[] = Form::radio('customer','统计管理',$service['customer'])->options([['value'=>1,'label'=>'开启'],['value'=>0,'label'=>'关闭']]); $f[] = Form::radio('customer','统计管理',$service['customer'])->options([['value'=>1,'label'=>'开启'],['value'=>0,'label'=>'关闭']]);
$f[] = Form::radio('notify','订单通知',$service['notify'])->options([['value'=>1,'label'=>'开启'],['value'=>0,'label'=>'关闭']]); $f[] = Form::radio('notify','订单通知',$service['notify'])->options([['value'=>1,'label'=>'开启'],['value'=>0,'label'=>'关闭']]);
$f[] = Form::radio('status','客服状态',$service['status'])->options([['value'=>1,'label'=>'显示'],['value'=>0,'label'=>'隐藏']]); $f[] = Form::radio('status','客服状态',$service['status'])->options([['value'=>1,'label'=>'在线'],['value'=>0,'label'=>'离线']]);
$form = Form::make_post_form('修改数据',$f,Url::buildUrl('update',compact('id'))); $form = Form::make_post_form('修改数据',$f,Url::buildUrl('update',compact('id')));
$this->assign(compact('form')); $this->assign(compact('form'));
return $this->fetch('public/form-builder'); return $this->fetch('public/form-builder');
@ -136,7 +136,7 @@ class StoreService extends AuthController
*/ */
public function upload() public function upload()
{ {
$res = Upload::getInstance()->setUploadPath('store/product/'.date('Ymd'))->image('file'); $res = Upload::instance()->setUploadPath('store/product/'.date('Ymd'))->image('file');
if(is_array($res)){ if(is_array($res)){
SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],2,$res['image_type'],$res['time']); SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],2,$res['image_type'],$res['time']);
return Json::successful('图片上传成功!',['name'=>$res['name'],'url'=>Upload::pathToUrl($res['thumb_path'])]); return Json::successful('图片上传成功!',['name'=>$res['name'],'url'=>Upload::pathToUrl($res['thumb_path'])]);

View File

@ -71,7 +71,7 @@ class Images extends AuthController
$upload_type = $this->request->get('upload_type',0); $upload_type = $this->request->get('upload_type',0);
try{ try{
$path = make_path('attach',2,true); $path = make_path('attach',2,true);
$res = Upload::getInstance()->setUploadPath($path)->setAutoValidate(true) $res = Upload::instance()->setUploadPath($path)->setAutoValidate(true)
->setUploadType($upload_type)->image('file'); ->setUploadType($upload_type)->image('file');
if(is_object($res) && $res->status === false){ if(is_object($res) && $res->status === false){
$info = array( $info = array(

View File

@ -58,7 +58,9 @@ class StoreStatistics extends BaseModel
public static function getOrderInfo($where) public static function getOrderInfo($where)
{ {
$orderinfo = self::getTimeWhere($where) $orderinfo = self::getTimeWhere($where)
->field('sum(total_price) total_price,sum(cost) cost,sum(pay_postage) pay_postage,sum(pay_price) pay_price,sum(coupon_price) coupon_price,sum(deduction_price) deduction_price,from_unixtime(pay_time,\'%Y-%m-%d\') pay_time')->order('pay_time')->group('from_unixtime(pay_time,\'%Y-%m-%d\')')->select()->toArray(); ->field('sum(total_price) total_price,sum(cost) cost,sum(pay_postage) pay_postage,sum(pay_price) pay_price,sum(coupon_price) coupon_price,sum(deduction_price) deduction_price,from_unixtime(pay_time,\'%Y-%m-%d\') pay_time')
->order('pay_time')->where('paid',1)->where('refund_status',0)
->group('from_unixtime(pay_time,\'%Y-%m-%d\')')->select()->toArray();
$price = 0; $price = 0;
$postage = 0; $postage = 0;
$deduction = 0; $deduction = 0;

View File

@ -288,10 +288,10 @@ class StoreProduct extends BaseModel
'class'=>'fa fa fa-ioxhost', 'class'=>'fa fa fa-ioxhost',
], ],
[ [
'name'=>'新增商品', 'name'=>'商品总数',
'field'=>'件', 'field'=>'件',
'count'=>self::setWhereType(self::getModelTime($where,new self),$type)->where('is_new',1)->sum('stock'), 'count'=>self::setWhereType(self::getModelTime($where,new self),$type)->sum('stock'),
'content'=>'增商品总数', 'content'=>'增商品总数',
'background_color'=>'layui-bg-cyan', 'background_color'=>'layui-bg-cyan',
'sum'=>self::where('is_new',1)->sum('stock'), 'sum'=>self::where('is_new',1)->sum('stock'),
'class'=>'fa fa-line-chart', 'class'=>'fa fa-line-chart',

View File

@ -67,6 +67,7 @@ class SystemAdmin extends BaseModel
{ {
Session::set('adminId',$adminInfo['id']); Session::set('adminId',$adminInfo['id']);
Session::set('adminInfo',$adminInfo->toArray()); Session::set('adminInfo',$adminInfo->toArray());
Session::save();
} }
/** /**
@ -76,7 +77,7 @@ class SystemAdmin extends BaseModel
{ {
Session::delete('adminInfo'); Session::delete('adminInfo');
Session::delete('adminId'); Session::delete('adminId');
Session::clear(); Session::save();
} }
/** /**

View File

@ -105,7 +105,7 @@ class WechatQrcode extends BaseModel
self::createForeverQrcode($id, $type); self::createForeverQrcode($id, $type);
$res = self::getForeverQrcode($type, $id); $res = self::getForeverQrcode($type, $id);
} }
if(!$res['ticket']) exception('临时二维码获取错误'); if(!$res['ticket']) exception('永久二维码获取错误');
return $res; return $res;
} }

View File

@ -9,7 +9,6 @@ namespace app\admin\model\wechat;
use app\admin\model\system\SystemConfig; use app\admin\model\system\SystemConfig;
use crmeb\traits\ModelTrait; use crmeb\traits\ModelTrait;
use crmeb\basic\BaseModel; use crmeb\basic\BaseModel;
use crmeb\services\HookService;
use crmeb\services\UtilService; use crmeb\services\UtilService;
use crmeb\services\WechatService; use crmeb\services\WechatService;
use think\facade\Route as Url; use think\facade\Route as Url;

View File

@ -1,4 +1,5 @@
<?php <?php
namespace app\api\controller; namespace app\api\controller;
use app\admin\model\system\SystemAttachment; use app\admin\model\system\SystemAttachment;
@ -8,6 +9,7 @@ use app\models\store\StoreProduct;
use app\models\store\StoreService; use app\models\store\StoreService;
use app\models\system\Express; use app\models\system\Express;
use app\models\user\UserBill; use app\models\user\UserBill;
use app\models\user\WechatUser;
use app\Request; use app\Request;
use crmeb\services\GroupDataService; use crmeb\services\GroupDataService;
use crmeb\services\SystemConfigService; use crmeb\services\SystemConfigService;
@ -50,13 +52,14 @@ class PublicController
$firstNumber = $routine_index_page[0]['first_number'] ?? 6;//sysConfig('first_number');//TODO 首发新品个数 $firstNumber = $routine_index_page[0]['first_number'] ?? 6;//sysConfig('first_number');//TODO 首发新品个数
$info['fastList'] = StoreCategory::byIndexList((int)$fastNumber);//TODO 快速选择分类个数 $info['fastList'] = StoreCategory::byIndexList((int)$fastNumber);//TODO 快速选择分类个数
$info['bastList'] = StoreProduct::getBestProduct('id,image,store_name,cate_id,price,ot_price,IFNULL(sales,0) + IFNULL(ficti,0) as sales,unit_name', (int)$bastNumber, $request->uid());//TODO 精品推荐个数 $info['bastList'] = StoreProduct::getBestProduct('id,image,store_name,cate_id,price,ot_price,IFNULL(sales,0) + IFNULL(ficti,0) as sales,unit_name', (int)$bastNumber, $request->uid());//TODO 精品推荐个数
$info['firstList'] = StoreProduct::getNewProduct('id,image,store_name,cate_id,price,unit_name,IFNULL(sales,0) + IFNULL(ficti,0) as sales', (int)$firstNumber,$request->uid());//TODO 首发新品个数 $info['firstList'] = StoreProduct::getNewProduct('id,image,store_name,cate_id,price,unit_name,IFNULL(sales,0) + IFNULL(ficti,0) as sales', (int)$firstNumber, $request->uid());//TODO 首发新品个数
$info['bastBanner'] = GroupDataService::getData('routine_home_bast_banner') ?? [];//TODO 首页精品推荐图片 $info['bastBanner'] = GroupDataService::getData('routine_home_bast_banner') ?? [];//TODO 首页精品推荐图片
$benefit = StoreProduct::getBenefitProduct('id,image,store_name,cate_id,price,ot_price,stock,unit_name', 3);//TODO 首页促销单品 $benefit = StoreProduct::getBenefitProduct('id,image,store_name,cate_id,price,ot_price,stock,unit_name', 3);//TODO 首页促销单品
$lovely = GroupDataService::getData('routine_home_new_banner') ?: [];//TODO 首发新品顶部图 $lovely = GroupDataService::getData('routine_home_new_banner') ?: [];//TODO 首发新品顶部图
$likeInfo = StoreProduct::getHotProduct('id,image,store_name,cate_id,price,unit_name', 3);//TODO 热门榜单 猜你喜欢 $likeInfo = StoreProduct::getHotProduct('id,image,store_name,cate_id,price,unit_name', 3);//TODO 热门榜单 猜你喜欢
$couponList = StoreCouponIssue::getIssueCouponList($request->uid(), 3); $couponList = StoreCouponIssue::getIssueCouponList($request->uid(), 3);
return app('json')->successful(compact('banner', 'menus', 'roll', 'info', 'activity', 'lovely', 'benefit', 'likeInfo', 'logoUrl', 'couponList','site_name')); $subscribe = WechatUser::where('uid', $request->uid() ?? 0)->value('subscribe') ? true : false;
return app('json')->successful(compact('banner', 'menus', 'roll', 'info', 'activity', 'lovely', 'benefit', 'likeInfo', 'logoUrl', 'couponList', 'site_name','subscribe'));
} }
/** /**
@ -88,20 +91,20 @@ class PublicController
$user = $request->user(); $user = $request->user();
$vipOpen = sysConfig('vip_open'); $vipOpen = sysConfig('vip_open');
$vipOpen = is_string($vipOpen) ? (int)$vipOpen : $vipOpen; $vipOpen = is_string($vipOpen) ? (int)$vipOpen : $vipOpen;
foreach ($menusInfo as $key=>&$value){ foreach ($menusInfo as $key => &$value) {
$value['pic'] = UtilService::setSiteUrl($value['pic']); $value['pic'] = UtilService::setSiteUrl($value['pic']);
if($value['id'] == 137 && !(intval(sysConfig('store_brokerage_statu')) == 2 || $user->is_promoter == 1)) if ($value['id'] == 137 && !(intval(sysConfig('store_brokerage_statu')) == 2 || $user->is_promoter == 1))
unset($menusInfo[$key]); unset($menusInfo[$key]);
if($value['id'] == 174 && !StoreService::orderServiceStatus($user->uid)) if ($value['id'] == 174 && !StoreService::orderServiceStatus($user->uid))
unset($menusInfo[$key]); unset($menusInfo[$key]);
if(!StoreService::orderServiceStatus($user->uid) && $value['wap_url'] === '/order/order_cancellation') if (!StoreService::orderServiceStatus($user->uid) && $value['wap_url'] === '/order/order_cancellation')
unset($menusInfo[$key]); unset($menusInfo[$key]);
if($value['wap_url'] == '/user/vip' && !$vipOpen) if ($value['wap_url'] == '/user/vip' && !$vipOpen)
unset($menusInfo[$key]); unset($menusInfo[$key]);
if($value['wap_url'] == '/customer/index' && !StoreService::orderServiceStatus($user->uid)) if ($value['wap_url'] == '/customer/index' && !StoreService::orderServiceStatus($user->uid))
unset($menusInfo[$key]); unset($menusInfo[$key]);
} }
return app('json')->successful(['routine_my_menus'=>$menusInfo]); return app('json')->successful(['routine_my_menus' => $menusInfo]);
} }
/** /**
@ -115,8 +118,8 @@ class PublicController
{ {
$routineHotSearch = GroupDataService::getData('routine_hot_search') ?? []; $routineHotSearch = GroupDataService::getData('routine_hot_search') ?? [];
$searchKeyword = []; $searchKeyword = [];
if(count($routineHotSearch)){ if (count($routineHotSearch)) {
foreach ($routineHotSearch as $key=>&$item){ foreach ($routineHotSearch as $key => &$item) {
array_push($searchKeyword, $item['title']); array_push($searchKeyword, $item['title']);
} }
} }
@ -133,21 +136,21 @@ class PublicController
public function upload_image(Request $request) public function upload_image(Request $request)
{ {
$data = UtilService::postMore([ $data = UtilService::postMore([
['filename','file'], ['filename', 'file'],
],$request); ], $request);
if(!$data['filename']) return app('json')->fail('参数有误'); if (!$data['filename']) return app('json')->fail('参数有误');
if(Cache::has('start_uploads_'.$request->uid()) && Cache::get('start_uploads_'.$request->uid()) >= 100) return app('json')->fail('非法操作'); if (Cache::has('start_uploads_' . $request->uid()) && Cache::get('start_uploads_' . $request->uid()) >= 100) return app('json')->fail('非法操作');
$res = UploadService::getInstance()->setUploadPath('store/comment')->image($data['filename']); $res = UploadService::instance()->setUploadPath('store/comment')->image($data['filename']);
if(!is_array($res)) return app('json')->fail($res); if (!is_array($res)) return app('json')->fail($res);
SystemAttachment::attachmentAdd($res['name'], $res['size'], $res['type'], $res['dir'], $res['thumb_path'],1, $res['image_type'], $res['time'], 2); SystemAttachment::attachmentAdd($res['name'], $res['size'], $res['type'], $res['dir'], $res['thumb_path'], 1, $res['image_type'], $res['time'], 2);
if(Cache::has('start_uploads_'.$request->uid())) if (Cache::has('start_uploads_' . $request->uid()))
$start_uploads=(int)Cache::get('start_uploads_'.$request->uid()); $start_uploads = (int)Cache::get('start_uploads_' . $request->uid());
else else
$start_uploads = 0; $start_uploads = 0;
$start_uploads++; $start_uploads++;
Cache::set('start_uploads_'.$request->uid(),$start_uploads,86400); Cache::set('start_uploads_' . $request->uid(), $start_uploads, 86400);
$res['dir'] = UploadService::pathToUrl($res['dir']); $res['dir'] = UploadService::pathToUrl($res['dir']);
if(strpos($res['dir'],'http') === false) $res['dir'] = $request->domain().$res['dir']; if (strpos($res['dir'], 'http') === false) $res['dir'] = $request->domain() . $res['dir'];
return app('json')->successful('图片上传成功!', ['name' => $res['name'], 'url' => $res['dir']]); return app('json')->successful('图片上传成功!', ['name' => $res['name'], 'url' => $res['dir']]);
} }
@ -158,8 +161,8 @@ class PublicController
public function logistics() public function logistics()
{ {
$expressList = Express::lst(); $expressList = Express::lst();
if(!$expressList) return app('json')->successful([]); if (!$expressList) return app('json')->successful([]);
return app('json')->successful($expressList->hidden(['code', 'id', 'sort', 'is_show'])->toArray()); return app('json')->successful($expressList->hidden(['code', 'id', 'sort', 'is_show'])->toArray());
} }
/** /**
@ -178,8 +181,8 @@ class PublicController
['pay_time', time()], ['pay_time', time()],
['attach', 0], ['attach', 0],
], $request, true); ], $request, true);
if($status == 200){ if ($status == 200) {
ChannelService::instance()->send('PAY_SMS_SUCCESS', ['price'=> $price, 'number'=> $num], [$attach]); ChannelService::instance()->send('PAY_SMS_SUCCESS', ['price' => $price, 'number' => $num], [$attach]);
return app('json')->successful(); return app('json')->successful();
} }
return app('json')->fail(); return app('json')->fail();
@ -190,7 +193,8 @@ class PublicController
* @param Request $request * @param Request $request
* @return mixed * @return mixed
*/ */
public function user_share(Request $request){ public function user_share(Request $request)
{
return app('json')->successful(UserBill::setUserShare($request->uid())); return app('json')->successful(UserBill::setUserShare($request->uid()));
} }
@ -199,21 +203,20 @@ class PublicController
* @param Request $request * @param Request $request
* @return mixed * @return mixed
*/ */
public function get_image_base64(Request $request){ public function get_image_base64(Request $request)
list($imageUrl,$codeUrl) = UtilService::postMore([ {
['image',''], list($imageUrl, $codeUrl) = UtilService::postMore([
['code',''], ['image', ''],
],$request,true); ['code', ''],
try{ ], $request, true);
try {
$code = $codeUrl ? UtilService::setImageBase64($codeUrl) : false; $code = $codeUrl ? UtilService::setImageBase64($codeUrl) : false;
$image = $imageUrl ? UtilService::setImageBase64($imageUrl) : false; $image = $imageUrl ? UtilService::setImageBase64($imageUrl) : false;
return app('json')->successful(compact('code','image')); return app('json')->successful(compact('code', 'image'));
}catch (\Exception $e){ } catch (\Exception $e) {
return app('json')->fail($e->getMessage()); return app('json')->fail($e->getMessage());
} }
} }
} }

View File

@ -314,7 +314,7 @@ class StoreBargainController
if($user['is_promoter'] || sysConfig('store_brokerage_statu') == 2) $valueData.='&pid='.$user['uid']; if($user['is_promoter'] || sysConfig('store_brokerage_statu') == 2) $valueData.='&pid='.$user['uid'];
$res = RoutineCode::getPageCode('pages/activity/goods_bargain_details/index',$valueData,280); $res = RoutineCode::getPageCode('pages/activity/goods_bargain_details/index',$valueData,280);
if(!$res) return app('json')->fail('二维码生成失败'); if(!$res) return app('json')->fail('二维码生成失败');
$imageInfo = UploadService::getInstance()->setUploadPath('routine/activity/bargain/code')->imageStream($name,$res); $imageInfo = UploadService::instance()->setUploadPath('routine/activity/bargain/code')->imageStream($name,$res);
if(!is_array($imageInfo)) return app('json')->fail($imageInfo); if(!is_array($imageInfo)) return app('json')->fail($imageInfo);
if($imageInfo['image_type'] == 1) $remoteImage = UtilService::remoteImage($siteUrl.$imageInfo['dir']); if($imageInfo['image_type'] == 1) $remoteImage = UtilService::remoteImage($siteUrl.$imageInfo['dir']);
else $remoteImage = UtilService::remoteImage($imageInfo['dir']); else $remoteImage = UtilService::remoteImage($imageInfo['dir']);

View File

@ -1,4 +1,5 @@
<?php <?php
namespace app\api\controller\activity; namespace app\api\controller\activity;
use app\admin\model\system\SystemAttachment; use app\admin\model\system\SystemAttachment;
@ -7,6 +8,7 @@ use app\models\store\StoreCombination;
use app\models\store\StorePink; use app\models\store\StorePink;
use app\models\store\StoreProductReply; use app\models\store\StoreProductReply;
use app\Request; use app\Request;
use crmeb\services\QrcodeService;
use crmeb\services\SystemConfigService; use crmeb\services\SystemConfigService;
use crmeb\services\UploadService; use crmeb\services\UploadService;
use crmeb\services\UtilService; use crmeb\services\UtilService;
@ -27,12 +29,12 @@ class StoreCombinationController
public function lst(Request $request) public function lst(Request $request)
{ {
list($page, $limit) = UtilService::getMore([ list($page, $limit) = UtilService::getMore([
['page',1], ['page', 1],
['limit',10], ['limit', 10],
],$request, true); ], $request, true);
$combinationList = StoreCombination::getAll($page, $limit); $combinationList = StoreCombination::getAll($page, $limit);
if(!count($combinationList)) return app('json')->successful([]); if (!count($combinationList)) return app('json')->successful([]);
return app('json')->successful($combinationList->hidden(['info','product_id','images','mer_id','attr','sort','stock','sales','add_time','is_del','is_show','browse','cost','is_show','start_time','stop_time','description','postage','is_postage','is_host','mer_use','combination'])->toArray()); return app('json')->successful($combinationList->hidden(['info', 'product_id', 'images', 'mer_id', 'attr', 'sort', 'stock', 'sales', 'add_time', 'is_del', 'is_show', 'browse', 'cost', 'is_show', 'start_time', 'stop_time', 'description', 'postage', 'is_postage', 'is_host', 'mer_use', 'combination'])->toArray());
} }
@ -44,49 +46,33 @@ class StoreCombinationController
*/ */
public function detail(Request $request, $id) public function detail(Request $request, $id)
{ {
if(!$id || !($combinationOne = StoreCombination::getCombinationOne($id))) return app('json')->fail('拼团不存在或已下架'); if (!$id || !($combinationOne = StoreCombination::getCombinationOne($id))) return app('json')->fail('拼团不存在或已下架');
$combinationOne = $combinationOne->hidden(['mer_id','attr','sort','add_time','is_host','is_show','is_del','mer_use','cost','combination'])->toArray(); $combinationOne = $combinationOne->hidden(['mer_id', 'attr', 'sort', 'add_time', 'is_host', 'is_show', 'is_del', 'mer_use', 'cost', 'combination'])->toArray();
$combinationOne['images'] = json_decode($combinationOne['images'],true); $combinationOne['images'] = json_decode($combinationOne['images'], true);
list($pink ,$pindAll)= StorePink::getPinkAll($id,true);//拼团列表 list($pink, $pindAll) = StorePink::getPinkAll($id, true);//拼团列表
//公众号
$name = $id.'_combination_detail_wap.jpg';
$imageInfo = SystemAttachment::getInfo($name,'name');
$siteUrl = sysConfig('site_url'); $siteUrl = sysConfig('site_url');
if(!$imageInfo){
$codeUrl = UtilService::setHttpType($siteUrl.'/activity/group_detail/'.$id, 1);//二维码链接
$imageInfo = UtilService::getQRCodePath($codeUrl, $name);
if(is_array($imageInfo)){
SystemAttachment::attachmentAdd($imageInfo['name'],$imageInfo['size'],$imageInfo['type'],$imageInfo['dir'],$imageInfo['thumb_path'],1,$imageInfo['image_type'],$imageInfo['time'],2);
$url = $imageInfo['dir'];
}else {
$url = '';
$imageInfo = ['image_type'=>0];
}
}else $url = $imageInfo['att_dir'];
if($imageInfo['image_type'] == 1)
$url = $siteUrl.$url;
$combinationOne['image'] = UtilService::setSiteUrl($combinationOne['image'], $siteUrl); $combinationOne['image'] = UtilService::setSiteUrl($combinationOne['image'], $siteUrl);
$combinationOne['image_base'] = UtilService::setSiteUrl($combinationOne['image'], $siteUrl); $combinationOne['image_base'] = UtilService::setSiteUrl($combinationOne['image'], $siteUrl);
$combinationOne['code_base'] = $url; $combinationOne['code_base'] = QrcodeService::getWechatQrcodePath($id . '_combination_detail_wap.jpg', '/activity/group_detail/' . $id);
$combinationOne['sale_stock'] = 0; $combinationOne['sale_stock'] = 0;
if($combinationOne['stock'] > 0) $combinationOne['sale_stock'] = 1; if ($combinationOne['stock'] > 0) $combinationOne['sale_stock'] = 1;
if(!strlen(trim($combinationOne['unit_name']))) $combinationOne['unit_name'] = '个'; if (!strlen(trim($combinationOne['unit_name']))) $combinationOne['unit_name'] = '个';
$uid = $request->uid(); $uid = $request->uid();
$data['pink'] = $pink; $data['pink'] = $pink;
$data['pindAll'] = $pindAll; $data['pindAll'] = $pindAll;
$data['storeInfo'] = $combinationOne; $data['storeInfo'] = $combinationOne;
$data['pink_ok_list']=StorePink::getPinkOkList($uid); $data['pink_ok_list'] = StorePink::getPinkOkList($uid);
$data['pink_ok_sum']=StorePink::getPinkOkSumTotalNum($id); $data['pink_ok_sum'] = StorePink::getPinkOkSumTotalNum($id);
$data['reply'] = StoreProductReply::getRecProductReply($combinationOne['product_id']); $data['reply'] = StoreProductReply::getRecProductReply($combinationOne['product_id']);
$data['replyCount'] = StoreProductReply::productValidWhere()->where('product_id',$combinationOne['product_id'])->count(); $data['replyCount'] = StoreProductReply::productValidWhere()->where('product_id', $combinationOne['product_id'])->count();
if($data['replyCount']){ if ($data['replyCount']) {
$goodReply=StoreProductReply::productValidWhere()->where('product_id',$combinationOne['product_id'])->where('product_score',5)->count(); $goodReply = StoreProductReply::productValidWhere()->where('product_id', $combinationOne['product_id'])->where('product_score', 5)->count();
$data['replyChance'] = $goodReply; $data['replyChance'] = $goodReply;
if($goodReply){ if ($goodReply) {
$data['replyChance'] = bcdiv($goodReply,$data['replyCount'],2); $data['replyChance'] = bcdiv($goodReply, $data['replyCount'], 2);
$data['replyChance'] = bcmul($data['replyChance'],100,3); $data['replyChance'] = bcmul($data['replyChance'], 100, 3);
} }
}else $data['replyChance']=0; } else $data['replyChance'] = 0;
return app('json')->successful($data); return app('json')->successful($data);
} }
@ -102,52 +88,52 @@ class StoreCombinationController
$userBool = 0;//判断当前用户是否在团内 0未在 1在 $userBool = 0;//判断当前用户是否在团内 0未在 1在
$pinkBool = 0;//判断拼团是否成功 0未在 1在 $pinkBool = 0;//判断拼团是否成功 0未在 1在
$user = $request->user(); $user = $request->user();
if(!$id) return app('json')->fail('参数错误'); if (!$id) return app('json')->fail('参数错误');
$pink = StorePink::getPinkUserOne($id); $pink = StorePink::getPinkUserOne($id);
if(!$pink) return app('json')->fail('参数错误'); if (!$pink) return app('json')->fail('参数错误');
if(isset($pink['is_refund']) && $pink['is_refund']) { if (isset($pink['is_refund']) && $pink['is_refund']) {
if($pink['is_refund'] != $pink['id']){ if ($pink['is_refund'] != $pink['id']) {
$id = $pink['is_refund']; $id = $pink['is_refund'];
return $this->pink($request,$id); return $this->pink($request, $id);
}else{ } else {
return app('json')->fail('订单已退款'); return app('json')->fail('订单已退款');
} }
} }
list($pinkAll,$pinkT,$count,$idAll,$uidAll) = StorePink::getPinkMemberAndPinkK($pink); list($pinkAll, $pinkT, $count, $idAll, $uidAll) = StorePink::getPinkMemberAndPinkK($pink);
if($pinkT['status'] == 2){ if ($pinkT['status'] == 2) {
$pinkBool = 1; $pinkBool = 1;
$is_ok = 1; $is_ok = 1;
}else if($pinkT['status'] == 3){ } else if ($pinkT['status'] == 3) {
$pinkBool = -1; $pinkBool = -1;
$is_ok = 0; $is_ok = 0;
}else{ } else {
if($count < 1){//组团完成 if ($count < 1) {//组团完成
$is_ok = 1; $is_ok = 1;
$pinkBool = StorePink::PinkComplete($uidAll,$idAll,$user['uid'],$pinkT); $pinkBool = StorePink::PinkComplete($uidAll, $idAll, $user['uid'], $pinkT);
}else{ } else {
$pinkBool = StorePink::PinkFail($pinkAll,$pinkT,$pinkBool); $pinkBool = StorePink::PinkFail($pinkAll, $pinkT, $pinkBool);
} }
} }
if(!empty($pinkAll)){ if (!empty($pinkAll)) {
foreach ($pinkAll as $v){ foreach ($pinkAll as $v) {
if($v['uid'] == $user['uid']) $userBool = 1; if ($v['uid'] == $user['uid']) $userBool = 1;
} }
} }
if($pinkT['uid'] == $user['uid']) $userBool = 1; if ($pinkT['uid'] == $user['uid']) $userBool = 1;
$combinationOne = StoreCombination::getCombinationOne($pink['cid']); $combinationOne = StoreCombination::getCombinationOne($pink['cid']);
if(!$combinationOne) return app('json')->fail('拼团不存在或已下架'); if (!$combinationOne) return app('json')->fail('拼团不存在或已下架');
$data['userInfo']['uid'] = $user['uid']; $data['userInfo']['uid'] = $user['uid'];
$data['userInfo']['nickname'] = $user['nickname']; $data['userInfo']['nickname'] = $user['nickname'];
$data['userInfo']['avatar'] = $user['avatar']; $data['userInfo']['avatar'] = $user['avatar'];
$data['is_ok'] = $is_ok; $data['is_ok'] = $is_ok;
$data['userBool'] = $userBool; $data['userBool'] = $userBool;
$data['pinkBool'] = $pinkBool; $data['pinkBool'] = $pinkBool;
$data['store_combination'] = $combinationOne->hidden(['mer_id','images','attr','info','sort','sales','stock','add_time','is_host','is_show','is_del','combination','mer_use','is_postage','postage','description','start_time','stop_time','cost','browse','product_price'])->toArray(); $data['store_combination'] = $combinationOne->hidden(['mer_id', 'images', 'attr', 'info', 'sort', 'sales', 'stock', 'add_time', 'is_host', 'is_show', 'is_del', 'combination', 'mer_use', 'is_postage', 'postage', 'description', 'start_time', 'stop_time', 'cost', 'browse', 'product_price'])->toArray();
$data['pinkT'] = $pinkT; $data['pinkT'] = $pinkT;
$data['pinkAll'] = $pinkAll; $data['pinkAll'] = $pinkAll;
$data['count'] = $count <= 0 ? 0 : $count; $data['count'] = $count <= 0 ? 0 : $count;
$data['store_combination_host'] = StoreCombination::getCombinationHost(); $data['store_combination_host'] = StoreCombination::getCombinationHost();
$data['current_pink_order'] = StorePink::getCurrentPink($id,$user['uid']); $data['current_pink_order'] = StorePink::getCurrentPink($id, $user['uid']);
return app('json')->successful($data); return app('json')->successful($data);
} }
@ -159,16 +145,16 @@ class StoreCombinationController
public function remove(Request $request) public function remove(Request $request)
{ {
list($id, $cid) = UtilService::postMore([ list($id, $cid) = UtilService::postMore([
['id',0], ['id', 0],
['cid',0], ['cid', 0],
],$request, true); ], $request, true);
if(!$id || !$cid) return app('json')->fail('缺少参数'); if (!$id || !$cid) return app('json')->fail('缺少参数');
$res = StorePink::removePink($request->uid(),$cid,$id); $res = StorePink::removePink($request->uid(), $cid, $id);
if($res){ if ($res) {
return app('json')->successful('取消成功'); return app('json')->successful('取消成功');
} }
$error = StorePink::getErrorInfo(); $error = StorePink::getErrorInfo();
if(is_array($error)) return app('json')->status($error['status'],$error['msg']); if (is_array($error)) return app('json')->status($error['status'], $error['msg']);
return app('json')->fail($error); return app('json')->fail($error);
} }
@ -180,70 +166,70 @@ class StoreCombinationController
*/ */
public function poster(Request $request) public function poster(Request $request)
{ {
list($pinkId, $from) = UtilService::postMore([['id',0],['from','wechat']],$request,true); list($pinkId, $from) = UtilService::postMore([['id', 0], ['from', 'wechat']], $request, true);
if(!$pinkId) return app('json')->fail('参数错误'); if (!$pinkId) return app('json')->fail('参数错误');
$user = $request->user(); $user = $request->user();
$pinkInfo = StorePink::getPinkUserOne($pinkId); $pinkInfo = StorePink::getPinkUserOne($pinkId);
$storeCombinationInfo = StoreCombination::getCombinationOne($pinkInfo['cid']); $storeCombinationInfo = StoreCombination::getCombinationOne($pinkInfo['cid']);
$data['title'] = $storeCombinationInfo['title']; $data['title'] = $storeCombinationInfo['title'];
$data['image'] = $storeCombinationInfo['image']; $data['image'] = $storeCombinationInfo['image'];
$data['price'] = $pinkInfo['total_price']; $data['price'] = $pinkInfo['total_price'];
$data['label'] = $pinkInfo['people'].'人团'; $data['label'] = $pinkInfo['people'] . '人团';
if($pinkInfo['k_id']) $pinkAll = StorePink::getPinkMember($pinkInfo['k_id']); if ($pinkInfo['k_id']) $pinkAll = StorePink::getPinkMember($pinkInfo['k_id']);
else $pinkAll = StorePink::getPinkMember($pinkInfo['id']); else $pinkAll = StorePink::getPinkMember($pinkInfo['id']);
$count = count($pinkAll)+1; $count = count($pinkAll) + 1;
$data['msg'] = '原价¥'.$storeCombinationInfo['product_price'].' 还差'.(int)bcsub((int)$pinkInfo['people'],$count,0).'人拼团成功'; $data['msg'] = '原价¥' . $storeCombinationInfo['product_price'] . ' 还差' . (int)bcsub((int)$pinkInfo['people'], $count, 0) . '人拼团成功';
try{ try {
$siteUrl = sysConfig('site_url'); $siteUrl = sysConfig('site_url');
if($from == 'routine'){ if ($from == 'routine') {
//小程序 //小程序
$name = $pinkId.'_'.$user['uid'].'_'.$user['is_promoter'].'_pink_share_routine.jpg'; $name = $pinkId . '_' . $user['uid'] . '_' . $user['is_promoter'] . '_pink_share_routine.jpg';
$imageInfo = SystemAttachment::getInfo($name,'name'); $imageInfo = SystemAttachment::getInfo($name, 'name');
if(!$imageInfo){ if (!$imageInfo) {
$valueData = 'id='.$pinkId; $valueData = 'id=' . $pinkId;
if($user['is_promoter'] || sysConfig('store_brokerage_statu')==2) $valueData.='&pid='.$user['uid']; if ($user['is_promoter'] || sysConfig('store_brokerage_statu') == 2) $valueData .= '&pid=' . $user['uid'];
$res = RoutineCode::getPageCode('pages/activity/goods_combination_status/index',$valueData,280); $res = RoutineCode::getPageCode('pages/activity/goods_combination_status/index', $valueData, 280);
if(!$res) return app('json')->fail('二维码生成失败'); if (!$res) return app('json')->fail('二维码生成失败');
$imageInfo = UploadService::getInstance()->setUploadPath('routine/activity/pink/code')->imageStream($name,$res); $imageInfo = UploadService::instance()->setUploadPath('routine/activity/pink/code')->imageStream($name, $res);
if(!is_array($imageInfo)) return app('json')->fail($imageInfo); if (!is_array($imageInfo)) return app('json')->fail($imageInfo);
if($imageInfo['image_type'] == 1) $remoteImage = UtilService::remoteImage($siteUrl.$imageInfo['dir']); if ($imageInfo['image_type'] == 1) $remoteImage = UtilService::remoteImage($siteUrl . $imageInfo['dir']);
else $remoteImage = UtilService::remoteImage($imageInfo['dir']); else $remoteImage = UtilService::remoteImage($imageInfo['dir']);
if(!$remoteImage['status']) return app('json')->fail($remoteImage['msg']); if (!$remoteImage['status']) return app('json')->fail($remoteImage['msg']);
SystemAttachment::attachmentAdd($imageInfo['name'],$imageInfo['size'],$imageInfo['type'],$imageInfo['dir'],$imageInfo['thumb_path'],1,$imageInfo['image_type'],$imageInfo['time'],2); SystemAttachment::attachmentAdd($imageInfo['name'], $imageInfo['size'], $imageInfo['type'], $imageInfo['dir'], $imageInfo['thumb_path'], 1, $imageInfo['image_type'], $imageInfo['time'], 2);
$url = $imageInfo['dir']; $url = $imageInfo['dir'];
}else $url = $imageInfo['att_dir']; } else $url = $imageInfo['att_dir'];
$data['url'] = $url; $data['url'] = $url;
if($imageInfo['image_type'] == 1) if ($imageInfo['image_type'] == 1)
$data['url'] = $siteUrl.$url; $data['url'] = $siteUrl . $url;
$posterImage = UtilService::setShareMarketingPoster($data,'routine/activity/pink/poster'); $posterImage = UtilService::setShareMarketingPoster($data, 'routine/activity/pink/poster');
if(!is_array($posterImage)) return app('json')->fail('海报生成失败'); if (!is_array($posterImage)) return app('json')->fail('海报生成失败');
SystemAttachment::attachmentAdd($posterImage['name'],$posterImage['size'],$posterImage['type'],$posterImage['dir'],$posterImage['thumb_path'],1,$posterImage['image_type'],$posterImage['time'],2); SystemAttachment::attachmentAdd($posterImage['name'], $posterImage['size'], $posterImage['type'], $posterImage['dir'], $posterImage['thumb_path'], 1, $posterImage['image_type'], $posterImage['time'], 2);
if($posterImage['image_type'] == 1) $posterImage['dir'] = $siteUrl.$posterImage['dir']; if ($posterImage['image_type'] == 1) $posterImage['dir'] = $siteUrl . $posterImage['dir'];
$routinePosterImage = UtilService::setHttpType($posterImage['dir'], 0);//小程序推广海报 $routinePosterImage = UtilService::setHttpType($posterImage['dir'], 0);//小程序推广海报
return app('json')->successful(['url'=>$routinePosterImage]); return app('json')->successful(['url' => $routinePosterImage]);
}else if($from == 'wechat'){ } else if ($from == 'wechat') {
//公众号 //公众号
$name = $pinkId.'_'.$user['uid'].'_'.$user['is_promoter'].'_pink_share_wap.jpg'; $name = $pinkId . '_' . $user['uid'] . '_' . $user['is_promoter'] . '_pink_share_wap.jpg';
$imageInfo = SystemAttachment::getInfo($name,'name'); $imageInfo = SystemAttachment::getInfo($name, 'name');
if(!$imageInfo){ if (!$imageInfo) {
$codeUrl = UtilService::setHttpType($siteUrl.'/activity/group_rule/'.$pinkId.'?spread='.$user['uid'], 1);//二维码链接 $codeUrl = UtilService::setHttpType($siteUrl . '/activity/group_rule/' . $pinkId . '?spread=' . $user['uid'], 1);//二维码链接
$imageInfo = UtilService::getQRCodePath($codeUrl, $name); $imageInfo = UtilService::getQRCodePath($codeUrl, $name);
if(!$imageInfo) return app('json')->fail('二维码生成失败'); if (!$imageInfo) return app('json')->fail('二维码生成失败');
SystemAttachment::attachmentAdd($imageInfo['name'],$imageInfo['size'],$imageInfo['type'],$imageInfo['dir'],$imageInfo['thumb_path'],1,$imageInfo['image_type'],$imageInfo['time'],2); SystemAttachment::attachmentAdd($imageInfo['name'], $imageInfo['size'], $imageInfo['type'], $imageInfo['dir'], $imageInfo['thumb_path'], 1, $imageInfo['image_type'], $imageInfo['time'], 2);
$url = $imageInfo['dir']; $url = $imageInfo['dir'];
}else $url = $imageInfo['att_dir']; } else $url = $imageInfo['att_dir'];
$data['url'] = $url; $data['url'] = $url;
if($imageInfo['image_type'] == 1) $data['url'] = $siteUrl.$url; if ($imageInfo['image_type'] == 1) $data['url'] = $siteUrl . $url;
$posterImage = UtilService::setShareMarketingPoster($data,'wap/activity/pink/poster'); $posterImage = UtilService::setShareMarketingPoster($data, 'wap/activity/pink/poster');
if(!is_array($posterImage)) return app('json')->fail('海报生成失败'); if (!is_array($posterImage)) return app('json')->fail('海报生成失败');
SystemAttachment::attachmentAdd($posterImage['name'],$posterImage['size'],$posterImage['type'],$posterImage['dir'],$posterImage['thumb_path'],1,$posterImage['image_type'],$posterImage['time'],2); SystemAttachment::attachmentAdd($posterImage['name'], $posterImage['size'], $posterImage['type'], $posterImage['dir'], $posterImage['thumb_path'], 1, $posterImage['image_type'], $posterImage['time'], 2);
if($posterImage['image_type'] == 1) $posterImage['dir'] = $siteUrl.$posterImage['dir']; if ($posterImage['image_type'] == 1) $posterImage['dir'] = $siteUrl . $posterImage['dir'];
$wapPosterImage = UtilService::setHttpType($posterImage['dir'], 1);//公众号推广海报 $wapPosterImage = UtilService::setHttpType($posterImage['dir'], 1);//公众号推广海报
return app('json')->successful(['url'=>$wapPosterImage]); return app('json')->successful(['url' => $wapPosterImage]);
} }
return app('json')->fail('参数错误'); return app('json')->fail('参数错误');
}catch (\Exception $e){ } catch (\Exception $e) {
return app('json')->fail(['line'=>$e->getLine(),'message'=>$e->getMessage()]); return app('json')->fail(['line' => $e->getLine(), 'message' => $e->getMessage()]);
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace app\api\controller\activity; namespace app\api\controller\activity;
use app\admin\model\system\SystemAttachment; use app\admin\model\system\SystemAttachment;
@ -7,6 +8,7 @@ use app\models\store\StoreProductReply;
use app\models\store\StoreSeckill; use app\models\store\StoreSeckill;
use app\Request; use app\Request;
use crmeb\services\GroupDataService; use crmeb\services\GroupDataService;
use crmeb\services\QrcodeService;
use crmeb\services\SystemConfigService; use crmeb\services\SystemConfigService;
use crmeb\services\UtilService; use crmeb\services\UtilService;
@ -29,39 +31,39 @@ class StoreSeckillController
//秒杀时间段 //秒杀时间段
$seckillTime = GroupDataService::getData('routine_seckill_time') ?? []; $seckillTime = GroupDataService::getData('routine_seckill_time') ?? [];
$seckillTimeIndex = 0; $seckillTimeIndex = 0;
if(count($seckillTime)){ if (count($seckillTime)) {
foreach($seckillTime as $key=>&$value){ foreach ($seckillTime as $key => &$value) {
$currentHour = date('H'); $currentHour = date('H');
$activityEndHour = bcadd((int)$value['time'],(int)$value['continued'],0); $activityEndHour = bcadd((int)$value['time'], (int)$value['continued'], 0);
if($activityEndHour > 24){ if ($activityEndHour > 24) {
$value['time'] = strlen((int)$value['time']) == 2 ? (int)$value['time'].':00' : '0'.(int)$value['time'].':00'; $value['time'] = strlen((int)$value['time']) == 2 ? (int)$value['time'] . ':00' : '0' . (int)$value['time'] . ':00';
$value['state'] = '即将开始'; $value['state'] = '即将开始';
$value['status'] = 2; $value['status'] = 2;
$value['stop'] = (int)bcadd(strtotime(date('Y-m-d')),bcmul($activityEndHour,3600,0)); $value['stop'] = (int)bcadd(strtotime(date('Y-m-d')), bcmul($activityEndHour, 3600, 0));
}else{ } else {
if($currentHour >= (int)$value['time'] && $currentHour < $activityEndHour){ if ($currentHour >= (int)$value['time'] && $currentHour < $activityEndHour) {
$value['time'] = strlen((int)$value['time']) == 2 ? (int)$value['time'].':00' : '0'.(int)$value['time'].':00'; $value['time'] = strlen((int)$value['time']) == 2 ? (int)$value['time'] . ':00' : '0' . (int)$value['time'] . ':00';
$value['state'] = '抢购中'; $value['state'] = '抢购中';
$value['stop'] = (int)bcadd(strtotime(date('Y-m-d')),bcmul($activityEndHour,3600,0)); $value['stop'] = (int)bcadd(strtotime(date('Y-m-d')), bcmul($activityEndHour, 3600, 0));
$value['status'] = 1; $value['status'] = 1;
if(!$seckillTimeIndex) $seckillTimeIndex = $key; if (!$seckillTimeIndex) $seckillTimeIndex = $key;
}else if($currentHour < (int)$value['time']){ } else if ($currentHour < (int)$value['time']) {
$value['time'] = strlen((int)$value['time']) == 2 ? (int)$value['time'].':00' : '0'.(int)$value['time'].':00'; $value['time'] = strlen((int)$value['time']) == 2 ? (int)$value['time'] . ':00' : '0' . (int)$value['time'] . ':00';
$value['state'] = '即将开始'; $value['state'] = '即将开始';
$value['status'] = 2; $value['status'] = 2;
$value['stop'] = (int)bcadd(strtotime(date('Y-m-d')),bcmul($activityEndHour,3600,0)); $value['stop'] = (int)bcadd(strtotime(date('Y-m-d')), bcmul($activityEndHour, 3600, 0));
}else if($currentHour >= $activityEndHour){ } else if ($currentHour >= $activityEndHour) {
$value['time'] = strlen((int)$value['time']) == 2 ? (int)$value['time'].':00' : '0'.(int)$value['time'].':00'; $value['time'] = strlen((int)$value['time']) == 2 ? (int)$value['time'] . ':00' : '0' . (int)$value['time'] . ':00';
$value['state'] = '已结束'; $value['state'] = '已结束';
$value['status'] = 0; $value['status'] = 0;
$value['stop'] = (int)bcadd(strtotime(date('Y-m-d')),bcmul($activityEndHour,3600,0)); $value['stop'] = (int)bcadd(strtotime(date('Y-m-d')), bcmul($activityEndHour, 3600, 0));
} }
} }
} }
} }
$data['lovely'] = sysConfig('seckill_header_banner'); $data['lovely'] = sysConfig('seckill_header_banner');
if(strstr($data['lovely'],'http') === false && strlen(trim($data['lovely']))) $data['lovely'] = sysConfig('site_url').$data['lovely']; if (strstr($data['lovely'], 'http') === false && strlen(trim($data['lovely']))) $data['lovely'] = sysConfig('site_url') . $data['lovely'];
$data['lovely'] = str_replace('\\','/',$data['lovely']); $data['lovely'] = str_replace('\\', '/', $data['lovely']);
$data['seckillTime'] = $seckillTime; $data['seckillTime'] = $seckillTime;
$data['seckillTimeIndex'] = $seckillTimeIndex; $data['seckillTimeIndex'] = $seckillTimeIndex;
return app('json')->successful($data); return app('json')->successful($data);
@ -79,18 +81,18 @@ class StoreSeckillController
public function lst(Request $request, $time) public function lst(Request $request, $time)
{ {
list($page, $limit) = UtilService::getMore([ list($page, $limit) = UtilService::getMore([
['page',0], ['page', 0],
['limit',0], ['limit', 0],
],$request, true); ], $request, true);
if(!$time) return app('json')->fail('参数错误'); if (!$time) return app('json')->fail('参数错误');
$timeInfo = GroupDataService::getDataNumber((int)$time); $timeInfo = GroupDataService::getDataNumber((int)$time);
$activityEndHour = bcadd((int)$timeInfo['time'],(int)$timeInfo['continued'],0); $activityEndHour = bcadd((int)$timeInfo['time'], (int)$timeInfo['continued'], 0);
$startTime = bcadd(strtotime(date('Y-m-d')),bcmul($timeInfo['time'],3600,0)); $startTime = bcadd(strtotime(date('Y-m-d')), bcmul($timeInfo['time'], 3600, 0));
$stopTime = bcadd(strtotime(date('Y-m-d')),bcmul($activityEndHour,3600,0)); $stopTime = bcadd(strtotime(date('Y-m-d')), bcmul($activityEndHour, 3600, 0));
$seckillInfo = StoreSeckill::seckillList($startTime, $stopTime, $page, $limit); $seckillInfo = StoreSeckill::seckillList($startTime, $stopTime, $page, $limit);
if(count($seckillInfo)){ if (count($seckillInfo)) {
foreach ($seckillInfo as $key=>&$item){ foreach ($seckillInfo as $key => &$item) {
$percent = (int)bcmul(bcdiv($item['sales'],bcadd($item['stock'],$item['sales'],0),2),100,0); $percent = (int)bcmul(bcdiv($item['sales'], bcadd($item['stock'], $item['sales'], 0), 2), 100, 0);
$item['percent'] = $percent ? $percent : 10; $item['percent'] = $percent ? $percent : 10;
} }
} }
@ -103,38 +105,23 @@ class StoreSeckillController
* @param $id * @param $id
* @return mixed * @return mixed
*/ */
public function detail(Request $request, $id,$time = 0){ public function detail(Request $request, $id, $time = 0)
if(!$id || !($storeInfo = StoreSeckill::getValidProduct($id))) return app('json')->fail('商品不存在或已下架!'); {
$storeInfo = $storeInfo->hidden(['cost','add_time','is_del'])->toArray(); if (!$id || !($storeInfo = StoreSeckill::getValidProduct($id))) return app('json')->fail('商品不存在或已下架!');
$storeInfo = $storeInfo->hidden(['cost', 'add_time', 'is_del'])->toArray();
//公众号
$name = $id.'_seckill_detail_wap.jpg';
$imageInfo = SystemAttachment::getInfo($name,'name');
$siteUrl = sysConfig('site_url'); $siteUrl = sysConfig('site_url');
if(!$imageInfo){
$codeUrl = UtilService::setHttpType($siteUrl.'/activity/seckill_detail/'.$id.'/'.$time, 1);//二维码链接
$imageInfo = UtilService::getQRCodePath($codeUrl, $name);
if(is_array($imageInfo)){
SystemAttachment::attachmentAdd($imageInfo['name'],$imageInfo['size'],$imageInfo['type'],$imageInfo['dir'],$imageInfo['thumb_path'],1,$imageInfo['image_type'],$imageInfo['time'],2);
$url = $imageInfo['dir'];
}else {
$url = '';
$imageInfo = ['image_type'=>0];
}
}else $url = $imageInfo['att_dir'];
if($imageInfo['image_type'] == 1) $url = $siteUrl.$url;
$storeInfo['image'] = UtilService::setSiteUrl($storeInfo['image'], $siteUrl); $storeInfo['image'] = UtilService::setSiteUrl($storeInfo['image'], $siteUrl);
$storeInfo['image_base'] = UtilService::setSiteUrl($storeInfo['image'], $siteUrl); $storeInfo['image_base'] = UtilService::setSiteUrl($storeInfo['image'], $siteUrl);
$storeInfo['code_base'] = $url; $storeInfo['code_base'] = QrcodeService::getWechatQrcodePath($id . '_seckill_detail_wap.jpg', '/activity/seckill_detail/' . $id . '/' . $time);
$uid = $request->uid(); $uid = $request->uid();
$storeInfo['userLike'] = StoreProductRelation::isProductRelation($id, $uid, 'like', 'product_seckill'); $storeInfo['userLike'] = StoreProductRelation::isProductRelation($id, $uid, 'like', 'product_seckill');
$storeInfo['like_num'] = StoreProductRelation::productRelationNum($id,'like','product_seckill'); $storeInfo['like_num'] = StoreProductRelation::productRelationNum($id, 'like', 'product_seckill');
$storeInfo['userCollect'] = StoreProductRelation::isProductRelation($id, $uid,'collect','product_seckill'); $storeInfo['userCollect'] = StoreProductRelation::isProductRelation($id, $uid, 'collect', 'product_seckill');
$storeInfo['uid'] = $uid; $storeInfo['uid'] = $uid;
$data['storeInfo'] = $storeInfo; $data['storeInfo'] = $storeInfo;
setView($uid,$id,$storeInfo['product_id'],'viwe'); setView($uid, $id, $storeInfo['product_id'], 'viwe');
$data['reply'] = StoreProductReply::getRecProductReply($storeInfo['product_id']); $data['reply'] = StoreProductReply::getRecProductReply($storeInfo['product_id']);
$data['replyCount'] = StoreProductReply::productValidWhere()->where('product_id',$storeInfo['product_id'])->count(); $data['replyCount'] = StoreProductReply::productValidWhere()->where('product_id', $storeInfo['product_id'])->count();
return app('json')->successful($data); return app('json')->successful($data);
} }
} }

View File

@ -516,7 +516,7 @@ class StoreOrderController
else if($cartInfo['cart_info']['seckill_id']) $productId = $cartInfo['cart_info']['product_id']; else if($cartInfo['cart_info']['seckill_id']) $productId = $cartInfo['cart_info']['product_id'];
else if($cartInfo['cart_info']['bargain_id']) $productId = $cartInfo['cart_info']['product_id']; else if($cartInfo['cart_info']['bargain_id']) $productId = $cartInfo['cart_info']['product_id'];
else $productId = $cartInfo['product_id']; else $productId = $cartInfo['product_id'];
if($group['pics']) $group['pics'] = json_encode(explode(',',$group['pics'])); if($group['pics']) $group['pics'] = json_encode(is_array($group['pics']) ? $group['pics']: explode(',',$group['pics']));
$group = array_merge($group,[ $group = array_merge($group,[
'uid'=>$uid, 'uid'=>$uid,
'oid'=>$cartInfo['oid'], 'oid'=>$cartInfo['oid'],

View File

@ -22,8 +22,8 @@ class ArticleController
public function lst(Request $request, $cid) public function lst(Request $request, $cid)
{ {
list($page, $limit) = UtilService::getMore([ list($page, $limit) = UtilService::getMore([
['page',0], ['page',1],
['limit',0], ['limit',10],
],$request, true); ],$request, true);
$list = Article::cidByArticleList($cid,$page,$limit,"id,title,image_input,visit,from_unixtime(add_time,'%Y-%m-%d %H:%i') as add_time,synopsis,url") ?? []; $list = Article::cidByArticleList($cid,$page,$limit,"id,title,image_input,visit,from_unixtime(add_time,'%Y-%m-%d %H:%i') as add_time,synopsis,url") ?? [];
if(is_object($list)) $list = $list->toArray(); if(is_object($list)) $list = $list->toArray();

View File

@ -9,7 +9,7 @@ class CategoryController
{ {
public function category(Request $request) public function category(Request $request)
{ {
$cateogry = StoreCategory::with('children')->where('is_show',1)->where('pid',0)->select(); $cateogry = StoreCategory::with('children')->where('is_show',1)->order('sort desc,id desc')->where('pid',0)->select();
return app('json')->success($cateogry->hidden(['add_time','is_show','sort','children.sort','children.add_time','children.pid','children.is_show'])->toArray()); return app('json')->success($cateogry->hidden(['add_time','is_show','sort','children.sort','children.add_time','children.pid','children.is_show'])->toArray());
} }
} }

View File

@ -10,6 +10,7 @@ use app\models\store\StoreProductRelation;
use app\models\store\StoreProductReply; use app\models\store\StoreProductReply;
use app\Request; use app\Request;
use crmeb\services\GroupDataService; use crmeb\services\GroupDataService;
use crmeb\services\QrcodeService;
use crmeb\services\SystemConfigService; use crmeb\services\SystemConfigService;
use crmeb\services\UtilService; use crmeb\services\UtilService;
@ -46,86 +47,67 @@ class StoreProductController
* @param Request $request * @param Request $request
* @param $id * @param $id
* @return mixed * @return mixed
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/ */
public function code(Request $request, $id) public function code(Request $request, $id)
{ {
if (!$id || !($storeInfo = StoreProduct::getValidProduct($id,'id'))) return app('json')->fail('商品不存在或已下架'); if (!$id || !($storeInfo = StoreProduct::getValidProduct($id, 'id'))) return app('json')->fail('商品不存在或已下架');
$userType = $request->get('user_type','wechat'); $userType = $request->get('user_type', 'wechat');
$user = $request->user(); $user = $request->user();
try{ try {
switch ($userType){ switch ($userType) {
case 'wechat': case 'wechat':
//公众号 //公众号
$name = $id.'_product_detail_'.$user['uid'].'_is_promoter_'.$user['is_promoter'].'_wap.jpg'; $name = $id . '_product_detail_' . $user['uid'] . '_is_promoter_' . $user['is_promoter'] . '_wap.jpg';
$imageInfo = SystemAttachment::getInfo($name,'name'); $url = QrcodeService::getWechatQrcodePath($name, '/detail/' . $id . '?spread=' . $user['uid']);
$siteUrl = sysConfig('site_url'); if ($url === false)
if(!$imageInfo){ return app('json')->fail('二维码生成失败');
$codeUrl = UtilService::setHttpType($siteUrl.'/detail/'.$id.'?spread='.$user['uid'], 1);//二维码链接 else
$imageInfo = UtilService::getQRCodePath($codeUrl, $name); return app('json')->successful(['code' => UtilService::setImageBase64($url)]);
if(is_string($imageInfo)) return app('json')->fail('二维码生成失败');
SystemAttachment::attachmentAdd($imageInfo['name'],$imageInfo['size'],$imageInfo['type'],$imageInfo['dir'],$imageInfo['thumb_path'],1,$imageInfo['image_type'],$imageInfo['time'],2);
$url = $imageInfo['dir'];
}else $url = $imageInfo['att_dir'];
if($imageInfo['image_type'] == 1) $url = $siteUrl.$url;
return app('json')->successful(['code'=>UtilService::setImageBase64($url)]);
break; break;
case 'routine': case 'routine':
//小程序 //小程序
$name = $id.'_'.$user['uid'].'_'.$user['is_promoter'].'_product.jpg'; $name = $id . '_' . $user['uid'] . '_' . $user['is_promoter'] . '_product.jpg';
$imageInfo = SystemAttachment::getInfo($name,'name'); $imageInfo = SystemAttachment::getInfo($name, 'name');
$siteUrl = sysConfig('site_url').DS; $siteUrl = sysConfig('site_url') . DS;
if(!$imageInfo){ if (!$imageInfo) {
$data='id='.$id; $data = 'id=' . $id;
if($user['is_promoter'] || sysConfig('store_brokerage_statu')==2) $data.='&pid='.$user['uid']; if ($user['is_promoter'] || sysConfig('store_brokerage_statu') == 2) $data .= '&pid=' . $user['uid'];
$res = \app\models\routine\RoutineCode::getPageCode('pages/goods_details/index',$data,280); $res = \app\models\routine\RoutineCode::getPageCode('pages/goods_details/index', $data, 280);
if(!$res) return app('json')->fail('二维码生成失败'); if (!$res) return app('json')->fail('二维码生成失败');
$imageInfo = \crmeb\services\UploadService::getInstance()->setUploadPath('routine/product')->imageStream($name,$res); $imageInfo = \crmeb\services\UploadService::instance()->setUploadPath('routine/product')->imageStream($name, $res);
if(is_string($imageInfo)) return app('json')->fail($imageInfo); if (is_string($imageInfo)) return app('json')->fail($imageInfo);
if($imageInfo['image_type'] == 1) $remoteImage = UtilService::remoteImage($siteUrl.$imageInfo['dir']); if ($imageInfo['image_type'] == 1) $remoteImage = UtilService::remoteImage($siteUrl . $imageInfo['dir']);
else $remoteImage = UtilService::remoteImage($imageInfo['dir']); else $remoteImage = UtilService::remoteImage($imageInfo['dir']);
if(!$remoteImage['status']) return app('json')->fail('小程序二维码未能生成'); if (!$remoteImage['status']) return app('json')->fail('小程序二维码未能生成');
SystemAttachment::attachmentAdd($imageInfo['name'],$imageInfo['size'],$imageInfo['type'],$imageInfo['dir'],$imageInfo['thumb_path'],1,$imageInfo['image_type'],$imageInfo['time'],2); SystemAttachment::attachmentAdd($imageInfo['name'], $imageInfo['size'], $imageInfo['type'], $imageInfo['dir'], $imageInfo['thumb_path'], 1, $imageInfo['image_type'], $imageInfo['time'], 2);
$url = $imageInfo['dir']; $url = $imageInfo['dir'];
}else $url = $imageInfo['att_dir']; } else $url = $imageInfo['att_dir'];
if($imageInfo['image_type'] == 1) $url = $siteUrl.$url; if ($imageInfo['image_type'] == 1) $url = $siteUrl . $url;
return app('json')->successful(['code'=>$url]); return app('json')->successful(['code' => $url]);
} }
}catch (\Exception $e){ } catch (\Exception $e) {
return app('json')->fail($e->getMessage(),[ return app('json')->fail($e->getMessage(), [
'code'=>$e->getCode(), 'code' => $e->getCode(),
'line'=>$e->getLine(), 'line' => $e->getLine(),
'message'=>$e->getMessage() 'message' => $e->getMessage()
]); ]);
} }
} }
public function detail(Request $request, $id,$type = 0) /**
* 产品详情
* @param Request $request
* @param $id
* @param int $type
* @return mixed
*/
public function detail(Request $request, $id, $type = 0)
{ {
if (!$id || !($storeInfo = StoreProduct::getValidProduct($id))) return app('json')->fail('商品不存在或已下架'); if (!$id || !($storeInfo = StoreProduct::getValidProduct($id))) return app('json')->fail('商品不存在或已下架');
//公众号
$name = $id.'_product_detail_wap.jpg';
$imageInfo = SystemAttachment::getInfo($name,'name');
$siteUrl = sysConfig('site_url'); $siteUrl = sysConfig('site_url');
if(!$imageInfo){
$codeUrl = UtilService::setHttpType($siteUrl.'/detail/'.$id, 1);//二维码链接
$imageInfo = UtilService::getQRCodePath($codeUrl, $name);
if(is_array($imageInfo)){
SystemAttachment::attachmentAdd($imageInfo['name'],$imageInfo['size'],$imageInfo['type'],$imageInfo['dir'],$imageInfo['thumb_path'],1,$imageInfo['image_type'],$imageInfo['time'],2);
$url = $imageInfo['dir'];
}else {
$url = '';
$imageInfo = ['image_type'=>0];
}
}else $url = $imageInfo['att_dir'];
if($imageInfo['image_type'] == 1) $url = $siteUrl.$url;
$storeInfo['image'] = UtilService::setSiteUrl($storeInfo['image'], $siteUrl); $storeInfo['image'] = UtilService::setSiteUrl($storeInfo['image'], $siteUrl);
$storeInfo['image_base'] = UtilService::setSiteUrl($storeInfo['image'], $siteUrl); $storeInfo['image_base'] = UtilService::setSiteUrl($storeInfo['image'], $siteUrl);
$storeInfo['code_base'] = $url; $storeInfo['code_base'] = QrcodeService::getWechatQrcodePath($id . '_product_detail_wap.jpg', '/detail/' . $id);
$uid = $request->uid(); $uid = $request->uid();
$data['uid'] = $uid; $data['uid'] = $uid;
//替换windows服务器下正反斜杠问题导致图片无法显示 //替换windows服务器下正反斜杠问题导致图片无法显示
@ -134,39 +116,40 @@ class StoreProductController
}, $storeInfo['description']); }, $storeInfo['description']);
$storeInfo['userCollect'] = StoreProductRelation::isProductRelation($id, $uid, 'collect'); $storeInfo['userCollect'] = StoreProductRelation::isProductRelation($id, $uid, 'collect');
$storeInfo['userLike'] = StoreProductRelation::isProductRelation($id, $uid, 'like'); $storeInfo['userLike'] = StoreProductRelation::isProductRelation($id, $uid, 'like');
list($productAttr, $productValue) = StoreProductAttr::getProductAttrDetail($id,$uid,$type); list($productAttr, $productValue) = StoreProductAttr::getProductAttrDetail($id, $uid, $type);
setView($uid, $id, $storeInfo['cate_id'], 'viwe'); setView($uid, $id, $storeInfo['cate_id'], 'viwe');
$data['storeInfo'] = StoreProduct::setLevelPrice($storeInfo, $uid, true); $data['storeInfo'] = StoreProduct::setLevelPrice($storeInfo, $uid, true);
$data['similarity'] = StoreProduct::cateIdBySimilarityProduct($storeInfo['cate_id'], 'id,store_name,image,price,sales,ficti', 4); $data['similarity'] = StoreProduct::cateIdBySimilarityProduct($storeInfo['cate_id'], 'id,store_name,image,price,sales,ficti', 4);
$data['productAttr'] = $productAttr; $data['productAttr'] = $productAttr;
$data['productValue'] = $productValue; $data['productValue'] = $productValue;
$data['priceName'] = 0; $data['priceName'] = 0;
if($uid){ if ($uid) {
$storeBrokerageStatus = sysConfig('store_brokerage_statu') ?? 1; $storeBrokerageStatus = sysConfig('store_brokerage_statu') ?? 1;
if($storeBrokerageStatus == 2) if ($storeBrokerageStatus == 2)
$data['priceName'] = StoreProduct::getPacketPrice($storeInfo, $productValue); $data['priceName'] = StoreProduct::getPacketPrice($storeInfo, $productValue);
else{ else {
$user = $request->user(); $user = $request->user();
if($user->is_promoter) if ($user->is_promoter)
$data['priceName'] = StoreProduct::getPacketPrice($storeInfo, $productValue); $data['priceName'] = StoreProduct::getPacketPrice($storeInfo, $productValue);
} }
if(!strlen(trim($data['priceName']))) if (!strlen(trim($data['priceName'])))
$data['priceName'] = 0; $data['priceName'] = 0;
} }
$data['reply'] = StoreProductReply::getRecProductReply($storeInfo['id']); $data['reply'] = StoreProductReply::getRecProductReply($storeInfo['id']);
$data['replyCount'] = StoreProductReply::productValidWhere()->where('product_id', $storeInfo['id'])->count(); $data['replyCount'] = StoreProductReply::productValidWhere()->where('product_id', $storeInfo['id'])->count();
if ($data['replyCount']) { if ($data['replyCount']) {
$goodReply = StoreProductReply::productValidWhere()->where('product_id', $storeInfo['id'])->where('product_score', 5)->count(); $goodReply = StoreProductReply::productValidWhere()->where('product_id', $storeInfo['id'])->where('product_score', 5)->count();
$data['replyChance'] = $goodReply; $data['replyChance'] = $goodReply;
if($goodReply){ if ($goodReply) {
$data['replyChance'] = bcdiv($goodReply, $data['replyCount'], 2); $data['replyChance'] = bcdiv($goodReply, $data['replyCount'], 2);
$data['replyChance'] = bcmul($data['replyChance'], 100, 2); $data['replyChance'] = bcmul($data['replyChance'], 100, 2);
} }
} else $data['replyChance'] = 0; } else $data['replyChance'] = 0;
$data['mer_id'] = $storeInfo['mer_id']; $data['mer_id'] = $storeInfo['mer_id'];
$data['system_store'] = ($res = SystemStore::getStoreDispose()) ? $res : []; $data['system_store'] = ($res = SystemStore::getStoreDispose()) ? $res : [];
$data['good_list'] = StoreProduct::getGoodList(18,'image,store_name,price,id,ot_price'); $data['good_list'] = StoreProduct::getGoodList(18, 'image,store_name,price,id,ot_price');
$data['mapKey'] = sysConfig('tengxun_map_key'); $data['mapKey'] = sysConfig('tengxun_map_key');
$data['store_self_mention'] = (int)sysConfig('store_self_mention') ?? 0;//门店自提是否开启
return app('json')->successful($data); return app('json')->successful($data);
} }
@ -182,11 +165,11 @@ class StoreProductController
public function product_hot(Request $request) public function product_hot(Request $request)
{ {
list($page, $limit) = UtilService::getMore([ list($page, $limit) = UtilService::getMore([
['page',0], ['page', 0],
['limit',0] ['limit', 0]
], $request, true); ], $request, true);
if(!$limit) return app('json')->successful([]); if (!$limit) return app('json')->successful([]);
$productHot = StoreProduct::getHotProductLoading('id,image,store_name,cate_id,price,unit_name,ot_price',(int)$page,(int)$limit); $productHot = StoreProduct::getHotProductLoading('id,image,store_name,cate_id,price,unit_name,ot_price', (int)$page, (int)$limit);
return app('json')->successful($productHot); return app('json')->successful($productHot);
} }
@ -199,21 +182,21 @@ class StoreProductController
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function groom_list(Request $request,$type) public function groom_list(Request $request, $type)
{ {
$info['banner'] = []; $info['banner'] = [];
$info['list'] = []; $info['list'] = [];
if($type == 1){//TODO 精品推荐 if ($type == 1) {//TODO 精品推荐
$info['banner'] = GroupDataService::getData('routine_home_bast_banner')?:[];//TODO 首页精品推荐图片 $info['banner'] = GroupDataService::getData('routine_home_bast_banner') ?: [];//TODO 首页精品推荐图片
$info['list'] = StoreProduct::getBestProduct('id,image,store_name,cate_id,price,ot_price,IFNULL(sales,0) + IFNULL(ficti,0) as sales,unit_name,sort');//TODO 精品推荐个数 $info['list'] = StoreProduct::getBestProduct('id,image,store_name,cate_id,price,ot_price,IFNULL(sales,0) + IFNULL(ficti,0) as sales,unit_name,sort');//TODO 精品推荐个数
}else if($type == 2){//TODO 热门榜单 } else if ($type == 2) {//TODO 热门榜单
$info['banner'] = GroupDataService::getData('routine_home_hot_banner')?:[];//TODO 热门榜单 猜你喜欢推荐图片 $info['banner'] = GroupDataService::getData('routine_home_hot_banner') ?: [];//TODO 热门榜单 猜你喜欢推荐图片
$info['list'] = StoreProduct::getHotProduct('id,image,store_name,cate_id,price,ot_price,unit_name,sort,IFNULL(sales,0) + IFNULL(ficti,0) as sales',0,$request->uid());//TODO 热门榜单 猜你喜欢 $info['list'] = StoreProduct::getHotProduct('id,image,store_name,cate_id,price,ot_price,unit_name,sort,IFNULL(sales,0) + IFNULL(ficti,0) as sales', 0, $request->uid());//TODO 热门榜单 猜你喜欢
}else if($type == 3){//TODO 首发新品 } else if ($type == 3) {//TODO 首发新品
$info['banner'] = GroupDataService::getData('routine_home_new_banner')?:[];//TODO 首发新品推荐图片 $info['banner'] = GroupDataService::getData('routine_home_new_banner') ?: [];//TODO 首发新品推荐图片
$info['list'] = StoreProduct::getNewProduct('id,image,store_name,cate_id,price,ot_price,unit_name,sort,IFNULL(sales,0) + IFNULL(ficti,0) as sales',0,$request->uid());//TODO 首发新品 $info['list'] = StoreProduct::getNewProduct('id,image,store_name,cate_id,price,ot_price,unit_name,sort,IFNULL(sales,0) + IFNULL(ficti,0) as sales', 0, $request->uid());//TODO 首发新品
}else if($type == 4){//TODO 促销单品 } else if ($type == 4) {//TODO 促销单品
$info['banner'] = GroupDataService::getData('routine_home_benefit_banner')?:[];//TODO 促销单品推荐图片 $info['banner'] = GroupDataService::getData('routine_home_benefit_banner') ?: [];//TODO 促销单品推荐图片
$info['list'] = StoreProduct::getBenefitProduct('id,image,store_name,cate_id,price,ot_price,stock,unit_name,sort');//TODO 促销单品 $info['list'] = StoreProduct::getBenefitProduct('id,image,store_name,cate_id,price,ot_price,stock,unit_name,sort');//TODO 促销单品
} }
return app('json')->successful($info); return app('json')->successful($info);
@ -226,9 +209,10 @@ class StoreProductController
*/ */
public function reply_config($id) public function reply_config($id)
{ {
if(!$id || !is_numeric($id)) return app('json')->fail('参数错误!'); if (!$id || !is_numeric($id)) return app('json')->fail('参数错误!');
return app('json')->successful(StoreProductReply::productReplyCount($id)); return app('json')->successful(StoreProductReply::productReplyCount($id));
} }
/** /**
* 获取产品评论 * 获取产品评论
* @param Request $request * @param Request $request
@ -239,10 +223,10 @@ class StoreProductController
public function reply_list(Request $request, $id) public function reply_list(Request $request, $id)
{ {
list($page, $limit, $type) = UtilService::getMore([ list($page, $limit, $type) = UtilService::getMore([
['page',0],['limit',0],['type',0] ['page', 0], ['limit', 0], ['type', 0]
], $request, true); ], $request, true);
if(!$id || !is_numeric($id)) return app('json')->fail('参数错误!'); if (!$id || !is_numeric($id)) return app('json')->fail('参数错误!');
$list = StoreProductReply::getProductReplyList($id,(int)$type,$page,$limit); $list = StoreProductReply::getProductReplyList($id, (int)$type, $page, $limit);
return app('json')->successful($list); return app('json')->successful($list);
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace app\api\controller\user; namespace app\api\controller\user;
use app\admin\model\system\SystemAttachment; use app\admin\model\system\SystemAttachment;
@ -26,28 +27,28 @@ class UserBillController
* @param Request $request * @param Request $request
* @return mixed * @return mixed
*/ */
public function commission(Request $request) public function commission(Request $request)
{ {
$uid = $request->uid(); $uid = $request->uid();
$lastDayCount = UserBill::yesterdayCommissionSum($uid);//昨天的佣金 $lastDayCount = UserBill::yesterdayCommissionSum($uid);//昨天的佣金
$extractCount = UserExtract::extractSum($uid);//累计提现金额 $extractCount = UserExtract::extractSum($uid);//累计提现金额
$commissionCount = UserBill::getBrokerage($uid);//获取总佣金 $commissionCount = UserBill::getBrokerage($uid);//获取总佣金
if($commissionCount > 0){ if ($commissionCount > 0) {
$rechargeCount = UserBill::getRecharge($uid);//累计充值 $rechargeCount = UserBill::getRecharge($uid);//累计充值
$orderYuePrice = StoreOrder::getOrderStatusYueSum($uid);//余额累计消费 $orderYuePrice = StoreOrder::getOrderStatusYueSum($uid);//余额累计消费
$systemAdd = UserBill::getSystemAdd($uid);//后台添加余额 $systemAdd = UserBill::getSystemAdd($uid);//后台添加余额
$yueCount = bcadd($rechargeCount,$systemAdd,2);// 后台添加余额 + 累计充值 = 非佣金的总金额 $yueCount = bcadd($rechargeCount, $systemAdd, 2);// 后台添加余额 + 累计充值 = 非佣金的总金额
$orderYuePrice = $yueCount > $orderYuePrice ? 0 : bcsub($orderYuePrice,$yueCount,2);// 余额累计消费(使用佣金消费的金额) $orderYuePrice = $yueCount > $orderYuePrice ? 0 : bcsub($orderYuePrice, $yueCount, 2);// 余额累计消费(使用佣金消费的金额)
$commissionCount = bcsub($commissionCount, $extractCount,2);//减去已提现金额 $commissionCount = bcsub($commissionCount, $extractCount, 2);//减去已提现金额
$extractPriceCount = UserExtract::userExtractTotalPrice($uid,0); $extractPriceCount = UserExtract::userExtractTotalPrice($uid, 0);
$commissionCount = $extractPriceCount < $commissionCount ? bcsub($commissionCount, $extractPriceCount,2) : 0;//减去审核中的提现金额 $commissionCount = $extractPriceCount < $commissionCount ? bcsub($commissionCount, $extractPriceCount, 2) : 0;//减去审核中的提现金额
$commissionCount = $commissionCount > $orderYuePrice ? bcsub($commissionCount, $orderYuePrice,2) : 0;//减掉余额支付 $commissionCount = $commissionCount > $orderYuePrice ? bcsub($commissionCount, $orderYuePrice, 2) : 0;//减掉余额支付
} }
$data['lastDayCount'] = $lastDayCount; $data['lastDayCount'] = $lastDayCount;
$data['extractCount'] = $extractCount; $data['extractCount'] = $extractCount;
$data['commissionCount'] = $commissionCount; $data['commissionCount'] = $commissionCount;
return app('json')->successful($data); return app('json')->successful($data);
} }
/** /**
@ -65,12 +66,12 @@ class UserBillController
public function spread_people(Request $request) public function spread_people(Request $request)
{ {
$spreadInfo = UtilService::postMore([ $spreadInfo = UtilService::postMore([
['page',1], ['page', 1],
['limit',20], ['limit', 20],
['grade',0], ['grade', 0],
['keyword',''], ['keyword', ''],
['sort',''], ['sort', ''],
],$request); ], $request);
$uid = $request->uid(); $uid = $request->uid();
$data['list'] = User::getUserSpreadGrade($uid, $spreadInfo['grade'], $spreadInfo['sort'], $spreadInfo['keyword'], $spreadInfo['page'], $spreadInfo['limit']); $data['list'] = User::getUserSpreadGrade($uid, $spreadInfo['grade'], $spreadInfo['sort'], $spreadInfo['keyword'], $spreadInfo['page'], $spreadInfo['limit']);
$data['total'] = User::getSpreadCount($uid); $data['total'] = User::getSpreadCount($uid);
@ -86,19 +87,19 @@ class UserBillController
public function spread_order(Request $request) public function spread_order(Request $request)
{ {
$orderInfo = UtilService::postMore([ $orderInfo = UtilService::postMore([
['page',1], ['page', 1],
['limit',20], ['limit', 20],
['category','now_money'], ['category', 'now_money'],
['type','brokerage'], ['type', 'brokerage'],
],$request); ], $request);
$data['list'] = []; $data['list'] = [];
$data['count'] = 0; $data['count'] = 0;
$uid = $request->uid(); $uid = $request->uid();
$data['list'] = UserBill::getRecordList($uid, $orderInfo['page'], $orderInfo['limit'], $orderInfo['category'], $orderInfo['type']); $data['list'] = UserBill::getRecordList($uid, $orderInfo['page'], $orderInfo['limit'], $orderInfo['category'], $orderInfo['type']);
$count = UserBill::getRecordOrderCount($uid, $orderInfo['category'], $orderInfo['type']); $count = UserBill::getRecordOrderCount($uid, $orderInfo['category'], $orderInfo['type']);
$data['count'] = $count ? $count : 0; $data['count'] = $count ? $count : 0;
if(!count($data['list'])) return app('json')->successful($data); if (!count($data['list'])) return app('json')->successful($data);
foreach ($data['list'] as $key=>&$value){ foreach ($data['list'] as $key => &$value) {
$value['child'] = UserBill::getRecordOrderListDraw($uid, $value['time'], $orderInfo['category'], $orderInfo['type']); $value['child'] = UserBill::getRecordOrderListDraw($uid, $value['time'], $orderInfo['category'], $orderInfo['type']);
$value['count'] = count($value['child']); $value['count'] = count($value['child']);
} }
@ -108,31 +109,31 @@ class UserBillController
/** /**
* 推广佣金明细 * 推广佣金明细
* @param Request $request * @param Request $request
* @param $type 0 全部 1 消费 2 充值 3 返佣 4 提现 * @param $type 0 全部 1 消费 2 充值 3 返佣 4 提现
* @return mixed * @return mixed
*/ */
public function spread_commission(Request $request, $type) public function spread_commission(Request $request, $type)
{ {
list($page, $limit) = UtilService::getMore([ list($page, $limit) = UtilService::getMore([
['page',0], ['page', 0],
['limit',0], ['limit', 0],
],$request, true); ], $request, true);
return app('json')->successful(UserBill::getUserBillList($request->uid(),$page,$limit,$type)); return app('json')->successful(UserBill::getUserBillList($request->uid(), $page, $limit, $type));
} }
/** /**
* 推广 佣金/提现 总和 * 推广 佣金/提现 总和
* @param Request $request * @param Request $request
* @param $type 3 佣金 4 提现 * @param $type 3 佣金 4 提现
* @return mixed * @return mixed
*/ */
public function spread_count(Request $request, $type) public function spread_count(Request $request, $type)
{ {
$count = 0; $count = 0;
if($type == 3) $count = UserBill::getRecordCount($request->uid(), 'now_money', 'brokerage'); if ($type == 3) $count = UserBill::getRecordCount($request->uid(), 'now_money', 'brokerage');
else if($type == 4) $count = UserExtract::userExtractTotalPrice($request->uid());//累计提现 else if ($type == 4) $count = UserExtract::userExtractTotalPrice($request->uid());//累计提现
$count = $count ? $count : 0; $count = $count ? $count : 0;
return app('json')->successful(['count'=>$count]); return app('json')->successful(['count' => $count]);
} }
@ -144,168 +145,168 @@ class UserBillController
public function spread_banner(Request $request) public function spread_banner(Request $request)
{ {
list($type) = UtilService::getMore([ list($type) = UtilService::getMore([
['type',2], ['type', 2],
],$request, true); ], $request, true);
$user = $request->user(); $user = $request->user();
$rootPath = app()->getRootPath(); $rootPath = app()->getRootPath();
try{ try {
$resRoutine = true;//小程序 $resRoutine = true;//小程序
$resWap = true;//公众号 $resWap = true;//公众号
$siteUrl = sysConfig('site_url'); $siteUrl = sysConfig('site_url');
$routineSpreadBanner = GroupDataService::getData('routine_spread_banner'); $routineSpreadBanner = GroupDataService::getData('routine_spread_banner');
if(!count($routineSpreadBanner)) return app('json')->fail('暂无海报'); if (!count($routineSpreadBanner)) return app('json')->fail('暂无海报');
if($type == 1){ if ($type == 1) {
//小程序 //小程序
$name = $user['uid'].'_'.$user['is_promoter'].'_user_routine.jpg'; $name = $user['uid'] . '_' . $user['is_promoter'] . '_user_routine.jpg';
$imageInfo = SystemAttachment::getInfo($name,'name'); $imageInfo = SystemAttachment::getInfo($name, 'name');
//检测远程文件是否存在 //检测远程文件是否存在
if(isset($imageInfo['att_dir']) && strstr($imageInfo['att_dir'],'http')!==false && UtilService::CurlFileExist($imageInfo['att_dir']) === false){ if (isset($imageInfo['att_dir']) && strstr($imageInfo['att_dir'], 'http') !== false && UtilService::CurlFileExist($imageInfo['att_dir']) === false) {
$imageInfo = null; $imageInfo = null;
SystemAttachment::where(['name'=>$name])->delete(); SystemAttachment::where(['name' => $name])->delete();
} }
if(!$imageInfo){ if (!$imageInfo) {
$res = RoutineCode::getShareCode($user['uid'], 'spread', '', ''); $res = RoutineCode::getShareCode($user['uid'], 'spread', '', '');
if(!$res) return app('json')->fail('二维码生成失败'); if (!$res) return app('json')->fail('二维码生成失败');
$imageInfo = UploadService::getInstance()->setUploadPath('routine/spread/code')->imageStream($name,$res['res']); $imageInfo = UploadService::instance()->setUploadPath('routine/spread/code')->imageStream($name, $res['res']);
if(!is_array($imageInfo)) return app('json')->fail($imageInfo); if (!is_array($imageInfo)) return app('json')->fail($imageInfo);
SystemAttachment::attachmentAdd($imageInfo['name'],$imageInfo['size'],$imageInfo['type'],$imageInfo['dir'],$imageInfo['thumb_path'],1,$imageInfo['image_type'],$imageInfo['time'],2); SystemAttachment::attachmentAdd($imageInfo['name'], $imageInfo['size'], $imageInfo['type'], $imageInfo['dir'], $imageInfo['thumb_path'], 1, $imageInfo['image_type'], $imageInfo['time'], 2);
RoutineQrcode::setRoutineQrcodeFind($res['id'],['status'=>1,'time'=>time(),'qrcode_url'=>$imageInfo['dir']]); RoutineQrcode::setRoutineQrcodeFind($res['id'], ['status' => 1, 'time' => time(), 'qrcode_url' => $imageInfo['dir']]);
$urlCode = $imageInfo['dir']; $urlCode = $imageInfo['dir'];
}else $urlCode = $imageInfo['att_dir']; } else $urlCode = $imageInfo['att_dir'];
if($imageInfo['image_type'] == 1) $urlCode = $siteUrl.$urlCode; if ($imageInfo['image_type'] == 1) $urlCode = $siteUrl . $urlCode;
$siteUrlHttps = UtilService::setHttpType($siteUrl, 0); $siteUrlHttps = UtilService::setHttpType($siteUrl, 0);
$filelink=[ $filelink = [
'Bold'=>'static'. DS .'font'. DS .'Alibaba-PuHuiTi-Regular.otf', 'Bold' => 'static' . DS . 'font' . DS . 'Alibaba-PuHuiTi-Regular.otf',
'Normal'=>'static'. DS .'font'. DS .'Alibaba-PuHuiTi-Regular.otf', 'Normal' => 'static' . DS . 'font' . DS . 'Alibaba-PuHuiTi-Regular.otf',
]; ];
if(!file_exists($filelink['Bold'])) return app('json')->fail('缺少字体文件Bold'); if (!file_exists($filelink['Bold'])) return app('json')->fail('缺少字体文件Bold');
if(!file_exists($filelink['Normal'])) return app('json')->fail('缺少字体文件Normal'); if (!file_exists($filelink['Normal'])) return app('json')->fail('缺少字体文件Normal');
foreach ($routineSpreadBanner as $key=>&$item){ foreach ($routineSpreadBanner as $key => &$item) {
$posterInfo = '海报生成失败:('; $posterInfo = '海报生成失败:(';
$config = array( $config = array(
'image'=>array( 'image' => array(
array( array(
'url'=>$urlCode, //二维码资源 'url' => $urlCode, //二维码资源
'stream'=>0, 'stream' => 0,
'left'=>114, 'left' => 114,
'top'=>790, 'top' => 790,
'right'=>0, 'right' => 0,
'bottom'=>0, 'bottom' => 0,
'width'=>120, 'width' => 120,
'height'=>120, 'height' => 120,
'opacity'=>100 'opacity' => 100
) )
), ),
'text'=>array( 'text' => array(
array( array(
'text'=>$user['nickname'], 'text' => $user['nickname'],
'left'=>250, 'left' => 250,
'top'=>840, 'top' => 840,
'fontPath'=>$rootPath.'public'. DS .$filelink['Bold'], //字体文件 'fontPath' => $rootPath . 'public' . DS . $filelink['Bold'], //字体文件
'fontSize'=>16, //字号 'fontSize' => 16, //字号
'fontColor'=>'40,40,40', //字体颜色 'fontColor' => '40,40,40', //字体颜色
'angle'=>0, 'angle' => 0,
), ),
array( array(
'text'=>'邀请您加入'.sysConfig('site_name'), 'text' => '邀请您加入' . sysConfig('site_name'),
'left'=>250, 'left' => 250,
'top'=>880, 'top' => 880,
'fontPath'=>$rootPath.'public'. DS .$filelink['Normal'], //字体文件 'fontPath' => $rootPath . 'public' . DS . $filelink['Normal'], //字体文件
'fontSize'=>16, //字号 'fontSize' => 16, //字号
'fontColor'=>'40,40,40', //字体颜色 'fontColor' => '40,40,40', //字体颜色
'angle'=>0, 'angle' => 0,
) )
), ),
'background'=>$item['pic'] 'background' => $item['pic']
); );
$resRoutine = $resRoutine && $posterInfo = UtilService::setSharePoster($config,'routine/spread/poster'); $resRoutine = $resRoutine && $posterInfo = UtilService::setSharePoster($config, 'routine/spread/poster');
if(!is_array($posterInfo)) return app('json')->fail($posterInfo); if (!is_array($posterInfo)) return app('json')->fail($posterInfo);
SystemAttachment::attachmentAdd($posterInfo['name'],$posterInfo['size'],$posterInfo['type'],$posterInfo['dir'],$posterInfo['thumb_path'],1,$posterInfo['image_type'],$posterInfo['time'],2); SystemAttachment::attachmentAdd($posterInfo['name'], $posterInfo['size'], $posterInfo['type'], $posterInfo['dir'], $posterInfo['thumb_path'], 1, $posterInfo['image_type'], $posterInfo['time'], 2);
if($resRoutine){ if ($resRoutine) {
if($posterInfo['image_type'] == 1) if ($posterInfo['image_type'] == 1)
$item['poster'] = $siteUrlHttps.$posterInfo['dir']; $item['poster'] = $siteUrlHttps . $posterInfo['dir'];
else else
$item['poster'] = UtilService::setHttpType($posterInfo['dir'], 0); $item['poster'] = UtilService::setHttpType($posterInfo['dir'], 0);
$item['poster'] = str_replace('\\','/',$item['poster']); $item['poster'] = str_replace('\\', '/', $item['poster']);
} }
} }
}else if($type == 2){ } else if ($type == 2) {
//公众号 //公众号
$name = $user['uid'].'_'.$user['is_promoter'].'_user_wap.jpg'; $name = $user['uid'] . '_' . $user['is_promoter'] . '_user_wap.jpg';
$imageInfo = SystemAttachment::getInfo($name,'name'); $imageInfo = SystemAttachment::getInfo($name, 'name');
//检测远程文件是否存在 //检测远程文件是否存在
if(isset($imageInfo['att_dir']) && strstr($imageInfo['att_dir'],'http')!==false && UtilService::CurlFileExist($imageInfo['att_dir']) === false){ if (isset($imageInfo['att_dir']) && strstr($imageInfo['att_dir'], 'http') !== false && UtilService::CurlFileExist($imageInfo['att_dir']) === false) {
$imageInfo = null; $imageInfo = null;
SystemAttachment::where(['name'=>$name])->delete(); SystemAttachment::where(['name' => $name])->delete();
} }
if(!$imageInfo){ if (!$imageInfo) {
$codeUrl = UtilService::setHttpType($siteUrl.'?spread='.$user['uid'], 1);//二维码链接 $codeUrl = UtilService::setHttpType($siteUrl . '?spread=' . $user['uid'], 1);//二维码链接
$imageInfo = UtilService::getQRCodePath($codeUrl, $name); $imageInfo = UtilService::getQRCodePath($codeUrl, $name);
if(!$imageInfo) return app('json')->fail('二维码生成失败'); if (!$imageInfo) return app('json')->fail('二维码生成失败');
SystemAttachment::attachmentAdd($imageInfo['name'],$imageInfo['size'],$imageInfo['type'],$imageInfo['dir'],$imageInfo['thumb_path'],1,$imageInfo['image_type'],$imageInfo['time'],2); SystemAttachment::attachmentAdd($imageInfo['name'], $imageInfo['size'], $imageInfo['type'], $imageInfo['dir'], $imageInfo['thumb_path'], 1, $imageInfo['image_type'], $imageInfo['time'], 2);
$urlCode = $imageInfo['dir']; $urlCode = $imageInfo['dir'];
}else $urlCode = $imageInfo['att_dir']; } else $urlCode = $imageInfo['att_dir'];
if($imageInfo['image_type'] == 1) $urlCode = $siteUrl.$urlCode; if ($imageInfo['image_type'] == 1) $urlCode = $siteUrl . $urlCode;
$siteUrl = UtilService::setHttpType($siteUrl, 1); $siteUrl = UtilService::setHttpType($siteUrl, 1);
$filelink=[ $filelink = [
'Bold'=>'static'. DS .'font'. DS .'Alibaba-PuHuiTi-Regular.otf', 'Bold' => 'static' . DS . 'font' . DS . 'Alibaba-PuHuiTi-Regular.otf',
'Normal'=>'static'. DS .'font'. DS .'Alibaba-PuHuiTi-Regular.otf', 'Normal' => 'static' . DS . 'font' . DS . 'Alibaba-PuHuiTi-Regular.otf',
]; ];
if(!file_exists($filelink['Bold'])) return app('json')->fail('缺少字体文件Bold'); if (!file_exists($filelink['Bold'])) return app('json')->fail('缺少字体文件Bold');
if(!file_exists($filelink['Normal'])) return app('json')->fail('缺少字体文件Normal'); if (!file_exists($filelink['Normal'])) return app('json')->fail('缺少字体文件Normal');
foreach ($routineSpreadBanner as $key=>&$item){ foreach ($routineSpreadBanner as $key => &$item) {
$posterInfo = '海报生成失败:('; $posterInfo = '海报生成失败:(';
$config = array( $config = array(
'image'=>array( 'image' => array(
array( array(
'url'=>$urlCode, //二维码资源 'url' => $urlCode, //二维码资源
'stream'=>0, 'stream' => 0,
'left'=>114, 'left' => 114,
'top'=>790, 'top' => 790,
'right'=>0, 'right' => 0,
'bottom'=>0, 'bottom' => 0,
'width'=>120, 'width' => 120,
'height'=>120, 'height' => 120,
'opacity'=>100 'opacity' => 100
) )
), ),
'text'=>array( 'text' => array(
array( array(
'text'=>$user['nickname'], 'text' => $user['nickname'],
'left'=>250, 'left' => 250,
'top'=>840, 'top' => 840,
'fontPath'=>$rootPath.'public'. DS .$filelink['Bold'], //字体文件 'fontPath' => $rootPath . 'public' . DS . $filelink['Bold'], //字体文件
'fontSize'=>16, //字号 'fontSize' => 16, //字号
'fontColor'=>'40,40,40', //字体颜色 'fontColor' => '40,40,40', //字体颜色
'angle'=>0, 'angle' => 0,
), ),
array( array(
'text'=>'邀请您加入'.sysConfig('site_name'), 'text' => '邀请您加入' . sysConfig('site_name'),
'left'=>250, 'left' => 250,
'top'=>880, 'top' => 880,
'fontPath'=>$rootPath.'public'. DS .$filelink['Normal'], //字体文件 'fontPath' => $rootPath . 'public' . DS . $filelink['Normal'], //字体文件
'fontSize'=>16, //字号 'fontSize' => 16, //字号
'fontColor'=>'40,40,40', //字体颜色 'fontColor' => '40,40,40', //字体颜色
'angle'=>0, 'angle' => 0,
) )
), ),
'background'=>$item['pic'] 'background' => $item['pic']
); );
$resWap = $resWap && $posterInfo = UtilService::setSharePoster($config,'wap/spread/poster'); $resWap = $resWap && $posterInfo = UtilService::setSharePoster($config, 'wap/spread/poster');
if(!is_array($posterInfo)) return app('json')->fail($posterInfo); if (!is_array($posterInfo)) return app('json')->fail($posterInfo);
SystemAttachment::attachmentAdd($posterInfo['name'],$posterInfo['size'],$posterInfo['type'],$posterInfo['dir'],$posterInfo['thumb_path'],1,$posterInfo['image_type'],$posterInfo['time'],2); SystemAttachment::attachmentAdd($posterInfo['name'], $posterInfo['size'], $posterInfo['type'], $posterInfo['dir'], $posterInfo['thumb_path'], 1, $posterInfo['image_type'], $posterInfo['time'], 2);
if($resWap){ if ($resWap) {
if($posterInfo['image_type'] == 1) if ($posterInfo['image_type'] == 1)
$item['wap_poster'] = $siteUrl.$posterInfo['dir']; $item['wap_poster'] = $siteUrl . $posterInfo['dir'];
else else
$item['wap_poster'] = UtilService::setHttpType($posterInfo['dir'], 1); $item['wap_poster'] = UtilService::setHttpType($posterInfo['dir'], 1);
} }
} }
} }
if($resRoutine && $resWap) return app('json')->successful($routineSpreadBanner); if ($resRoutine && $resWap) return app('json')->successful($routineSpreadBanner);
else return app('json')->fail('生成图片失败'); else return app('json')->fail('生成图片失败');
}catch (\Exception $e){ } catch (\Exception $e) {
return app('json')->fail('生成图片时,系统错误',['line'=>$e->getLine(),'message'=>$e->getMessage()]); return app('json')->fail('生成图片时,系统错误', ['line' => $e->getLine(), 'message' => $e->getMessage()]);
} }
} }
@ -321,9 +322,9 @@ class UserBillController
public function integral_list(Request $request) public function integral_list(Request $request)
{ {
list($page, $limit) = UtilService::getMore([ list($page, $limit) = UtilService::getMore([
['page',0],['limit',0] ['page', 0], ['limit', 0]
], $request, true); ], $request, true);
return app('json')->successful(UserBill::userBillList($request->uid(),$page,$limit)); return app('json')->successful(UserBill::userBillList($request->uid(), $page, $limit));
} }
} }

View File

@ -8,6 +8,7 @@ use app\models\user\User;
use app\models\user\UserToken; use app\models\user\UserToken;
use app\models\user\WechatUser; use app\models\user\WechatUser;
use app\Request; use app\Request;
use crmeb\utils\Canvas;
use crmeb\services\WechatService; use crmeb\services\WechatService;
use think\facade\Cookie; use think\facade\Cookie;
@ -56,7 +57,7 @@ class WechatController
public function auth(Request $request) public function auth(Request $request)
{ {
$spreadId = intval($request->param('spread')); $spreadId = intval($request->param('spread'));
$login_type = $request->param('login_type',''); $login_type = $request->param('login_type', '');
try { try {
$wechatInfo = WechatService::oauthService()->user()->getOriginal(); $wechatInfo = WechatService::oauthService()->user()->getOriginal();
} catch (\Exception $e) { } catch (\Exception $e) {
@ -79,7 +80,7 @@ class WechatController
$user = User::where('uid', WechatUser::openidToUid($openid, 'openid'))->find(); $user = User::where('uid', WechatUser::openidToUid($openid, 'openid'))->find();
if (!$user) if (!$user)
return app('json')->fail('获取用户信息失败'); return app('json')->fail('获取用户信息失败');
if($user->login_type == 'h5' && ($h5UserInfo = User::where(['account'=>$user->phone,'phone'=>$user->phone,'user_type'=>'h5'])->find())) if ($user->login_type == 'h5' && ($h5UserInfo = User::where(['account' => $user->phone, 'phone' => $user->phone, 'user_type' => 'h5'])->find()))
$token = UserToken::createToken($h5UserInfo, 'wechat'); $token = UserToken::createToken($h5UserInfo, 'wechat');
else else
$token = UserToken::createToken($user, 'wechat'); $token = UserToken::createToken($user, 'wechat');
@ -91,4 +92,27 @@ class WechatController
} else } else
return app('json')->fail('登录失败'); return app('json')->fail('登录失败');
} }
public function follow()
{
$canvas = Canvas::instance();
$path = 'uploads/follow/';
$imageType = 'jpg';
$name = 'follow';
$siteUrl = sysConfig('site_url');
if (file_exists($path . $name . '.' . $imageType)) {
return app('json')->success('ok', ['path' => $siteUrl . '/' . $path . $name . '.' . $imageType]);
}
$canvas->setImageUrl('static/qrcode/follow.png')->setImageHeight(720)->setImageWidth(500)->pushImageValue();
$wechatQrcode = sysConfig('wechat_qrcode');
if (($strlen = stripos($wechatQrcode, 'uploads')) !== false) {
$wechatQrcode = substr($wechatQrcode, $strlen);
}
if (!$wechatQrcode)
return app('json')->fail('请上传二维码');
$canvas->setImageUrl($wechatQrcode)->setImageHeight(344)->setImageWidth(344)->setImageLeft(76)->setImageTop(76)->pushImageValue();
$image = $canvas->setFileName($name)->setImageType($imageType)->setPath($path)->setBackgroundWidth(500)->setBackgroundHeight(720)->starDrawChart();
return app('json')->success('ok', ['path' => $image ? $siteUrl . '/' . $image : '']);
}
} }

View File

@ -335,7 +335,7 @@ class StoreOrder extends BaseModel
} }
$orderInfo = [ $orderInfo = [
'uid' => $uid, 'uid' => $uid,
'order_id' => $test ? 0 : self::getNewOrderId($uid), 'order_id' => $test ? 0 : self::getNewOrderId(),
'real_name' => $addressInfo['real_name'], 'real_name' => $addressInfo['real_name'],
'user_phone' => $addressInfo['phone'], 'user_phone' => $addressInfo['phone'],
'user_address' => $addressInfo['province'] . ' ' . $addressInfo['city'] . ' ' . $addressInfo['district'] . ' ' . $addressInfo['detail'], 'user_address' => $addressInfo['province'] . ' ' . $addressInfo['city'] . ' ' . $addressInfo['district'] . ' ' . $addressInfo['detail'],
@ -490,10 +490,10 @@ class StoreOrder extends BaseModel
* @param $uid 用户uid * @param $uid 用户uid
* @return string * @return string
*/ */
public static function getNewOrderId($uid) public static function getNewOrderId()
{ {
list($msec, $sec) = explode(' ', microtime()); list($msec, $sec) = explode(' ', microtime());
$msectime = (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000); $msectime = number_format((floatval($msec) + floatval($sec)) * 1000,0,'','');
$orderId = 'wx' . $msectime . mt_rand(10000,99999); $orderId = 'wx' . $msectime . mt_rand(10000,99999);
if(self::be(['order_id'=>$orderId])) $orderId = 'wx' . $msectime . mt_rand(10000,99999); if(self::be(['order_id'=>$orderId])) $orderId = 'wx' . $msectime . mt_rand(10000,99999);
return $orderId; return $orderId;

View File

@ -40,9 +40,10 @@ class WechatUser extends BaseModel
* @param string $uid * @param string $uid
* @return bool|mixed * @return bool|mixed
*/ */
public static function getOpenId($uid = ''){ public static function getOpenId($uid = '')
if($uid == '') return false; {
return self::where('uid',$uid)->value('routine_openid'); if ($uid == '') return false;
return self::where('uid', $uid)->value('routine_openid');
} }
/** /**
@ -55,7 +56,7 @@ class WechatUser extends BaseModel
public static function uidToOpenid($uid, $openidType = 'routine_openid') public static function uidToOpenid($uid, $openidType = 'routine_openid')
{ {
$openid = self::where('uid',$uid)->value($openidType); $openid = self::where('uid', $uid)->value($openidType);
return $openid; return $openid;
} }
@ -67,7 +68,7 @@ class WechatUser extends BaseModel
*/ */
public static function openidTouid($openid, $openidType = 'openid') public static function openidTouid($openid, $openidType = 'openid')
{ {
return self::where($openidType,$openid)->where('user_type','<>','h5')->value('uid'); return self::where($openidType, $openid)->where('user_type', '<>', 'h5')->value('uid');
} }
/** /**
@ -75,67 +76,71 @@ class WechatUser extends BaseModel
* @param $routineInfo * @param $routineInfo
* @return mixed * @return mixed
*/ */
public static function routineOauth($routine){ public static function routineOauth($routine)
$routineInfo['nickname'] = filterEmoji($routine['nickName']);//姓名 {
$routineInfo['sex'] = $routine['gender'];//性别 $routineInfo['nickname'] = filterEmoji($routine['nickName']);//姓名
$routineInfo['language'] = $routine['language'];//语言 $routineInfo['sex'] = $routine['gender'];//性别
$routineInfo['city'] = $routine['city'];//城市 $routineInfo['language'] = $routine['language'];//语言
$routineInfo['province'] = $routine['province'];//省份 $routineInfo['city'] = $routine['city'];//城市
$routineInfo['country'] = $routine['country'];//国家 $routineInfo['province'] = $routine['province'];//省份
$routineInfo['headimgurl'] = $routine['avatarUrl'];//头像 $routineInfo['country'] = $routine['country'];//国家
$routineInfo['headimgurl'] = $routine['avatarUrl'];//头像
$routineInfo['routine_openid'] = $routine['openId'];//openid $routineInfo['routine_openid'] = $routine['openId'];//openid
$routineInfo['session_key'] = $routine['session_key'];//会话密匙 $routineInfo['session_key'] = $routine['session_key'];//会话密匙
$routineInfo['unionid'] = $routine['unionId'];//用户在开放平台的唯一标识符 $routineInfo['unionid'] = $routine['unionId'];//用户在开放平台的唯一标识符
$routineInfo['user_type'] = 'routine';//用户类型 $routineInfo['user_type'] = 'routine';//用户类型
$spid = 0;//绑定关系uid $spid = 0;//绑定关系uid
$isCOde = false; $isCOde = false;
//获取是否有扫码进小程序 //获取是否有扫码进小程序
if($routine['code']){ if ($routine['code']) {
if($info = RoutineQrcode::getRoutineQrcodeFindType($routine['code'])){ if ($info = RoutineQrcode::getRoutineQrcodeFindType($routine['code'])) {
$spid = $info['third_id']; $spid = $info['third_id'];
$isCOde=true; $isCOde = true;
}else } else
$spid = $routine['spid']; $spid = $routine['spid'];
}else if($routine['spid']) } else if ($routine['spid'])
$spid = $routine['spid']; $spid = $routine['spid'];
// 判断unionid 存在根据unionid判断 // 判断unionid 存在根据unionid判断
if($routineInfo['unionid'] != '' && ($uid=self::where(['unionid'=>$routineInfo['unionid']])->where('user_type','<>','h5')->value('uid'))){ if ($routineInfo['unionid'] != '' && ($uid = self::where(['unionid' => $routineInfo['unionid']])->where('user_type', '<>', 'h5')->value('uid'))) {
self::edit($routineInfo,$uid,'uid'); self::edit($routineInfo, $uid, 'uid');
$routineInfo['code'] = $spid; $routineInfo['code'] = $spid;
$routineInfo['isPromoter'] = $isCOde; $routineInfo['isPromoter'] = $isCOde;
if($routine['login_type']) $routineInfo['login_type'] = $routine['login_type']; if ($routine['login_type']) $routineInfo['login_type'] = $routine['login_type'];
User::updateWechatUser($routineInfo,$uid); User::updateWechatUser($routineInfo, $uid);
}else if($uid = self::where(['routine_openid'=>$routineInfo['routine_openid']])->where('user_type','<>','h5')->value('uid')){ //根据小程序openid判断 } else if ($uid = self::where(['routine_openid' => $routineInfo['routine_openid']])->where('user_type', '<>', 'h5')->value('uid')) { //根据小程序openid判断
self::edit($routineInfo,$uid,'uid'); self::edit($routineInfo, $uid, 'uid');
$routineInfo['code'] = $spid; $routineInfo['code'] = $spid;
$routineInfo['isPromoter'] = $isCOde; $routineInfo['isPromoter'] = $isCOde;
if($routine['login_type']) $routineInfo['login_type'] = $routine['login_type']; if ($routine['login_type']) $routineInfo['login_type'] = $routine['login_type'];
User::updateWechatUser($routineInfo,$uid); User::updateWechatUser($routineInfo, $uid);
}else{ } else {
$routineInfo['add_time'] = time();//用户添加时间 $routineInfo['add_time'] = time();//用户添加时间
$routineInfo = self::create($routineInfo); $routineInfo = self::create($routineInfo);
$res = User::setRoutineUser($routineInfo,$spid); $res = User::setRoutineUser($routineInfo, $spid);
$uid = $res->uid; $uid = $res->uid;
} }
return $uid; return $uid;
} }
/** /**
* 判断是否是小程序用户 * 判断是否是小程序用户
* @param int $uid * @param int $uid
* @return bool|int|string * @return bool|int|string
*/ */
public static function isRoutineUser($uid = 0){ public static function isRoutineUser($uid = 0)
if(!$uid) return false; {
return self::where('uid',$uid)->where('user_type','routine')->count(); if (!$uid) return false;
return self::where('uid', $uid)->where('user_type', 'routine')->count();
} }
/** /**
* @param int $uid * @param int $uid
* @return int * @return int
*/ */
public static function isUserStatus($uid = 0){ public static function isUserStatus($uid = 0)
if(!$uid) return 0; {
if (!$uid) return 0;
$user = User::getUserInfo($uid); $user = User::getUserInfo($uid);
return $user['status']; return $user['status'];
} }
@ -148,23 +153,23 @@ class WechatUser extends BaseModel
public static function setNewUser($openid) public static function setNewUser($openid)
{ {
$userInfo = WechatService::getUserInfo($openid); $userInfo = WechatService::getUserInfo($openid);
if(!isset($userInfo['subscribe']) || !$userInfo['subscribe'] || !isset($userInfo['openid'])) if (!isset($userInfo['subscribe']) || !$userInfo['subscribe'] || !isset($userInfo['openid']))
exception('请关注公众号!'); exception('请关注公众号!');
$userInfo['tagid_list'] = implode(',',$userInfo['tagid_list']); $userInfo['tagid_list'] = implode(',', $userInfo['tagid_list']);
//判断 unionid 是否存在 //判断 unionid 是否存在
if(isset($userInfo['unionid'])){ if (isset($userInfo['unionid'])) {
$wechatInfo = self::where('unionid',$userInfo['unionid'])->find(); $wechatInfo = self::where('unionid', $userInfo['unionid'])->find();
if($wechatInfo){ if ($wechatInfo) {
return self::edit($userInfo,$userInfo['unionid'],'unionid'); return self::edit($userInfo, $userInfo['unionid'], 'unionid');
} }
} }
self::beginTrans(); self::beginTrans();
$wechatUser = self::create(is_object($userInfo) ? $userInfo->toArray() : $userInfo); $wechatUser = self::create(is_object($userInfo) ? $userInfo->toArray() : $userInfo);
if(!$wechatUser){ if (!$wechatUser) {
self::rollbackTrans(); self::rollbackTrans();
exception('用户储存失败!'); exception('用户储存失败!');
} }
if(!User::setWechatUser($wechatUser)){ if (!User::setWechatUser($wechatUser)) {
self::rollbackTrans(); self::rollbackTrans();
exception('用户信息储存失败!'); exception('用户信息储存失败!');
} }
@ -180,7 +185,7 @@ class WechatUser extends BaseModel
public static function userFirstSubGiveCoupon($openid) public static function userFirstSubGiveCoupon($openid)
{ {
$couponId = sysConfig('wechat_first_sub_give_coupon'); $couponId = sysConfig('wechat_first_sub_give_coupon');
if($couponId) StoreCouponUser::addUserCoupon(self::openidToUid($openid),$couponId); if ($couponId) StoreCouponUser::addUserCoupon(self::openidToUid($openid), $couponId);
} }
/** /**
@ -190,7 +195,7 @@ class WechatUser extends BaseModel
public static function userTakeOrderGiveCoupon($uid) public static function userTakeOrderGiveCoupon($uid)
{ {
$couponId = sysConfig('store_order_give_coupon'); $couponId = sysConfig('store_order_give_coupon');
if($couponId) StoreCouponUser::addUserCoupon($uid,$couponId); if ($couponId) StoreCouponUser::addUserCoupon($uid, $couponId);
} }
/** /**
@ -201,8 +206,8 @@ class WechatUser extends BaseModel
public static function updateUser($openid) public static function updateUser($openid)
{ {
$userInfo = WechatService::getUserInfo($openid); $userInfo = WechatService::getUserInfo($openid);
$userInfo['tagid_list'] = implode(',',$userInfo['tagid_list']); $userInfo['tagid_list'] = implode(',', $userInfo['tagid_list']);
return self::edit($userInfo->toArray(),$openid,'openid'); return self::edit($userInfo->toArray(), $openid, 'openid');
} }
/** /**
@ -211,7 +216,7 @@ class WechatUser extends BaseModel
*/ */
public static function saveUser($openid) public static function saveUser($openid)
{ {
self::be($openid,'openid') == true ? self::updateUser($openid) : self::setNewUser($openid); self::be($openid, 'openid') == true ? self::updateUser($openid) : self::setNewUser($openid);
} }
/** /**
@ -221,7 +226,7 @@ class WechatUser extends BaseModel
*/ */
public static function unSubscribe($openid) public static function unSubscribe($openid)
{ {
return self::edit(['subscribe'=>0],$openid,'openid'); return self::edit(['subscribe' => 0], $openid, 'openid');
} }
/** /**
@ -231,7 +236,7 @@ class WechatUser extends BaseModel
*/ */
public static function uidToUnionid($uid) public static function uidToUnionid($uid)
{ {
return self::where('uid',$uid)->value('unionid'); return self::where('uid', $uid)->value('unionid');
} }
/** /**
@ -245,13 +250,13 @@ class WechatUser extends BaseModel
*/ */
public static function getWechatInfo($openid, $openidType) public static function getWechatInfo($openid, $openidType)
{ {
if(is_numeric($openid)) $openid = self::uidToOpenid($openid); if (is_numeric($openid)) $openid = self::uidToOpenid($openid);
$wechatInfo = self::where($openidType,$openid)->find(); $wechatInfo = self::where($openidType, $openid)->find();
if(!$wechatInfo) { if (!$wechatInfo) {
self::setNewUser($openid); self::setNewUser($openid);
$wechatInfo = self::where($openidType,$openid)->find(); $wechatInfo = self::where($openidType, $openid)->find();
} }
if(!$wechatInfo) exception('获取用户信息失败!'); if (!$wechatInfo) exception('获取用户信息失败!');
return $wechatInfo->toArray(); return $wechatInfo->toArray();
} }
} }