配置修改
This commit is contained in:
@ -43,6 +43,10 @@ class Statistics extends AdminBase
|
|||||||
return view();
|
return view();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test(){
|
||||||
|
$result = StatisticsLogic::makeMpWechatQrcode();
|
||||||
|
var_dump($result);
|
||||||
|
}
|
||||||
//交易分析
|
//交易分析
|
||||||
public function trading()
|
public function trading()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -24,6 +24,9 @@ namespace app\admin\logic;
|
|||||||
use app\common\basics\Logic;
|
use app\common\basics\Logic;
|
||||||
use app\common\server\UrlServer;
|
use app\common\server\UrlServer;
|
||||||
use app\common\enum\PayEnum;
|
use app\common\enum\PayEnum;
|
||||||
|
use app\common\server\WeChatServer;
|
||||||
|
use EasyWeChat\Factory;
|
||||||
|
use EasyWeChat\Kernel\Http\StreamResponse;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
|
||||||
class StatisticsLogic extends Logic
|
class StatisticsLogic extends Logic
|
||||||
@ -306,4 +309,62 @@ class StatisticsLogic extends Logic
|
|||||||
|
|
||||||
return ['count' => $goods_count, 'lists' => $goods_list];
|
return ['count' => $goods_count, 'lists' => $goods_list];
|
||||||
}
|
}
|
||||||
|
public static function makeMpWechatQrcode( string $type = 'base64', array $extra = [])
|
||||||
|
{
|
||||||
|
|
||||||
|
try {
|
||||||
|
$width = 430;
|
||||||
|
// 'env_version' => 'trial',
|
||||||
|
$envVersion = 'develop';
|
||||||
|
// $envVersion = 'release';
|
||||||
|
$page = "bundle/pages/user_spread/user_spread";
|
||||||
|
$save_dir = public_path() . 'uploads/wxqrcode/';
|
||||||
|
// 确保目录存在
|
||||||
|
if (!is_dir($save_dir)) {
|
||||||
|
mkdir($save_dir, 0755, true);
|
||||||
|
}
|
||||||
|
$file_name = time() . '.png';
|
||||||
|
$config = WeChatServer::getMnpConfig();
|
||||||
|
$app = Factory::miniProgram($config);
|
||||||
|
|
||||||
|
$response = $app->app_code->getUnlimit('type=1', [
|
||||||
|
// 'scene' => 'type=1',
|
||||||
|
'page' => $page,
|
||||||
|
'width' => $width,
|
||||||
|
'auto_color' => false,
|
||||||
|
'line_color' => ['r' => 0, 'g' => 0, 'b' => 0],
|
||||||
|
'is_hyaline' => false,
|
||||||
|
'env_version' => $envVersion,
|
||||||
|
'check_path' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if(is_array($response) && 41030 === $response['errcode']){
|
||||||
|
|
||||||
|
//开启错误提示,小程序未发布和页面不存在,返回提示
|
||||||
|
if (41030 === $response['errcode']) {
|
||||||
|
return '所传page页面不存在,或者小程序没有发布';
|
||||||
|
}
|
||||||
|
return $response['errmsg'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$contents = $response->getBody()->getContents();
|
||||||
|
switch ($type){
|
||||||
|
case 'file':
|
||||||
|
if ($response instanceof StreamResponse) {
|
||||||
|
$file_name = $response->saveAs($save_dir, $file_name);
|
||||||
|
$contents = $save_dir . $file_name;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'base64':
|
||||||
|
$mp_base64 = chunk_split(base64_encode($contents));
|
||||||
|
$contents = 'data:image/png;base64,' . $mp_base64;
|
||||||
|
}
|
||||||
|
return data_success('',['qr_code'=>$contents, 'extra' => $extra]);
|
||||||
|
|
||||||
|
|
||||||
|
} catch (\EasyWeChat\Kernel\Exceptions\Exception $e){
|
||||||
|
return data_error($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -112,7 +112,7 @@ class DistributionLogic extends Logic
|
|||||||
{
|
{
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$user_msg = User::where('id', $user_id)->find();
|
// $user_msg = User::where('id', $user_id)->find();
|
||||||
$time = time();
|
$time = time();
|
||||||
$data = [
|
$data = [
|
||||||
'user_id' => $user_id,
|
'user_id' => $user_id,
|
||||||
|
|||||||
Reference in New Issue
Block a user