From 8875a1e82b02dc0e1829fde81ade0f0a274285fd Mon Sep 17 00:00:00 2001 From: liaofei <136327134@qq.com> Date: Thu, 28 Nov 2019 18:41:53 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=8A=E4=BC=A0=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E8=8E=B7=E5=8F=96=E9=9D=99=E6=80=81=E5=8F=A5=E6=9F=84?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/app/admin/controller/Index.php | 18 - .../admin/controller/agent/AgentManage.php | 8 +- .../app/admin/controller/article/Article.php | 2 +- .../controller/article/ArticleCategory.php | 2 +- .../admin/controller/article/WechatNews.php | 2 +- .../app/admin/controller/order/StoreOrder.php | 2 - .../admin/controller/setting/SystemConfig.php | 2 +- .../controller/setting/SystemGroupData.php | 2 +- .../app/admin/controller/store/CopyTaobao.php | 2 +- .../admin/controller/store/StoreCategory.php | 2 +- .../admin/controller/store/StoreInfoMana.php | 2 +- .../admin/controller/store/StoreProduct.php | 2 +- .../controller/system/SystemAttachment.php | 2 +- .../app/admin/controller/ump/StoreSeckill.php | 2 +- crmeb/app/admin/controller/wechat/Reply.php | 4 +- .../admin/controller/wechat/StoreService.php | 4 +- crmeb/app/admin/controller/widget/Images.php | 2 +- .../admin/model/record/StoreStatistics.php | 4 +- crmeb/app/admin/model/store/StoreProduct.php | 6 +- crmeb/app/admin/model/system/SystemAdmin.php | 3 +- crmeb/app/admin/model/wechat/WechatQrcode.php | 2 +- crmeb/app/admin/model/wechat/WechatReply.php | 1 - crmeb/app/api/controller/PublicController.php | 77 ++--- .../activity/StoreBargainController.php | 2 +- .../activity/StoreCombinationController.php | 204 ++++++------ .../activity/StoreSeckillController.php | 93 +++--- .../controller/order/StoreOrderController.php | 2 +- .../controller/publics/ArticleController.php | 4 +- .../controller/store/CategoryController.php | 2 +- .../store/StoreProductController.php | 158 ++++----- .../controller/user/UserBillController.php | 309 +++++++++--------- .../controller/wechat/WechatController.php | 28 +- crmeb/app/models/store/StoreOrder.php | 6 +- crmeb/app/models/user/WechatUser.php | 123 +++---- 34 files changed, 528 insertions(+), 556 deletions(-) diff --git a/crmeb/app/admin/controller/Index.php b/crmeb/app/admin/controller/Index.php index 5ca306d7..e0ab6cd7 100644 --- a/crmeb/app/admin/controller/Index.php +++ b/crmeb/app/admin/controller/Index.php @@ -12,9 +12,7 @@ use app\admin\model\user\UserExtract as UserExtractModel;//分销 use app\admin\model\user\User as UserModel;//用户 use app\admin\model\store\StoreProductReply as StoreProductReplyModel;//评论 use app\admin\model\store\StoreProduct as ProductModel;//产品 -use crmeb\utils\Template; use FormBuilder\Json; -use think\facade\Route; /** * 首页控制器 @@ -39,22 +37,6 @@ class Index extends AuthController 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() { diff --git a/crmeb/app/admin/controller/agent/AgentManage.php b/crmeb/app/admin/controller/agent/AgentManage.php index 25515b23..2f31a1db 100644 --- a/crmeb/app/admin/controller/agent/AgentManage.php +++ b/crmeb/app/admin/controller/agent/AgentManage.php @@ -211,7 +211,7 @@ class AgentManage extends AuthController if(!$imageInfo){ $res = \app\models\routine\RoutineCode::getShareCode($uid, 'spread', '', ''); 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; 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']]); @@ -221,11 +221,11 @@ class AgentManage extends AuthController } /* - * + * 获取公众号二维码 * */ 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'])) return ['code_src'=>$qr_code['url']]; else @@ -246,7 +246,7 @@ class AgentManage extends AuthController if(!$imageInfo){ $res = \app\models\routine\RoutineCode::getShareCode($uid, 'spread', '', ''); 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); 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']]); diff --git a/crmeb/app/admin/controller/article/Article.php b/crmeb/app/admin/controller/article/Article.php index 0625152d..155f0faf 100644 --- a/crmeb/app/admin/controller/article/Article.php +++ b/crmeb/app/admin/controller/article/Article.php @@ -99,7 +99,7 @@ class Article extends AuthController * @return \think\response\Json */ 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); 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']]); diff --git a/crmeb/app/admin/controller/article/ArticleCategory.php b/crmeb/app/admin/controller/article/ArticleCategory.php index d1203c52..78abcc07 100644 --- a/crmeb/app/admin/controller/article/ArticleCategory.php +++ b/crmeb/app/admin/controller/article/ArticleCategory.php @@ -72,7 +72,7 @@ class ArticleCategory extends AuthController * s上传图片 * */ 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); 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'])]); diff --git a/crmeb/app/admin/controller/article/WechatNews.php b/crmeb/app/admin/controller/article/WechatNews.php index 16466d92..2339a525 100644 --- a/crmeb/app/admin/controller/article/WechatNews.php +++ b/crmeb/app/admin/controller/article/WechatNews.php @@ -89,7 +89,7 @@ class WechatNews extends AuthController * @return \think\response\Json */ 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); 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']]); diff --git a/crmeb/app/admin/controller/order/StoreOrder.php b/crmeb/app/admin/controller/order/StoreOrder.php index 32d5d934..16298c4b 100644 --- a/crmeb/app/admin/controller/order/StoreOrder.php +++ b/crmeb/app/admin/controller/order/StoreOrder.php @@ -15,8 +15,6 @@ use crmeb\services\MiniProgramService; use crmeb\services\UtilService; use crmeb\services\WechatService; use crmeb\services\FormBuilder as Form; -use crmeb\services\HookService; -use crmeb\subscribes\OrderSubscribe; use app\admin\model\order\StoreOrderStatus; use app\admin\model\ump\StorePink; use app\admin\model\user\User; diff --git a/crmeb/app/admin/controller/setting/SystemConfig.php b/crmeb/app/admin/controller/setting/SystemConfig.php index d8aa5444..75b4ed02 100644 --- a/crmeb/app/admin/controller/setting/SystemConfig.php +++ b/crmeb/app/admin/controller/setting/SystemConfig.php @@ -400,7 +400,7 @@ class SystemConfig extends AuthController * 文件上传 * */ 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); return Json::successful('上传成功!',['filePath'=>$res->filePath]); } diff --git a/crmeb/app/admin/controller/setting/SystemGroupData.php b/crmeb/app/admin/controller/setting/SystemGroupData.php index 413168fe..768b9f98 100644 --- a/crmeb/app/admin/controller/setting/SystemGroupData.php +++ b/crmeb/app/admin/controller/setting/SystemGroupData.php @@ -255,7 +255,7 @@ class SystemGroupData extends AuthController 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); 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'])]); diff --git a/crmeb/app/admin/controller/store/CopyTaobao.php b/crmeb/app/admin/controller/store/CopyTaobao.php index 996dbbae..3ed38bcf 100644 --- a/crmeb/app/admin/controller/store/CopyTaobao.php +++ b/crmeb/app/admin/controller/store/CopyTaobao.php @@ -770,7 +770,7 @@ class CopyTaobao extends AuthController $size = strlen(trim($content)); if (!$content || $size <= 2) return '图片流获取失败'; $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; $date['path'] = $imageInfo['dir']; $date['name'] = $imageInfo['name']; diff --git a/crmeb/app/admin/controller/store/StoreCategory.php b/crmeb/app/admin/controller/store/StoreCategory.php index 449f5cc0..754142d4 100644 --- a/crmeb/app/admin/controller/store/StoreCategory.php +++ b/crmeb/app/admin/controller/store/StoreCategory.php @@ -107,7 +107,7 @@ class StoreCategory extends AuthController */ 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)){ 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'])]); diff --git a/crmeb/app/admin/controller/store/StoreInfoMana.php b/crmeb/app/admin/controller/store/StoreInfoMana.php index 8c28c30c..98ad977c 100644 --- a/crmeb/app/admin/controller/store/StoreInfoMana.php +++ b/crmeb/app/admin/controller/store/StoreInfoMana.php @@ -68,7 +68,7 @@ class StoreInfoMana extends AuthController * */ 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']); if(is_array($res)) return Json::successful('图片上传成功!',['name'=>$res['name'],'url'=>Upload::pathToUrl($res['thumb_path'])]); diff --git a/crmeb/app/admin/controller/store/StoreProduct.php b/crmeb/app/admin/controller/store/StoreProduct.php index bc4ba4fc..4b6a8fbc 100644 --- a/crmeb/app/admin/controller/store/StoreProduct.php +++ b/crmeb/app/admin/controller/store/StoreProduct.php @@ -176,7 +176,7 @@ class StoreProduct extends AuthController */ 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']); if(is_array($res)) return Json::successful('图片上传成功!',['name'=>$res['name'],'url'=>Upload::pathToUrl($res['thumb_path'])]); diff --git a/crmeb/app/admin/controller/system/SystemAttachment.php b/crmeb/app/admin/controller/system/SystemAttachment.php index 1f3d0df3..5e65268e 100644 --- a/crmeb/app/admin/controller/system/SystemAttachment.php +++ b/crmeb/app/admin/controller/system/SystemAttachment.php @@ -21,7 +21,7 @@ class SystemAttachment extends AuthController */ 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)){ SystemAttachmentModel::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],0,$res['image_type'],$res['time']); $info["originalName"] = $res['name']; diff --git a/crmeb/app/admin/controller/ump/StoreSeckill.php b/crmeb/app/admin/controller/ump/StoreSeckill.php index 25ea8d17..825c0f0c 100644 --- a/crmeb/app/admin/controller/ump/StoreSeckill.php +++ b/crmeb/app/admin/controller/ump/StoreSeckill.php @@ -191,7 +191,7 @@ class StoreSeckill extends AuthController */ 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)){ 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'])]); diff --git a/crmeb/app/admin/controller/wechat/Reply.php b/crmeb/app/admin/controller/wechat/Reply.php index 5853d4cf..a347ef70 100644 --- a/crmeb/app/admin/controller/wechat/Reply.php +++ b/crmeb/app/admin/controller/wechat/Reply.php @@ -82,7 +82,7 @@ class Reply extends AuthController { $name = $this->request->post('file'); 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); 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']); @@ -93,7 +93,7 @@ class Reply extends AuthController { $name = $this->request->post('file'); 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); } diff --git a/crmeb/app/admin/controller/wechat/StoreService.php b/crmeb/app/admin/controller/wechat/StoreService.php index dc244c1f..d0f8dbdf 100644 --- a/crmeb/app/admin/controller/wechat/StoreService.php +++ b/crmeb/app/admin/controller/wechat/StoreService.php @@ -91,7 +91,7 @@ class StoreService extends AuthController $f[] = Form::input('nickname','客服名称',$service["nickname"]); $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('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'))); $this->assign(compact('form')); return $this->fetch('public/form-builder'); @@ -136,7 +136,7 @@ class StoreService extends AuthController */ 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)){ 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'])]); diff --git a/crmeb/app/admin/controller/widget/Images.php b/crmeb/app/admin/controller/widget/Images.php index 645951f6..8c7ae19a 100644 --- a/crmeb/app/admin/controller/widget/Images.php +++ b/crmeb/app/admin/controller/widget/Images.php @@ -71,7 +71,7 @@ class Images extends AuthController $upload_type = $this->request->get('upload_type',0); try{ $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'); if(is_object($res) && $res->status === false){ $info = array( diff --git a/crmeb/app/admin/model/record/StoreStatistics.php b/crmeb/app/admin/model/record/StoreStatistics.php index e560bfb7..e63e761f 100644 --- a/crmeb/app/admin/model/record/StoreStatistics.php +++ b/crmeb/app/admin/model/record/StoreStatistics.php @@ -58,7 +58,9 @@ class StoreStatistics extends BaseModel public static function getOrderInfo($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; $postage = 0; $deduction = 0; diff --git a/crmeb/app/admin/model/store/StoreProduct.php b/crmeb/app/admin/model/store/StoreProduct.php index 14a28c80..15746844 100644 --- a/crmeb/app/admin/model/store/StoreProduct.php +++ b/crmeb/app/admin/model/store/StoreProduct.php @@ -288,10 +288,10 @@ class StoreProduct extends BaseModel 'class'=>'fa fa fa-ioxhost', ], [ - 'name'=>'新增商品', + 'name'=>'商品总数', 'field'=>'件', - 'count'=>self::setWhereType(self::getModelTime($where,new self),$type)->where('is_new',1)->sum('stock'), - 'content'=>'新增商品总数', + 'count'=>self::setWhereType(self::getModelTime($where,new self),$type)->sum('stock'), + 'content'=>'增商品总数', 'background_color'=>'layui-bg-cyan', 'sum'=>self::where('is_new',1)->sum('stock'), 'class'=>'fa fa-line-chart', diff --git a/crmeb/app/admin/model/system/SystemAdmin.php b/crmeb/app/admin/model/system/SystemAdmin.php index 8931a449..70088346 100644 --- a/crmeb/app/admin/model/system/SystemAdmin.php +++ b/crmeb/app/admin/model/system/SystemAdmin.php @@ -67,6 +67,7 @@ class SystemAdmin extends BaseModel { Session::set('adminId',$adminInfo['id']); Session::set('adminInfo',$adminInfo->toArray()); + Session::save(); } /** @@ -76,7 +77,7 @@ class SystemAdmin extends BaseModel { Session::delete('adminInfo'); Session::delete('adminId'); - Session::clear(); + Session::save(); } /** diff --git a/crmeb/app/admin/model/wechat/WechatQrcode.php b/crmeb/app/admin/model/wechat/WechatQrcode.php index 006f1d0c..03731f0c 100644 --- a/crmeb/app/admin/model/wechat/WechatQrcode.php +++ b/crmeb/app/admin/model/wechat/WechatQrcode.php @@ -105,7 +105,7 @@ class WechatQrcode extends BaseModel self::createForeverQrcode($id, $type); $res = self::getForeverQrcode($type, $id); } - if(!$res['ticket']) exception('临时二维码获取错误'); + if(!$res['ticket']) exception('永久二维码获取错误'); return $res; } diff --git a/crmeb/app/admin/model/wechat/WechatReply.php b/crmeb/app/admin/model/wechat/WechatReply.php index 6d8217ff..79b02387 100644 --- a/crmeb/app/admin/model/wechat/WechatReply.php +++ b/crmeb/app/admin/model/wechat/WechatReply.php @@ -9,7 +9,6 @@ namespace app\admin\model\wechat; use app\admin\model\system\SystemConfig; use crmeb\traits\ModelTrait; use crmeb\basic\BaseModel; -use crmeb\services\HookService; use crmeb\services\UtilService; use crmeb\services\WechatService; use think\facade\Route as Url; diff --git a/crmeb/app/api/controller/PublicController.php b/crmeb/app/api/controller/PublicController.php index bed15fbb..12a38498 100644 --- a/crmeb/app/api/controller/PublicController.php +++ b/crmeb/app/api/controller/PublicController.php @@ -1,4 +1,5 @@ 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 首页精品推荐图片 $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 首发新品顶部图 $likeInfo = StoreProduct::getHotProduct('id,image,store_name,cate_id,price,unit_name', 3);//TODO 热门榜单 猜你喜欢 $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(); $vipOpen = sysConfig('vip_open'); $vipOpen = is_string($vipOpen) ? (int)$vipOpen : $vipOpen; - foreach ($menusInfo as $key=>&$value){ + foreach ($menusInfo as $key => &$value) { $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]); - if($value['id'] == 174 && !StoreService::orderServiceStatus($user->uid)) + if ($value['id'] == 174 && !StoreService::orderServiceStatus($user->uid)) 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]); - if($value['wap_url'] == '/user/vip' && !$vipOpen) + if ($value['wap_url'] == '/user/vip' && !$vipOpen) 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]); } - 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') ?? []; $searchKeyword = []; - if(count($routineHotSearch)){ - foreach ($routineHotSearch as $key=>&$item){ + if (count($routineHotSearch)) { + foreach ($routineHotSearch as $key => &$item) { array_push($searchKeyword, $item['title']); } } @@ -133,21 +136,21 @@ class PublicController public function upload_image(Request $request) { $data = UtilService::postMore([ - ['filename','file'], - ],$request); - 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('非法操作'); - $res = UploadService::getInstance()->setUploadPath('store/comment')->image($data['filename']); - 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); - if(Cache::has('start_uploads_'.$request->uid())) - $start_uploads=(int)Cache::get('start_uploads_'.$request->uid()); + ['filename', 'file'], + ], $request); + 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('非法操作'); + $res = UploadService::instance()->setUploadPath('store/comment')->image($data['filename']); + 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); + if (Cache::has('start_uploads_' . $request->uid())) + $start_uploads = (int)Cache::get('start_uploads_' . $request->uid()); else $start_uploads = 0; $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']); - 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']]); } @@ -158,8 +161,8 @@ class PublicController public function logistics() { $expressList = Express::lst(); - if(!$expressList) return app('json')->successful([]); - return app('json')->successful($expressList->hidden(['code', 'id', 'sort', 'is_show'])->toArray()); + if (!$expressList) return app('json')->successful([]); + return app('json')->successful($expressList->hidden(['code', 'id', 'sort', 'is_show'])->toArray()); } /** @@ -178,8 +181,8 @@ class PublicController ['pay_time', time()], ['attach', 0], ], $request, true); - if($status == 200){ - ChannelService::instance()->send('PAY_SMS_SUCCESS', ['price'=> $price, 'number'=> $num], [$attach]); + if ($status == 200) { + ChannelService::instance()->send('PAY_SMS_SUCCESS', ['price' => $price, 'number' => $num], [$attach]); return app('json')->successful(); } return app('json')->fail(); @@ -190,7 +193,8 @@ class PublicController * @param Request $request * @return mixed */ - public function user_share(Request $request){ + public function user_share(Request $request) + { return app('json')->successful(UserBill::setUserShare($request->uid())); } @@ -199,21 +203,20 @@ class PublicController * @param Request $request * @return mixed */ - public function get_image_base64(Request $request){ - list($imageUrl,$codeUrl) = UtilService::postMore([ - ['image',''], - ['code',''], - ],$request,true); - try{ + public function get_image_base64(Request $request) + { + list($imageUrl, $codeUrl) = UtilService::postMore([ + ['image', ''], + ['code', ''], + ], $request, true); + try { $code = $codeUrl ? UtilService::setImageBase64($codeUrl) : false; $image = $imageUrl ? UtilService::setImageBase64($imageUrl) : false; - return app('json')->successful(compact('code','image')); - }catch (\Exception $e){ + return app('json')->successful(compact('code', 'image')); + } catch (\Exception $e) { return app('json')->fail($e->getMessage()); } } - - } \ No newline at end of file diff --git a/crmeb/app/api/controller/activity/StoreBargainController.php b/crmeb/app/api/controller/activity/StoreBargainController.php index da7f8fb3..c9ab274b 100644 --- a/crmeb/app/api/controller/activity/StoreBargainController.php +++ b/crmeb/app/api/controller/activity/StoreBargainController.php @@ -314,7 +314,7 @@ class StoreBargainController if($user['is_promoter'] || sysConfig('store_brokerage_statu') == 2) $valueData.='&pid='.$user['uid']; $res = RoutineCode::getPageCode('pages/activity/goods_bargain_details/index',$valueData,280); 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($imageInfo['image_type'] == 1) $remoteImage = UtilService::remoteImage($siteUrl.$imageInfo['dir']); else $remoteImage = UtilService::remoteImage($imageInfo['dir']); diff --git a/crmeb/app/api/controller/activity/StoreCombinationController.php b/crmeb/app/api/controller/activity/StoreCombinationController.php index c56256b6..d9d7d30b 100644 --- a/crmeb/app/api/controller/activity/StoreCombinationController.php +++ b/crmeb/app/api/controller/activity/StoreCombinationController.php @@ -1,4 +1,5 @@ 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()); + 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()); } @@ -44,49 +46,33 @@ class StoreCombinationController */ public function detail(Request $request, $id) { - 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['images'] = json_decode($combinationOne['images'],true); - list($pink ,$pindAll)= StorePink::getPinkAll($id,true);//拼团列表 - //公众号 - $name = $id.'_combination_detail_wap.jpg'; - $imageInfo = SystemAttachment::getInfo($name,'name'); + 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['images'] = json_decode($combinationOne['images'], true); + list($pink, $pindAll) = StorePink::getPinkAll($id, true);//拼团列表 $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_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; - if($combinationOne['stock'] > 0) $combinationOne['sale_stock'] = 1; - if(!strlen(trim($combinationOne['unit_name']))) $combinationOne['unit_name'] = '个'; + if ($combinationOne['stock'] > 0) $combinationOne['sale_stock'] = 1; + if (!strlen(trim($combinationOne['unit_name']))) $combinationOne['unit_name'] = '个'; $uid = $request->uid(); $data['pink'] = $pink; $data['pindAll'] = $pindAll; $data['storeInfo'] = $combinationOne; - $data['pink_ok_list']=StorePink::getPinkOkList($uid); - $data['pink_ok_sum']=StorePink::getPinkOkSumTotalNum($id); + $data['pink_ok_list'] = StorePink::getPinkOkList($uid); + $data['pink_ok_sum'] = StorePink::getPinkOkSumTotalNum($id); $data['reply'] = StoreProductReply::getRecProductReply($combinationOne['product_id']); - $data['replyCount'] = StoreProductReply::productValidWhere()->where('product_id',$combinationOne['product_id'])->count(); - if($data['replyCount']){ - $goodReply=StoreProductReply::productValidWhere()->where('product_id',$combinationOne['product_id'])->where('product_score',5)->count(); + $data['replyCount'] = StoreProductReply::productValidWhere()->where('product_id', $combinationOne['product_id'])->count(); + if ($data['replyCount']) { + $goodReply = StoreProductReply::productValidWhere()->where('product_id', $combinationOne['product_id'])->where('product_score', 5)->count(); $data['replyChance'] = $goodReply; - if($goodReply){ - $data['replyChance'] = bcdiv($goodReply,$data['replyCount'],2); - $data['replyChance'] = bcmul($data['replyChance'],100,3); + if ($goodReply) { + $data['replyChance'] = bcdiv($goodReply, $data['replyCount'], 2); + $data['replyChance'] = bcmul($data['replyChance'], 100, 3); } - }else $data['replyChance']=0; + } else $data['replyChance'] = 0; return app('json')->successful($data); } @@ -102,52 +88,52 @@ class StoreCombinationController $userBool = 0;//判断当前用户是否在团内 0未在 1在 $pinkBool = 0;//判断拼团是否成功 0未在 1在 $user = $request->user(); - if(!$id) return app('json')->fail('参数错误'); + if (!$id) return app('json')->fail('参数错误'); $pink = StorePink::getPinkUserOne($id); - if(!$pink) return app('json')->fail('参数错误'); - if(isset($pink['is_refund']) && $pink['is_refund']) { - if($pink['is_refund'] != $pink['id']){ + if (!$pink) return app('json')->fail('参数错误'); + if (isset($pink['is_refund']) && $pink['is_refund']) { + if ($pink['is_refund'] != $pink['id']) { $id = $pink['is_refund']; - return $this->pink($request,$id); - }else{ + return $this->pink($request, $id); + } else { return app('json')->fail('订单已退款'); } } - list($pinkAll,$pinkT,$count,$idAll,$uidAll) = StorePink::getPinkMemberAndPinkK($pink); - if($pinkT['status'] == 2){ + list($pinkAll, $pinkT, $count, $idAll, $uidAll) = StorePink::getPinkMemberAndPinkK($pink); + if ($pinkT['status'] == 2) { $pinkBool = 1; $is_ok = 1; - }else if($pinkT['status'] == 3){ + } else if ($pinkT['status'] == 3) { $pinkBool = -1; $is_ok = 0; - }else{ - if($count < 1){//组团完成 + } else { + if ($count < 1) {//组团完成 $is_ok = 1; - $pinkBool = StorePink::PinkComplete($uidAll,$idAll,$user['uid'],$pinkT); - }else{ - $pinkBool = StorePink::PinkFail($pinkAll,$pinkT,$pinkBool); + $pinkBool = StorePink::PinkComplete($uidAll, $idAll, $user['uid'], $pinkT); + } else { + $pinkBool = StorePink::PinkFail($pinkAll, $pinkT, $pinkBool); } } - if(!empty($pinkAll)){ - foreach ($pinkAll as $v){ - if($v['uid'] == $user['uid']) $userBool = 1; + if (!empty($pinkAll)) { + foreach ($pinkAll as $v) { + 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']); - if(!$combinationOne) return app('json')->fail('拼团不存在或已下架'); + if (!$combinationOne) return app('json')->fail('拼团不存在或已下架'); $data['userInfo']['uid'] = $user['uid']; $data['userInfo']['nickname'] = $user['nickname']; $data['userInfo']['avatar'] = $user['avatar']; $data['is_ok'] = $is_ok; $data['userBool'] = $userBool; $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['pinkAll'] = $pinkAll; $data['count'] = $count <= 0 ? 0 : $count; $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); } @@ -159,16 +145,16 @@ class StoreCombinationController public function remove(Request $request) { list($id, $cid) = UtilService::postMore([ - ['id',0], - ['cid',0], - ],$request, true); - if(!$id || !$cid) return app('json')->fail('缺少参数'); - $res = StorePink::removePink($request->uid(),$cid,$id); - if($res){ + ['id', 0], + ['cid', 0], + ], $request, true); + if (!$id || !$cid) return app('json')->fail('缺少参数'); + $res = StorePink::removePink($request->uid(), $cid, $id); + if ($res) { return app('json')->successful('取消成功'); } $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); } @@ -180,70 +166,70 @@ class StoreCombinationController */ public function poster(Request $request) { - list($pinkId, $from) = UtilService::postMore([['id',0],['from','wechat']],$request,true); - if(!$pinkId) return app('json')->fail('参数错误'); + list($pinkId, $from) = UtilService::postMore([['id', 0], ['from', 'wechat']], $request, true); + if (!$pinkId) return app('json')->fail('参数错误'); $user = $request->user(); $pinkInfo = StorePink::getPinkUserOne($pinkId); $storeCombinationInfo = StoreCombination::getCombinationOne($pinkInfo['cid']); $data['title'] = $storeCombinationInfo['title']; $data['image'] = $storeCombinationInfo['image']; $data['price'] = $pinkInfo['total_price']; - $data['label'] = $pinkInfo['people'].'人团'; - if($pinkInfo['k_id']) $pinkAll = StorePink::getPinkMember($pinkInfo['k_id']); + $data['label'] = $pinkInfo['people'] . '人团'; + if ($pinkInfo['k_id']) $pinkAll = StorePink::getPinkMember($pinkInfo['k_id']); else $pinkAll = StorePink::getPinkMember($pinkInfo['id']); - $count = count($pinkAll)+1; - $data['msg'] = '原价¥'.$storeCombinationInfo['product_price'].' 还差'.(int)bcsub((int)$pinkInfo['people'],$count,0).'人拼团成功'; - try{ + $count = count($pinkAll) + 1; + $data['msg'] = '原价¥' . $storeCombinationInfo['product_price'] . ' 还差' . (int)bcsub((int)$pinkInfo['people'], $count, 0) . '人拼团成功'; + try { $siteUrl = sysConfig('site_url'); - if($from == 'routine'){ + if ($from == 'routine') { //小程序 - $name = $pinkId.'_'.$user['uid'].'_'.$user['is_promoter'].'_pink_share_routine.jpg'; - $imageInfo = SystemAttachment::getInfo($name,'name'); - if(!$imageInfo){ - $valueData = 'id='.$pinkId; - if($user['is_promoter'] || sysConfig('store_brokerage_statu')==2) $valueData.='&pid='.$user['uid']; - $res = RoutineCode::getPageCode('pages/activity/goods_combination_status/index',$valueData,280); - if(!$res) return app('json')->fail('二维码生成失败'); - $imageInfo = UploadService::getInstance()->setUploadPath('routine/activity/pink/code')->imageStream($name,$res); - if(!is_array($imageInfo)) return app('json')->fail($imageInfo); - if($imageInfo['image_type'] == 1) $remoteImage = UtilService::remoteImage($siteUrl.$imageInfo['dir']); + $name = $pinkId . '_' . $user['uid'] . '_' . $user['is_promoter'] . '_pink_share_routine.jpg'; + $imageInfo = SystemAttachment::getInfo($name, 'name'); + if (!$imageInfo) { + $valueData = 'id=' . $pinkId; + if ($user['is_promoter'] || sysConfig('store_brokerage_statu') == 2) $valueData .= '&pid=' . $user['uid']; + $res = RoutineCode::getPageCode('pages/activity/goods_combination_status/index', $valueData, 280); + if (!$res) return app('json')->fail('二维码生成失败'); + $imageInfo = UploadService::instance()->setUploadPath('routine/activity/pink/code')->imageStream($name, $res); + if (!is_array($imageInfo)) return app('json')->fail($imageInfo); + if ($imageInfo['image_type'] == 1) $remoteImage = UtilService::remoteImage($siteUrl . $imageInfo['dir']); else $remoteImage = UtilService::remoteImage($imageInfo['dir']); - 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); + 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); $url = $imageInfo['dir']; - }else $url = $imageInfo['att_dir']; + } else $url = $imageInfo['att_dir']; $data['url'] = $url; - if($imageInfo['image_type'] == 1) - $data['url'] = $siteUrl.$url; - $posterImage = UtilService::setShareMarketingPoster($data,'routine/activity/pink/poster'); - 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); - if($posterImage['image_type'] == 1) $posterImage['dir'] = $siteUrl.$posterImage['dir']; + if ($imageInfo['image_type'] == 1) + $data['url'] = $siteUrl . $url; + $posterImage = UtilService::setShareMarketingPoster($data, 'routine/activity/pink/poster'); + 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); + if ($posterImage['image_type'] == 1) $posterImage['dir'] = $siteUrl . $posterImage['dir']; $routinePosterImage = UtilService::setHttpType($posterImage['dir'], 0);//小程序推广海报 - return app('json')->successful(['url'=>$routinePosterImage]); - }else if($from == 'wechat'){ + return app('json')->successful(['url' => $routinePosterImage]); + } else if ($from == 'wechat') { //公众号 - $name = $pinkId.'_'.$user['uid'].'_'.$user['is_promoter'].'_pink_share_wap.jpg'; - $imageInfo = SystemAttachment::getInfo($name,'name'); - if(!$imageInfo){ - $codeUrl = UtilService::setHttpType($siteUrl.'/activity/group_rule/'.$pinkId.'?spread='.$user['uid'], 1);//二维码链接 + $name = $pinkId . '_' . $user['uid'] . '_' . $user['is_promoter'] . '_pink_share_wap.jpg'; + $imageInfo = SystemAttachment::getInfo($name, 'name'); + if (!$imageInfo) { + $codeUrl = UtilService::setHttpType($siteUrl . '/activity/group_rule/' . $pinkId . '?spread=' . $user['uid'], 1);//二维码链接 $imageInfo = UtilService::getQRCodePath($codeUrl, $name); - 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); + 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); $url = $imageInfo['dir']; - }else $url = $imageInfo['att_dir']; + } else $url = $imageInfo['att_dir']; $data['url'] = $url; - if($imageInfo['image_type'] == 1) $data['url'] = $siteUrl.$url; - $posterImage = UtilService::setShareMarketingPoster($data,'wap/activity/pink/poster'); - 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); - if($posterImage['image_type'] == 1) $posterImage['dir'] = $siteUrl.$posterImage['dir']; + if ($imageInfo['image_type'] == 1) $data['url'] = $siteUrl . $url; + $posterImage = UtilService::setShareMarketingPoster($data, 'wap/activity/pink/poster'); + 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); + if ($posterImage['image_type'] == 1) $posterImage['dir'] = $siteUrl . $posterImage['dir']; $wapPosterImage = UtilService::setHttpType($posterImage['dir'], 1);//公众号推广海报 - return app('json')->successful(['url'=>$wapPosterImage]); + return app('json')->successful(['url' => $wapPosterImage]); } return app('json')->fail('参数错误'); - }catch (\Exception $e){ - return app('json')->fail(['line'=>$e->getLine(),'message'=>$e->getMessage()]); + } catch (\Exception $e) { + return app('json')->fail(['line' => $e->getLine(), 'message' => $e->getMessage()]); } } diff --git a/crmeb/app/api/controller/activity/StoreSeckillController.php b/crmeb/app/api/controller/activity/StoreSeckillController.php index 2f2fd904..45c68b6a 100644 --- a/crmeb/app/api/controller/activity/StoreSeckillController.php +++ b/crmeb/app/api/controller/activity/StoreSeckillController.php @@ -1,4 +1,5 @@ &$value){ + if (count($seckillTime)) { + foreach ($seckillTime as $key => &$value) { $currentHour = date('H'); - $activityEndHour = bcadd((int)$value['time'],(int)$value['continued'],0); - if($activityEndHour > 24){ - $value['time'] = strlen((int)$value['time']) == 2 ? (int)$value['time'].':00' : '0'.(int)$value['time'].':00'; + $activityEndHour = bcadd((int)$value['time'], (int)$value['continued'], 0); + if ($activityEndHour > 24) { + $value['time'] = strlen((int)$value['time']) == 2 ? (int)$value['time'] . ':00' : '0' . (int)$value['time'] . ':00'; $value['state'] = '即将开始'; $value['status'] = 2; - $value['stop'] = (int)bcadd(strtotime(date('Y-m-d')),bcmul($activityEndHour,3600,0)); - }else{ - if($currentHour >= (int)$value['time'] && $currentHour < $activityEndHour){ - $value['time'] = strlen((int)$value['time']) == 2 ? (int)$value['time'].':00' : '0'.(int)$value['time'].':00'; + $value['stop'] = (int)bcadd(strtotime(date('Y-m-d')), bcmul($activityEndHour, 3600, 0)); + } else { + if ($currentHour >= (int)$value['time'] && $currentHour < $activityEndHour) { + $value['time'] = strlen((int)$value['time']) == 2 ? (int)$value['time'] . ':00' : '0' . (int)$value['time'] . ':00'; $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; - if(!$seckillTimeIndex) $seckillTimeIndex = $key; - }else if($currentHour < (int)$value['time']){ - $value['time'] = strlen((int)$value['time']) == 2 ? (int)$value['time'].':00' : '0'.(int)$value['time'].':00'; + if (!$seckillTimeIndex) $seckillTimeIndex = $key; + } else if ($currentHour < (int)$value['time']) { + $value['time'] = strlen((int)$value['time']) == 2 ? (int)$value['time'] . ':00' : '0' . (int)$value['time'] . ':00'; $value['state'] = '即将开始'; $value['status'] = 2; - $value['stop'] = (int)bcadd(strtotime(date('Y-m-d')),bcmul($activityEndHour,3600,0)); - }else if($currentHour >= $activityEndHour){ - $value['time'] = strlen((int)$value['time']) == 2 ? (int)$value['time'].':00' : '0'.(int)$value['time'].':00'; + $value['stop'] = (int)bcadd(strtotime(date('Y-m-d')), bcmul($activityEndHour, 3600, 0)); + } else if ($currentHour >= $activityEndHour) { + $value['time'] = strlen((int)$value['time']) == 2 ? (int)$value['time'] . ':00' : '0' . (int)$value['time'] . ':00'; $value['state'] = '已结束'; $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'); - if(strstr($data['lovely'],'http') === false && strlen(trim($data['lovely']))) $data['lovely'] = sysConfig('site_url').$data['lovely']; - $data['lovely'] = str_replace('\\','/',$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['seckillTime'] = $seckillTime; $data['seckillTimeIndex'] = $seckillTimeIndex; return app('json')->successful($data); @@ -79,18 +81,18 @@ class StoreSeckillController public function lst(Request $request, $time) { list($page, $limit) = UtilService::getMore([ - ['page',0], - ['limit',0], - ],$request, true); - if(!$time) return app('json')->fail('参数错误'); + ['page', 0], + ['limit', 0], + ], $request, true); + if (!$time) return app('json')->fail('参数错误'); $timeInfo = GroupDataService::getDataNumber((int)$time); - $activityEndHour = bcadd((int)$timeInfo['time'],(int)$timeInfo['continued'],0); - $startTime = bcadd(strtotime(date('Y-m-d')),bcmul($timeInfo['time'],3600,0)); - $stopTime = bcadd(strtotime(date('Y-m-d')),bcmul($activityEndHour,3600,0)); + $activityEndHour = bcadd((int)$timeInfo['time'], (int)$timeInfo['continued'], 0); + $startTime = bcadd(strtotime(date('Y-m-d')), bcmul($timeInfo['time'], 3600, 0)); + $stopTime = bcadd(strtotime(date('Y-m-d')), bcmul($activityEndHour, 3600, 0)); $seckillInfo = StoreSeckill::seckillList($startTime, $stopTime, $page, $limit); - if(count($seckillInfo)){ - foreach ($seckillInfo as $key=>&$item){ - $percent = (int)bcmul(bcdiv($item['sales'],bcadd($item['stock'],$item['sales'],0),2),100,0); + if (count($seckillInfo)) { + foreach ($seckillInfo as $key => &$item) { + $percent = (int)bcmul(bcdiv($item['sales'], bcadd($item['stock'], $item['sales'], 0), 2), 100, 0); $item['percent'] = $percent ? $percent : 10; } } @@ -103,38 +105,23 @@ class StoreSeckillController * @param $id * @return mixed */ - 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(); - - //公众号 - $name = $id.'_seckill_detail_wap.jpg'; - $imageInfo = SystemAttachment::getInfo($name,'name'); + 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(); $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_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(); $storeInfo['userLike'] = StoreProductRelation::isProductRelation($id, $uid, 'like', 'product_seckill'); - $storeInfo['like_num'] = StoreProductRelation::productRelationNum($id,'like','product_seckill'); - $storeInfo['userCollect'] = StoreProductRelation::isProductRelation($id, $uid,'collect','product_seckill'); + $storeInfo['like_num'] = StoreProductRelation::productRelationNum($id, 'like', 'product_seckill'); + $storeInfo['userCollect'] = StoreProductRelation::isProductRelation($id, $uid, 'collect', 'product_seckill'); $storeInfo['uid'] = $uid; $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['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); } } \ No newline at end of file diff --git a/crmeb/app/api/controller/order/StoreOrderController.php b/crmeb/app/api/controller/order/StoreOrderController.php index 01293033..3e17953f 100644 --- a/crmeb/app/api/controller/order/StoreOrderController.php +++ b/crmeb/app/api/controller/order/StoreOrderController.php @@ -516,7 +516,7 @@ class StoreOrderController 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 $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,[ 'uid'=>$uid, 'oid'=>$cartInfo['oid'], diff --git a/crmeb/app/api/controller/publics/ArticleController.php b/crmeb/app/api/controller/publics/ArticleController.php index 4bca6151..3acec4da 100644 --- a/crmeb/app/api/controller/publics/ArticleController.php +++ b/crmeb/app/api/controller/publics/ArticleController.php @@ -22,8 +22,8 @@ class ArticleController public function lst(Request $request, $cid) { list($page, $limit) = UtilService::getMore([ - ['page',0], - ['limit',0], + ['page',1], + ['limit',10], ],$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") ?? []; if(is_object($list)) $list = $list->toArray(); diff --git a/crmeb/app/api/controller/store/CategoryController.php b/crmeb/app/api/controller/store/CategoryController.php index fba12753..bbff9fc7 100644 --- a/crmeb/app/api/controller/store/CategoryController.php +++ b/crmeb/app/api/controller/store/CategoryController.php @@ -9,7 +9,7 @@ class CategoryController { 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()); } } \ No newline at end of file diff --git a/crmeb/app/api/controller/store/StoreProductController.php b/crmeb/app/api/controller/store/StoreProductController.php index bf29471b..822481e9 100644 --- a/crmeb/app/api/controller/store/StoreProductController.php +++ b/crmeb/app/api/controller/store/StoreProductController.php @@ -10,6 +10,7 @@ use app\models\store\StoreProductRelation; use app\models\store\StoreProductReply; use app\Request; use crmeb\services\GroupDataService; +use crmeb\services\QrcodeService; use crmeb\services\SystemConfigService; use crmeb\services\UtilService; @@ -46,86 +47,67 @@ class StoreProductController * @param Request $request * @param $id * @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) { - if (!$id || !($storeInfo = StoreProduct::getValidProduct($id,'id'))) return app('json')->fail('商品不存在或已下架'); - $userType = $request->get('user_type','wechat'); + if (!$id || !($storeInfo = StoreProduct::getValidProduct($id, 'id'))) return app('json')->fail('商品不存在或已下架'); + $userType = $request->get('user_type', 'wechat'); $user = $request->user(); - try{ - switch ($userType){ + try { + switch ($userType) { case 'wechat': //公众号 - $name = $id.'_product_detail_'.$user['uid'].'_is_promoter_'.$user['is_promoter'].'_wap.jpg'; - $imageInfo = SystemAttachment::getInfo($name,'name'); - $siteUrl = sysConfig('site_url'); - if(!$imageInfo){ - $codeUrl = UtilService::setHttpType($siteUrl.'/detail/'.$id.'?spread='.$user['uid'], 1);//二维码链接 - $imageInfo = UtilService::getQRCodePath($codeUrl, $name); - 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)]); + $name = $id . '_product_detail_' . $user['uid'] . '_is_promoter_' . $user['is_promoter'] . '_wap.jpg'; + $url = QrcodeService::getWechatQrcodePath($name, '/detail/' . $id . '?spread=' . $user['uid']); + if ($url === false) + return app('json')->fail('二维码生成失败'); + else + return app('json')->successful(['code' => UtilService::setImageBase64($url)]); break; case 'routine': //小程序 - $name = $id.'_'.$user['uid'].'_'.$user['is_promoter'].'_product.jpg'; - $imageInfo = SystemAttachment::getInfo($name,'name'); - $siteUrl = sysConfig('site_url').DS; - if(!$imageInfo){ - $data='id='.$id; - 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); - if(!$res) return app('json')->fail('二维码生成失败'); - $imageInfo = \crmeb\services\UploadService::getInstance()->setUploadPath('routine/product')->imageStream($name,$res); - if(is_string($imageInfo)) return app('json')->fail($imageInfo); - if($imageInfo['image_type'] == 1) $remoteImage = UtilService::remoteImage($siteUrl.$imageInfo['dir']); + $name = $id . '_' . $user['uid'] . '_' . $user['is_promoter'] . '_product.jpg'; + $imageInfo = SystemAttachment::getInfo($name, 'name'); + $siteUrl = sysConfig('site_url') . DS; + if (!$imageInfo) { + $data = 'id=' . $id; + 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); + if (!$res) return app('json')->fail('二维码生成失败'); + $imageInfo = \crmeb\services\UploadService::instance()->setUploadPath('routine/product')->imageStream($name, $res); + if (is_string($imageInfo)) return app('json')->fail($imageInfo); + if ($imageInfo['image_type'] == 1) $remoteImage = UtilService::remoteImage($siteUrl . $imageInfo['dir']); else $remoteImage = UtilService::remoteImage($imageInfo['dir']); - 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); + 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); $url = $imageInfo['dir']; - }else $url = $imageInfo['att_dir']; - if($imageInfo['image_type'] == 1) $url = $siteUrl.$url; - return app('json')->successful(['code'=>$url]); + } else $url = $imageInfo['att_dir']; + if ($imageInfo['image_type'] == 1) $url = $siteUrl . $url; + return app('json')->successful(['code' => $url]); } - }catch (\Exception $e){ - return app('json')->fail($e->getMessage(),[ - 'code'=>$e->getCode(), - 'line'=>$e->getLine(), - 'message'=>$e->getMessage() + } catch (\Exception $e) { + return app('json')->fail($e->getMessage(), [ + 'code' => $e->getCode(), + 'line' => $e->getLine(), + '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('商品不存在或已下架'); - - //公众号 - $name = $id.'_product_detail_wap.jpg'; - $imageInfo = SystemAttachment::getInfo($name,'name'); $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_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(); $data['uid'] = $uid; //替换windows服务器下正反斜杠问题导致图片无法显示 @@ -134,39 +116,40 @@ class StoreProductController }, $storeInfo['description']); $storeInfo['userCollect'] = StoreProductRelation::isProductRelation($id, $uid, 'collect'); $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'); $data['storeInfo'] = StoreProduct::setLevelPrice($storeInfo, $uid, true); $data['similarity'] = StoreProduct::cateIdBySimilarityProduct($storeInfo['cate_id'], 'id,store_name,image,price,sales,ficti', 4); $data['productAttr'] = $productAttr; $data['productValue'] = $productValue; $data['priceName'] = 0; - if($uid){ + if ($uid) { $storeBrokerageStatus = sysConfig('store_brokerage_statu') ?? 1; - if($storeBrokerageStatus == 2) + if ($storeBrokerageStatus == 2) $data['priceName'] = StoreProduct::getPacketPrice($storeInfo, $productValue); - else{ + else { $user = $request->user(); - if($user->is_promoter) + if ($user->is_promoter) $data['priceName'] = StoreProduct::getPacketPrice($storeInfo, $productValue); } - if(!strlen(trim($data['priceName']))) + if (!strlen(trim($data['priceName']))) $data['priceName'] = 0; } $data['reply'] = StoreProductReply::getRecProductReply($storeInfo['id']); $data['replyCount'] = StoreProductReply::productValidWhere()->where('product_id', $storeInfo['id'])->count(); if ($data['replyCount']) { $goodReply = StoreProductReply::productValidWhere()->where('product_id', $storeInfo['id'])->where('product_score', 5)->count(); - $data['replyChance'] = $goodReply; - if($goodReply){ + $data['replyChance'] = $goodReply; + if ($goodReply) { $data['replyChance'] = bcdiv($goodReply, $data['replyCount'], 2); $data['replyChance'] = bcmul($data['replyChance'], 100, 2); } } else $data['replyChance'] = 0; $data['mer_id'] = $storeInfo['mer_id']; $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['store_self_mention'] = (int)sysConfig('store_self_mention') ?? 0;//门店自提是否开启 return app('json')->successful($data); } @@ -182,11 +165,11 @@ class StoreProductController public function product_hot(Request $request) { list($page, $limit) = UtilService::getMore([ - ['page',0], - ['limit',0] + ['page', 0], + ['limit', 0] ], $request, true); - if(!$limit) return app('json')->successful([]); - $productHot = StoreProduct::getHotProductLoading('id,image,store_name,cate_id,price,unit_name,ot_price',(int)$page,(int)$limit); + if (!$limit) return app('json')->successful([]); + $productHot = StoreProduct::getHotProductLoading('id,image,store_name,cate_id,price,unit_name,ot_price', (int)$page, (int)$limit); return app('json')->successful($productHot); } @@ -199,21 +182,21 @@ class StoreProductController * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ - public function groom_list(Request $request,$type) + public function groom_list(Request $request, $type) { $info['banner'] = []; $info['list'] = []; - if($type == 1){//TODO 精品推荐 - $info['banner'] = GroupDataService::getData('routine_home_bast_banner')?:[];//TODO 首页精品推荐图片 + if ($type == 1) {//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 精品推荐个数 - }else if($type == 2){//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 热门榜单 猜你喜欢 - }else if($type == 3){//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 首发新品 - }else if($type == 4){//TODO 促销单品 - $info['banner'] = GroupDataService::getData('routine_home_benefit_banner')?:[];//TODO 促销单品推荐图片 + } else if ($type == 2) {//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 热门榜单 猜你喜欢 + } else if ($type == 3) {//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 首发新品 + } else if ($type == 4) {//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 促销单品 } return app('json')->successful($info); @@ -226,9 +209,10 @@ class StoreProductController */ 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)); } + /** * 获取产品评论 * @param Request $request @@ -239,10 +223,10 @@ class StoreProductController public function reply_list(Request $request, $id) { list($page, $limit, $type) = UtilService::getMore([ - ['page',0],['limit',0],['type',0] + ['page', 0], ['limit', 0], ['type', 0] ], $request, true); - if(!$id || !is_numeric($id)) return app('json')->fail('参数错误!'); - $list = StoreProductReply::getProductReplyList($id,(int)$type,$page,$limit); + if (!$id || !is_numeric($id)) return app('json')->fail('参数错误!'); + $list = StoreProductReply::getProductReplyList($id, (int)$type, $page, $limit); return app('json')->successful($list); } diff --git a/crmeb/app/api/controller/user/UserBillController.php b/crmeb/app/api/controller/user/UserBillController.php index 245602b7..17401108 100644 --- a/crmeb/app/api/controller/user/UserBillController.php +++ b/crmeb/app/api/controller/user/UserBillController.php @@ -1,4 +1,5 @@ uid(); - $lastDayCount = UserBill::yesterdayCommissionSum($uid);//昨天的佣金 - $extractCount = UserExtract::extractSum($uid);//累计提现金额 - $commissionCount = UserBill::getBrokerage($uid);//获取总佣金 - if($commissionCount > 0){ - $rechargeCount = UserBill::getRecharge($uid);//累计充值 - $orderYuePrice = StoreOrder::getOrderStatusYueSum($uid);//余额累计消费 - $systemAdd = UserBill::getSystemAdd($uid);//后台添加余额 - $yueCount = bcadd($rechargeCount,$systemAdd,2);// 后台添加余额 + 累计充值 = 非佣金的总金额 - $orderYuePrice = $yueCount > $orderYuePrice ? 0 : bcsub($orderYuePrice,$yueCount,2);// 余额累计消费(使用佣金消费的金额) - $commissionCount = bcsub($commissionCount, $extractCount,2);//减去已提现金额 - $extractPriceCount = UserExtract::userExtractTotalPrice($uid,0); - $commissionCount = $extractPriceCount < $commissionCount ? bcsub($commissionCount, $extractPriceCount,2) : 0;//减去审核中的提现金额 - $commissionCount = $commissionCount > $orderYuePrice ? bcsub($commissionCount, $orderYuePrice,2) : 0;//减掉余额支付 - } - $data['lastDayCount'] = $lastDayCount; - $data['extractCount'] = $extractCount; - $data['commissionCount'] = $commissionCount; - return app('json')->successful($data); - } + public function commission(Request $request) + { + $uid = $request->uid(); + $lastDayCount = UserBill::yesterdayCommissionSum($uid);//昨天的佣金 + $extractCount = UserExtract::extractSum($uid);//累计提现金额 + $commissionCount = UserBill::getBrokerage($uid);//获取总佣金 + if ($commissionCount > 0) { + $rechargeCount = UserBill::getRecharge($uid);//累计充值 + $orderYuePrice = StoreOrder::getOrderStatusYueSum($uid);//余额累计消费 + $systemAdd = UserBill::getSystemAdd($uid);//后台添加余额 + $yueCount = bcadd($rechargeCount, $systemAdd, 2);// 后台添加余额 + 累计充值 = 非佣金的总金额 + $orderYuePrice = $yueCount > $orderYuePrice ? 0 : bcsub($orderYuePrice, $yueCount, 2);// 余额累计消费(使用佣金消费的金额) + $commissionCount = bcsub($commissionCount, $extractCount, 2);//减去已提现金额 + $extractPriceCount = UserExtract::userExtractTotalPrice($uid, 0); + $commissionCount = $extractPriceCount < $commissionCount ? bcsub($commissionCount, $extractPriceCount, 2) : 0;//减去审核中的提现金额 + $commissionCount = $commissionCount > $orderYuePrice ? bcsub($commissionCount, $orderYuePrice, 2) : 0;//减掉余额支付 + } + $data['lastDayCount'] = $lastDayCount; + $data['extractCount'] = $extractCount; + $data['commissionCount'] = $commissionCount; + return app('json')->successful($data); + } /** @@ -65,12 +66,12 @@ class UserBillController public function spread_people(Request $request) { $spreadInfo = UtilService::postMore([ - ['page',1], - ['limit',20], - ['grade',0], - ['keyword',''], - ['sort',''], - ],$request); + ['page', 1], + ['limit', 20], + ['grade', 0], + ['keyword', ''], + ['sort', ''], + ], $request); $uid = $request->uid(); $data['list'] = User::getUserSpreadGrade($uid, $spreadInfo['grade'], $spreadInfo['sort'], $spreadInfo['keyword'], $spreadInfo['page'], $spreadInfo['limit']); $data['total'] = User::getSpreadCount($uid); @@ -86,19 +87,19 @@ class UserBillController public function spread_order(Request $request) { $orderInfo = UtilService::postMore([ - ['page',1], - ['limit',20], - ['category','now_money'], - ['type','brokerage'], - ],$request); + ['page', 1], + ['limit', 20], + ['category', 'now_money'], + ['type', 'brokerage'], + ], $request); $data['list'] = []; $data['count'] = 0; $uid = $request->uid(); $data['list'] = UserBill::getRecordList($uid, $orderInfo['page'], $orderInfo['limit'], $orderInfo['category'], $orderInfo['type']); $count = UserBill::getRecordOrderCount($uid, $orderInfo['category'], $orderInfo['type']); $data['count'] = $count ? $count : 0; - if(!count($data['list'])) return app('json')->successful($data); - foreach ($data['list'] as $key=>&$value){ + if (!count($data['list'])) return app('json')->successful($data); + foreach ($data['list'] as $key => &$value) { $value['child'] = UserBill::getRecordOrderListDraw($uid, $value['time'], $orderInfo['category'], $orderInfo['type']); $value['count'] = count($value['child']); } @@ -108,31 +109,31 @@ class UserBillController /** * 推广佣金明细 * @param Request $request - * @param $type 0 全部 1 消费 2 充值 3 返佣 4 提现 + * @param $type 0 全部 1 消费 2 充值 3 返佣 4 提现 * @return mixed */ public function spread_commission(Request $request, $type) { list($page, $limit) = UtilService::getMore([ - ['page',0], - ['limit',0], - ],$request, true); - return app('json')->successful(UserBill::getUserBillList($request->uid(),$page,$limit,$type)); + ['page', 0], + ['limit', 0], + ], $request, true); + return app('json')->successful(UserBill::getUserBillList($request->uid(), $page, $limit, $type)); } /** * 推广 佣金/提现 总和 * @param Request $request - * @param $type 3 佣金 4 提现 + * @param $type 3 佣金 4 提现 * @return mixed */ public function spread_count(Request $request, $type) { $count = 0; - if($type == 3) $count = UserBill::getRecordCount($request->uid(), 'now_money', 'brokerage'); - else if($type == 4) $count = UserExtract::userExtractTotalPrice($request->uid());//累计提现 + if ($type == 3) $count = UserBill::getRecordCount($request->uid(), 'now_money', 'brokerage'); + else if ($type == 4) $count = UserExtract::userExtractTotalPrice($request->uid());//累计提现 $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) { list($type) = UtilService::getMore([ - ['type',2], - ],$request, true); + ['type', 2], + ], $request, true); $user = $request->user(); $rootPath = app()->getRootPath(); - try{ + try { $resRoutine = true;//小程序 $resWap = true;//公众号 $siteUrl = sysConfig('site_url'); $routineSpreadBanner = GroupDataService::getData('routine_spread_banner'); - if(!count($routineSpreadBanner)) return app('json')->fail('暂无海报'); - if($type == 1){ + if (!count($routineSpreadBanner)) return app('json')->fail('暂无海报'); + if ($type == 1) { //小程序 - $name = $user['uid'].'_'.$user['is_promoter'].'_user_routine.jpg'; - $imageInfo = SystemAttachment::getInfo($name,'name'); + $name = $user['uid'] . '_' . $user['is_promoter'] . '_user_routine.jpg'; + $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; - SystemAttachment::where(['name'=>$name])->delete(); + SystemAttachment::where(['name' => $name])->delete(); } - if(!$imageInfo){ + if (!$imageInfo) { $res = RoutineCode::getShareCode($user['uid'], 'spread', '', ''); - if(!$res) return app('json')->fail('二维码生成失败'); - $imageInfo = UploadService::getInstance()->setUploadPath('routine/spread/code')->imageStream($name,$res['res']); - 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); - RoutineQrcode::setRoutineQrcodeFind($res['id'],['status'=>1,'time'=>time(),'qrcode_url'=>$imageInfo['dir']]); + if (!$res) return app('json')->fail('二维码生成失败'); + $imageInfo = UploadService::instance()->setUploadPath('routine/spread/code')->imageStream($name, $res['res']); + 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); + RoutineQrcode::setRoutineQrcodeFind($res['id'], ['status' => 1, 'time' => time(), 'qrcode_url' => $imageInfo['dir']]); $urlCode = $imageInfo['dir']; - }else $urlCode = $imageInfo['att_dir']; - if($imageInfo['image_type'] == 1) $urlCode = $siteUrl.$urlCode; + } else $urlCode = $imageInfo['att_dir']; + if ($imageInfo['image_type'] == 1) $urlCode = $siteUrl . $urlCode; $siteUrlHttps = UtilService::setHttpType($siteUrl, 0); - $filelink=[ - 'Bold'=>'static'. DS .'font'. DS .'Alibaba-PuHuiTi-Regular.otf', - 'Normal'=>'static'. DS .'font'. DS .'Alibaba-PuHuiTi-Regular.otf', + $filelink = [ + 'Bold' => '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['Normal'])) return app('json')->fail('缺少字体文件Normal'); - foreach ($routineSpreadBanner as $key=>&$item){ + if (!file_exists($filelink['Bold'])) return app('json')->fail('缺少字体文件Bold'); + if (!file_exists($filelink['Normal'])) return app('json')->fail('缺少字体文件Normal'); + foreach ($routineSpreadBanner as $key => &$item) { $posterInfo = '海报生成失败:('; $config = array( - 'image'=>array( + 'image' => array( array( - 'url'=>$urlCode, //二维码资源 - 'stream'=>0, - 'left'=>114, - 'top'=>790, - 'right'=>0, - 'bottom'=>0, - 'width'=>120, - 'height'=>120, - 'opacity'=>100 + 'url' => $urlCode, //二维码资源 + 'stream' => 0, + 'left' => 114, + 'top' => 790, + 'right' => 0, + 'bottom' => 0, + 'width' => 120, + 'height' => 120, + 'opacity' => 100 ) ), - 'text'=>array( + 'text' => array( array( - 'text'=>$user['nickname'], - 'left'=>250, - 'top'=>840, - 'fontPath'=>$rootPath.'public'. DS .$filelink['Bold'], //字体文件 - 'fontSize'=>16, //字号 - 'fontColor'=>'40,40,40', //字体颜色 - 'angle'=>0, + 'text' => $user['nickname'], + 'left' => 250, + 'top' => 840, + 'fontPath' => $rootPath . 'public' . DS . $filelink['Bold'], //字体文件 + 'fontSize' => 16, //字号 + 'fontColor' => '40,40,40', //字体颜色 + 'angle' => 0, ), array( - 'text'=>'邀请您加入'.sysConfig('site_name'), - 'left'=>250, - 'top'=>880, - 'fontPath'=>$rootPath.'public'. DS .$filelink['Normal'], //字体文件 - 'fontSize'=>16, //字号 - 'fontColor'=>'40,40,40', //字体颜色 - 'angle'=>0, + 'text' => '邀请您加入' . sysConfig('site_name'), + 'left' => 250, + 'top' => 880, + 'fontPath' => $rootPath . 'public' . DS . $filelink['Normal'], //字体文件 + 'fontSize' => 16, //字号 + 'fontColor' => '40,40,40', //字体颜色 + 'angle' => 0, ) ), - 'background'=>$item['pic'] + 'background' => $item['pic'] ); - $resRoutine = $resRoutine && $posterInfo = UtilService::setSharePoster($config,'routine/spread/poster'); - 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); - if($resRoutine){ - if($posterInfo['image_type'] == 1) - $item['poster'] = $siteUrlHttps.$posterInfo['dir']; + $resRoutine = $resRoutine && $posterInfo = UtilService::setSharePoster($config, 'routine/spread/poster'); + 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); + if ($resRoutine) { + if ($posterInfo['image_type'] == 1) + $item['poster'] = $siteUrlHttps . $posterInfo['dir']; else $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'; - $imageInfo = SystemAttachment::getInfo($name,'name'); + $name = $user['uid'] . '_' . $user['is_promoter'] . '_user_wap.jpg'; + $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; - SystemAttachment::where(['name'=>$name])->delete(); + SystemAttachment::where(['name' => $name])->delete(); } - if(!$imageInfo){ - $codeUrl = UtilService::setHttpType($siteUrl.'?spread='.$user['uid'], 1);//二维码链接 + if (!$imageInfo) { + $codeUrl = UtilService::setHttpType($siteUrl . '?spread=' . $user['uid'], 1);//二维码链接 $imageInfo = UtilService::getQRCodePath($codeUrl, $name); - 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); + 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); $urlCode = $imageInfo['dir']; - }else $urlCode = $imageInfo['att_dir']; - if($imageInfo['image_type'] == 1) $urlCode = $siteUrl.$urlCode; + } else $urlCode = $imageInfo['att_dir']; + if ($imageInfo['image_type'] == 1) $urlCode = $siteUrl . $urlCode; $siteUrl = UtilService::setHttpType($siteUrl, 1); - $filelink=[ - 'Bold'=>'static'. DS .'font'. DS .'Alibaba-PuHuiTi-Regular.otf', - 'Normal'=>'static'. DS .'font'. DS .'Alibaba-PuHuiTi-Regular.otf', + $filelink = [ + 'Bold' => '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['Normal'])) return app('json')->fail('缺少字体文件Normal'); - foreach ($routineSpreadBanner as $key=>&$item){ + if (!file_exists($filelink['Bold'])) return app('json')->fail('缺少字体文件Bold'); + if (!file_exists($filelink['Normal'])) return app('json')->fail('缺少字体文件Normal'); + foreach ($routineSpreadBanner as $key => &$item) { $posterInfo = '海报生成失败:('; $config = array( - 'image'=>array( + 'image' => array( array( - 'url'=>$urlCode, //二维码资源 - 'stream'=>0, - 'left'=>114, - 'top'=>790, - 'right'=>0, - 'bottom'=>0, - 'width'=>120, - 'height'=>120, - 'opacity'=>100 + 'url' => $urlCode, //二维码资源 + 'stream' => 0, + 'left' => 114, + 'top' => 790, + 'right' => 0, + 'bottom' => 0, + 'width' => 120, + 'height' => 120, + 'opacity' => 100 ) ), - 'text'=>array( + 'text' => array( array( - 'text'=>$user['nickname'], - 'left'=>250, - 'top'=>840, - 'fontPath'=>$rootPath.'public'. DS .$filelink['Bold'], //字体文件 - 'fontSize'=>16, //字号 - 'fontColor'=>'40,40,40', //字体颜色 - 'angle'=>0, + 'text' => $user['nickname'], + 'left' => 250, + 'top' => 840, + 'fontPath' => $rootPath . 'public' . DS . $filelink['Bold'], //字体文件 + 'fontSize' => 16, //字号 + 'fontColor' => '40,40,40', //字体颜色 + 'angle' => 0, ), array( - 'text'=>'邀请您加入'.sysConfig('site_name'), - 'left'=>250, - 'top'=>880, - 'fontPath'=>$rootPath.'public'. DS .$filelink['Normal'], //字体文件 - 'fontSize'=>16, //字号 - 'fontColor'=>'40,40,40', //字体颜色 - 'angle'=>0, + 'text' => '邀请您加入' . sysConfig('site_name'), + 'left' => 250, + 'top' => 880, + 'fontPath' => $rootPath . 'public' . DS . $filelink['Normal'], //字体文件 + 'fontSize' => 16, //字号 + 'fontColor' => '40,40,40', //字体颜色 + 'angle' => 0, ) ), - 'background'=>$item['pic'] + 'background' => $item['pic'] ); - $resWap = $resWap && $posterInfo = UtilService::setSharePoster($config,'wap/spread/poster'); - 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); - if($resWap){ - if($posterInfo['image_type'] == 1) - $item['wap_poster'] = $siteUrl.$posterInfo['dir']; + $resWap = $resWap && $posterInfo = UtilService::setSharePoster($config, 'wap/spread/poster'); + 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); + if ($resWap) { + if ($posterInfo['image_type'] == 1) + $item['wap_poster'] = $siteUrl . $posterInfo['dir']; else $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('生成图片失败'); - }catch (\Exception $e){ - return app('json')->fail('生成图片时,系统错误',['line'=>$e->getLine(),'message'=>$e->getMessage()]); + } catch (\Exception $e) { + return app('json')->fail('生成图片时,系统错误', ['line' => $e->getLine(), 'message' => $e->getMessage()]); } } @@ -321,9 +322,9 @@ class UserBillController public function integral_list(Request $request) { list($page, $limit) = UtilService::getMore([ - ['page',0],['limit',0] + ['page', 0], ['limit', 0] ], $request, true); - return app('json')->successful(UserBill::userBillList($request->uid(),$page,$limit)); + return app('json')->successful(UserBill::userBillList($request->uid(), $page, $limit)); } } \ No newline at end of file diff --git a/crmeb/app/api/controller/wechat/WechatController.php b/crmeb/app/api/controller/wechat/WechatController.php index 566f3410..09b96747 100644 --- a/crmeb/app/api/controller/wechat/WechatController.php +++ b/crmeb/app/api/controller/wechat/WechatController.php @@ -8,6 +8,7 @@ use app\models\user\User; use app\models\user\UserToken; use app\models\user\WechatUser; use app\Request; +use crmeb\utils\Canvas; use crmeb\services\WechatService; use think\facade\Cookie; @@ -56,7 +57,7 @@ class WechatController public function auth(Request $request) { $spreadId = intval($request->param('spread')); - $login_type = $request->param('login_type',''); + $login_type = $request->param('login_type', ''); try { $wechatInfo = WechatService::oauthService()->user()->getOriginal(); } catch (\Exception $e) { @@ -79,7 +80,7 @@ class WechatController $user = User::where('uid', WechatUser::openidToUid($openid, 'openid'))->find(); if (!$user) 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'); else $token = UserToken::createToken($user, 'wechat'); @@ -91,4 +92,27 @@ class WechatController } else 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 : '']); + } + } \ No newline at end of file diff --git a/crmeb/app/models/store/StoreOrder.php b/crmeb/app/models/store/StoreOrder.php index 03819a62..345e4f0a 100644 --- a/crmeb/app/models/store/StoreOrder.php +++ b/crmeb/app/models/store/StoreOrder.php @@ -335,7 +335,7 @@ class StoreOrder extends BaseModel } $orderInfo = [ 'uid' => $uid, - 'order_id' => $test ? 0 : self::getNewOrderId($uid), + 'order_id' => $test ? 0 : self::getNewOrderId(), 'real_name' => $addressInfo['real_name'], 'user_phone' => $addressInfo['phone'], 'user_address' => $addressInfo['province'] . ' ' . $addressInfo['city'] . ' ' . $addressInfo['district'] . ' ' . $addressInfo['detail'], @@ -490,10 +490,10 @@ class StoreOrder extends BaseModel * @param $uid 用户uid * @return string */ - public static function getNewOrderId($uid) + public static function getNewOrderId() { 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); if(self::be(['order_id'=>$orderId])) $orderId = 'wx' . $msectime . mt_rand(10000,99999); return $orderId; diff --git a/crmeb/app/models/user/WechatUser.php b/crmeb/app/models/user/WechatUser.php index 04ef68cd..4ec57bed 100644 --- a/crmeb/app/models/user/WechatUser.php +++ b/crmeb/app/models/user/WechatUser.php @@ -40,9 +40,10 @@ class WechatUser extends BaseModel * @param string $uid * @return bool|mixed */ - public static function getOpenId($uid = ''){ - if($uid == '') return false; - return self::where('uid',$uid)->value('routine_openid'); + public static function getOpenId($uid = '') + { + 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') { - $openid = self::where('uid',$uid)->value($openidType); + $openid = self::where('uid', $uid)->value($openidType); return $openid; } @@ -67,7 +68,7 @@ class WechatUser extends BaseModel */ 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 * @return mixed */ - public static function routineOauth($routine){ - $routineInfo['nickname'] = filterEmoji($routine['nickName']);//姓名 - $routineInfo['sex'] = $routine['gender'];//性别 - $routineInfo['language'] = $routine['language'];//语言 - $routineInfo['city'] = $routine['city'];//城市 - $routineInfo['province'] = $routine['province'];//省份 - $routineInfo['country'] = $routine['country'];//国家 - $routineInfo['headimgurl'] = $routine['avatarUrl'];//头像 + public static function routineOauth($routine) + { + $routineInfo['nickname'] = filterEmoji($routine['nickName']);//姓名 + $routineInfo['sex'] = $routine['gender'];//性别 + $routineInfo['language'] = $routine['language'];//语言 + $routineInfo['city'] = $routine['city'];//城市 + $routineInfo['province'] = $routine['province'];//省份 + $routineInfo['country'] = $routine['country'];//国家 + $routineInfo['headimgurl'] = $routine['avatarUrl'];//头像 $routineInfo['routine_openid'] = $routine['openId'];//openid $routineInfo['session_key'] = $routine['session_key'];//会话密匙 - $routineInfo['unionid'] = $routine['unionId'];//用户在开放平台的唯一标识符 - $routineInfo['user_type'] = 'routine';//用户类型 + $routineInfo['unionid'] = $routine['unionId'];//用户在开放平台的唯一标识符 + $routineInfo['user_type'] = 'routine';//用户类型 $spid = 0;//绑定关系uid $isCOde = false; //获取是否有扫码进小程序 - if($routine['code']){ - if($info = RoutineQrcode::getRoutineQrcodeFindType($routine['code'])){ + if ($routine['code']) { + if ($info = RoutineQrcode::getRoutineQrcodeFindType($routine['code'])) { $spid = $info['third_id']; - $isCOde=true; - }else + $isCOde = true; + } else $spid = $routine['spid']; - }else if($routine['spid']) + } else if ($routine['spid']) $spid = $routine['spid']; // 判断unionid 存在根据unionid判断 - if($routineInfo['unionid'] != '' && ($uid=self::where(['unionid'=>$routineInfo['unionid']])->where('user_type','<>','h5')->value('uid'))){ - self::edit($routineInfo,$uid,'uid'); - $routineInfo['code'] = $spid; - $routineInfo['isPromoter'] = $isCOde; - if($routine['login_type']) $routineInfo['login_type'] = $routine['login_type']; - User::updateWechatUser($routineInfo,$uid); - }else if($uid = self::where(['routine_openid'=>$routineInfo['routine_openid']])->where('user_type','<>','h5')->value('uid')){ //根据小程序openid判断 - self::edit($routineInfo,$uid,'uid'); - $routineInfo['code'] = $spid; - $routineInfo['isPromoter'] = $isCOde; - if($routine['login_type']) $routineInfo['login_type'] = $routine['login_type']; - User::updateWechatUser($routineInfo,$uid); - }else{ + if ($routineInfo['unionid'] != '' && ($uid = self::where(['unionid' => $routineInfo['unionid']])->where('user_type', '<>', 'h5')->value('uid'))) { + self::edit($routineInfo, $uid, 'uid'); + $routineInfo['code'] = $spid; + $routineInfo['isPromoter'] = $isCOde; + if ($routine['login_type']) $routineInfo['login_type'] = $routine['login_type']; + User::updateWechatUser($routineInfo, $uid); + } else if ($uid = self::where(['routine_openid' => $routineInfo['routine_openid']])->where('user_type', '<>', 'h5')->value('uid')) { //根据小程序openid判断 + self::edit($routineInfo, $uid, 'uid'); + $routineInfo['code'] = $spid; + $routineInfo['isPromoter'] = $isCOde; + if ($routine['login_type']) $routineInfo['login_type'] = $routine['login_type']; + User::updateWechatUser($routineInfo, $uid); + } else { $routineInfo['add_time'] = time();//用户添加时间 $routineInfo = self::create($routineInfo); - $res = User::setRoutineUser($routineInfo,$spid); + $res = User::setRoutineUser($routineInfo, $spid); $uid = $res->uid; } return $uid; } + /** * 判断是否是小程序用户 * @param int $uid * @return bool|int|string */ - public static function isRoutineUser($uid = 0){ - if(!$uid) return false; - return self::where('uid',$uid)->where('user_type','routine')->count(); + public static function isRoutineUser($uid = 0) + { + if (!$uid) return false; + return self::where('uid', $uid)->where('user_type', 'routine')->count(); } /** * @param int $uid * @return int */ - public static function isUserStatus($uid = 0){ - if(!$uid) return 0; + public static function isUserStatus($uid = 0) + { + if (!$uid) return 0; $user = User::getUserInfo($uid); return $user['status']; } @@ -148,23 +153,23 @@ class WechatUser extends BaseModel public static function setNewUser($openid) { $userInfo = WechatService::getUserInfo($openid); - if(!isset($userInfo['subscribe']) || !$userInfo['subscribe'] || !isset($userInfo['openid'])) + if (!isset($userInfo['subscribe']) || !$userInfo['subscribe'] || !isset($userInfo['openid'])) exception('请关注公众号!'); - $userInfo['tagid_list'] = implode(',',$userInfo['tagid_list']); + $userInfo['tagid_list'] = implode(',', $userInfo['tagid_list']); //判断 unionid 是否存在 - if(isset($userInfo['unionid'])){ - $wechatInfo = self::where('unionid',$userInfo['unionid'])->find(); - if($wechatInfo){ - return self::edit($userInfo,$userInfo['unionid'],'unionid'); + if (isset($userInfo['unionid'])) { + $wechatInfo = self::where('unionid', $userInfo['unionid'])->find(); + if ($wechatInfo) { + return self::edit($userInfo, $userInfo['unionid'], 'unionid'); } } self::beginTrans(); $wechatUser = self::create(is_object($userInfo) ? $userInfo->toArray() : $userInfo); - if(!$wechatUser){ + if (!$wechatUser) { self::rollbackTrans(); exception('用户储存失败!'); } - if(!User::setWechatUser($wechatUser)){ + if (!User::setWechatUser($wechatUser)) { self::rollbackTrans(); exception('用户信息储存失败!'); } @@ -180,7 +185,7 @@ class WechatUser extends BaseModel public static function userFirstSubGiveCoupon($openid) { $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) { $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) { $userInfo = WechatService::getUserInfo($openid); - $userInfo['tagid_list'] = implode(',',$userInfo['tagid_list']); - return self::edit($userInfo->toArray(),$openid,'openid'); + $userInfo['tagid_list'] = implode(',', $userInfo['tagid_list']); + return self::edit($userInfo->toArray(), $openid, 'openid'); } /** @@ -211,7 +216,7 @@ class WechatUser extends BaseModel */ 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) { - 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) { - 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) { - if(is_numeric($openid)) $openid = self::uidToOpenid($openid); - $wechatInfo = self::where($openidType,$openid)->find(); - if(!$wechatInfo) { + if (is_numeric($openid)) $openid = self::uidToOpenid($openid); + $wechatInfo = self::where($openidType, $openid)->find(); + if (!$wechatInfo) { self::setNewUser($openid); - $wechatInfo = self::where($openidType,$openid)->find(); + $wechatInfo = self::where($openidType, $openid)->find(); } - if(!$wechatInfo) exception('获取用户信息失败!'); + if (!$wechatInfo) exception('获取用户信息失败!'); return $wechatInfo->toArray(); } } \ No newline at end of file