修改用户代理管理

This commit is contained in:
邹景立 2021-05-19 17:45:06 +08:00
parent 9323443f29
commit b19c8059c3
22 changed files with 280 additions and 96 deletions

View File

@ -0,0 +1,79 @@
<?php
namespace app\data\command;
use app\data\service\UserUpgradeService;
use think\admin\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\Output;
/**
* 更新用户代理关系
* Class UserAgent
* @package app\data\command
*/
class UserAgent extends Command
{
protected function configure()
{
$this->setName('xdata:UserAgent');
$this->addArgument('uid', Argument::OPTIONAL, '目标用户', '');
$this->addArgument('pid', Argument::OPTIONAL, '上级代理', '');
$this->setDescription('重新设置用户上级代理, 参数UID PID');
}
/**
* @param Input $input
* @param Output $output
* @return void
* @throws \think\admin\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
protected function execute(Input $input, Output $output)
{
[$uid, $pid] = [$input->getArgument('uid'), $input->getArgument('pid')];
if (empty($uid)) $this->setQueueError("参数UID无效请传入正确的参数!");
if (empty($pid)) $this->setQueueError("参数PID无效请传入正确的参数!");
// 检查当前用户资料
$user = $this->app->db->name('DataUser')->where(['id' => $uid])->find();
if (empty($user)) $this->setQueueError("读取用户数据失败!");
// 检查上级代理用户
$parant = $this->app->db->name('DataUser')->where(['id' => $pid])->find();
if (empty($parant)) $this->setQueueError('读取代理数据失败!');
// 检查异常关系处理
if (stripos($parant['path'], "-{$user['id']}-")) {
$this->setQueueError('不能把下级设置为代理!');
}
// 更新自己的代理关系
$path1 = rtrim($parant['path'] ?: '-', '-') . "-{$parant['id']}-";
$this->app->db->name('DataUser')->where(['id' => $user['id']])->update([
'path' => $path1, 'layer' => substr_count($path1, '-'),
'pid0' => $parant['id'], 'pid1' => $parant['id'], 'pid2' => $parant['pid1'],
]);
UserUpgradeService::instance()->upgrade($user['id'], true);
$this->setQueueMessage(1, 1, "更新指定用户[{$user['id']}]代理绑定成功!");
// 更新下级的代理关系
$path2 = "{$user['path']}{$user['id']}-";
[$total, $count] = [$this->app->db->name('DataUser')->whereLike('path', "{$path2}%")->count(), 0];
foreach ($this->app->db->name('DataUser')->whereLike('path', "{$path2}%")->order('layer desc')->select() as $vo) {
$this->setQueueMessage($total, ++$count, "开始更新下级用户[{$vo['id']}]代理绑定!");
// 更新下级用户代理数据
$path3 = preg_replace("#^{$path2}#", "{$path1}{$user['id']}-", $vo['path']);
$attrs = array_reverse(str2arr($path3, '-'));
$this->app->db->name('DataUser')->where(['id' => $vo['id']])->update([
'path' => $path3, 'layer' => substr_count($path3, '-'),
'pid0' => $attrs[0] ?? 0, 'pid1' => $attrs[0] ?? 0, 'pid2' => $attrs[1] ?? 0,
]);
$this->setQueueMessage($total, $count, "完成更新下级用户[{$vo['id']}]代理绑定!", 1);
}
}
}

View File

@ -61,7 +61,7 @@ class Admin extends Controller
* 数据列表处理
* @param array $data
*/
protected function _index_page_filter(array &$data)
protected function _page_filter(array &$data)
{
$this->upgrades = UserUpgradeService::instance()->levels();
UserAdminService::instance()->buildByUid($data, 'pid1', 'from');
@ -94,7 +94,24 @@ class Admin extends Controller
}
/**
* 修改用户推荐人
* 永久绑定代理
* @auth true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function forever()
{
$map = $this->_vali(['id.require' => '用户ID不能为空']);
$user = $this->app->db->name($this->table)->where($map)->find();
if (empty($user) || empty($user['pid0'])) $this->error('用户不符合操作要求!');
[$status, $message] = UserUpgradeService::instance()->bindAgent($user['id'], $user['pid0'], true);
$status && sysoplog('前端用户管理', "后台修改用户[{$map['uid']}]的代理为永久状态");
empty($status) ? $this->error($message) : $this->success($message);
}
/**
* 绑定上级代理
* @auth true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
@ -102,45 +119,23 @@ class Admin extends Controller
*/
public function parent()
{
$data = $this->_vali(['pid.default' => '', 'uid.require' => '待操作UID不能为空']);
if ($data['uid'] === $data['pid']) $this->error('代理不能是自己');
if (empty($data['pid'])) {
$map = [['id', '<>', $data['uid']], ['deleted', '=', 0]];
$query = $this->_query($this->table)->where($map)->equal('status,vip_code');
$query->like('phone,username|nickname#username')->dateBetween('create_at')->order('id desc')->page();
} else try {
$user = $this->app->db->name('DataUser')->where(['id' => $data['uid']])->find();
$parent = $this->app->db->name('DataUser')->where(['id' => $data['pid']])->find();
if (empty($user)) $this->error('读取用户数据失败!');
if (empty($parent)) $this->error('读取代理数据失败!');
$this->app->db->transaction(function () use ($data, $user, $parent) {
if (empty($parent['vip_code'])) $this->error('代理无推荐资格');
if (is_numeric(strpos($parent['path'], "-{$data['uid']}-"))) $this->error('代理不能绑下属');
// 组装当前用户上级数据
$path = rtrim($parent['path'] ?: '-', '-') . "-{$parent['id']}-";
// $this->app->db->name('DataUser')->where(['id' => $data['uid']])->update([
// 'pid0' => $parent['id'], 'pid1' => $parent['id'], 'pid2' => $parent['pid1'],
// 'path' => $path, 'layer' => substr_count($path, '-'),
// ]);
// 替换原来用户的下级用户
$newPath = rtrim($path, '-') . "-{$user['id']}-";
$oldPath = rtrim($user['path'], '-') . "-{$user['id']}-";
foreach ($this->app->db->name('DataUser')->whereLike('path', "{$oldPath}%")->cursor() as $vo) {
dump($vo);
}
// $this->app->db->name('DataUser')->whereLike('path', "{$oldPath}%")->update([
// 'path' => $this->app->db->raw("replace(path,'{$oldPath}','{$newPath}')"),
// ]);
// foreach (array_reverse(array_unique(array_merge(str2arr($newPath), str2arr($oldPath)))) as $uid) {
// UserUpgradeService::instance()->upgrade($uid);
// }
});
exit;
$this->success('修改代理成功!');
} catch (\think\exception\HttpResponseException $exception) {
throw $exception;
} catch (\Exception $exception) {
$this->error($exception->getMessage());
if ($this->request->isGet()) {
$this->upgrades = UserUpgradeService::instance()->levels();
$data = $this->_vali(['uid.require' => '待操作UID不能为空']);
// 排除下级用户
$path = $this->app->db->name($this->table)->where(['id' => $data['uid']])->value('path', '-');
$subids = $this->app->db->name($this->table)->whereLike('path', "{$path}{$data['uid']}-%")->column('id');
$query = $this->_query($this->table)->order('id desc')->whereNotIn('id', array_merge($subids, array_values($data)));
// 用户搜索查询
$db = $this->_query($this->table)->equal('vip_code#from_vipcode')->like('phone#from_phone,username|nickname#from_username')->db();
if ($db->getOptions('where')) $query->whereRaw("pid1 in {$db->field('id')->buildSql()}");
// 数据查询分页
$query->like('phone,username|nickname#username')->equal('status,vip_code')->dateBetween('create_at')->page();
} else {
$data = $this->_vali(['pid.require' => '待绑定代理不能为空!', 'uid.require' => '待操作用户不能为空!']);
[$status, $message] = UserUpgradeService::instance()->bindAgent($data['uid'], $data['pid'], false);
$status && sysoplog('前端用户管理', "后台修改用户[{$data['uid']}]的代理为[{$data['pid']}]");
empty($status) ? $this->error($message) : $this->success($message);
}
}

View File

@ -32,7 +32,7 @@ class GoodsService extends Service
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getCateTree($type = 'arr2tree'): array
public function getCateTree(string $type = 'arr2tree'): array
{
$map = ['deleted' => 0, 'status' => 1];
$query = $this->app->db->name('ShopGoodsCate')->where($map)->order('sort desc,id desc');
@ -44,7 +44,7 @@ class GoodsService extends Service
* @param boolean $simple 简化数据
* @return array
*/
public function getCateData($simple = true): array
public function getCateData(bool $simple = true): array
{
$map = ['status' => 1, 'deleted' => 0];
$cates = $this->app->db->name('ShopGoodsCate')->where($map)->column('id,pid,name', 'id');
@ -126,7 +126,7 @@ class GoodsService extends Service
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function bindData(array &$data = [], $simple = true): array
public function bindData(array &$data = [], bool $simple = true): array
{
[$cates, $codes] = [$this->getCateData(), array_unique(array_column($data, 'code'))];
$marks = $this->app->db->name('ShopGoodsMark')->where(['status' => 1])->column('name');

View File

@ -17,7 +17,7 @@ class NewsService extends Service
* @param array $total 查询统计
* @throws \think\db\exception\DbException
*/
public function syncNewsTotal(string $code, $total = []): void
public function syncNewsTotal(string $code, array $total = []): void
{
$query = $this->app->db->name('DataNewsXCollect')->field('type,count(1) count');
foreach ($query->where(['code' => $code, 'status' => 2])->group('type')->cursor() as $item) {

View File

@ -88,9 +88,7 @@ class OrderService extends Service
$lastMap = [['uid', '=', $uid], ['status', '>=', 4], ['payment_status', '=', 1]];
$lastDate = $query->where($lastMap)->order('payment_datetime desc')->value('payment_datetime');
// 更新用户支付信息
$this->app->db->name('DataUser')->where(['id' => $uid])->update([
'buy_vip_entry' => $entry, 'buy_last_date' => $lastDate,
]);
$this->app->db->name('DataUser')->where(['id' => $uid])->update(['buy_vip_entry' => $entry, 'buy_last_date' => $lastDate]);
return $entry;
}
@ -123,7 +121,7 @@ class OrderService extends Service
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function buildData(array &$data = [], $from = true): array
public function buildData(array &$data = [], bool $from = true): array
{
if (empty($data)) return $data;
// 关联发货信息
@ -139,9 +137,9 @@ class OrderService extends Service
if ($from) UserAdminService::instance()->buildByUid($data, 'puid1', 'from', $fields);
foreach ($data as &$vo) {
[$vo['sales'], $vo['truck'], $vo['items']] = [0, $trucks[$vo['order_no']] ?? [], []];
foreach ($items as $item) if ($vo['order_no'] === $item['order_no']) {
$vo['sales'] += $item['stock_sales'];
$vo['items'][] = $item;
foreach ($items as $it) if ($vo['order_no'] === $it['order_no']) {
$vo['sales'] += $it['stock_sales'];
$vo['items'][] = $it;
}
}
return $data;

View File

@ -36,28 +36,38 @@ class UserUpgradeService extends Service
{
$user = $this->app->db->name('DataUser')->where(['id' => $uid])->find();
if (empty($user)) return [0, '用户查询失败'];
if (!empty($user['pids'])) return [1, '已绑定代理'];
if ($user['pids']) return [1, '已绑定代理'];
// 检查代理用户
if (empty($pid)) $pid = $user['pid0'];
if (empty($pid)) return [0, '绑定代理不存在'];
if ($uid == $pid) return [0, '代理不能是自己'];
if (empty($pid)) return [0, '绑定代理不存在'];
if ($uid == $pid) return [0, '不能绑定自己为代理'];
// 检查代理资格
$parant = $this->app->db->name('DataUser')->where(['id' => $pid])->find();
if (empty($parant['vip_code'])) return [0, '代理无推荐资格'];
if (stripos($parant['path'], "-{$uid}-") !== false) return [0, '不能绑定下属'];
$agent = $this->app->db->name('DataUser')->where(['id' => $pid])->find();
if (empty($agent['vip_code'])) return [0, '代理无推荐资格'];
if (stripos($agent['path'], "-{$uid}-") !== false) return [0, '不能绑定下属'];
// 组装代理数据
$path = rtrim($parant['path'] ?: '-', '-') . "-{$parant['id']}-";
$data = [
'pid0' => $parant['id'], 'pid1' => $parant['id'], 'pid2' => $parant['pid1'],
'pids' => intval($force), 'path' => $path, 'layer' => substr_count($path, '-'),
];
// 更新用户代理
if ($this->app->db->name('DataUser')->where(['id' => $uid])->update($data) !== false) {
$this->upgrade($uid);
return [1, '绑定代理成功'];
} else {
return [0, '绑定代理失败'];
}
$result = [0, '绑定代理失败'];
$this->app->db->transaction(function () use ($user, $agent, $force, &$result) {
// 更新用户代理
$path1 = rtrim($agent['path'] ?: '-', '-') . "-{$agent['id']}-";
$data1 = ['pid0' => $agent['id'], 'pid1' => $agent['id'], 'pid2' => $agent['pid1']];
$data2 = ['pids' => intval($force), 'path' => $path1, 'layer' => substr_count($path1, '-')];
$this->app->db->name('DataUser')->where(['id' => $user['id']])->update(array_merge($data1, $data2));
// 更新下级代理
$path2 = "{$user['path']}{$user['id']}-";
if ($this->app->db->name('DataUser')->whereLike('path', "{$path2}%")->count() > 0) {
foreach ($this->app->db->name('DataUser')->whereLike('path', "{$path2}%")->order('layer desc')->select() as $vo) {
$attr = array_reverse(str2arr($path3 = preg_replace("#^{$path2}#", "{$path1}{$user['id']}-", $vo['path']), '-'));
$this->app->db->name('DataUser')->where(['id' => $vo['id']])->update([
'pid0' => $attr[0] ?? 0, 'pid1' => $attr[0] ?? 0, 'pid2' => $attr[1] ?? 0, 'path' => $path3, 'layer' => substr_count($path3, '-'),
]);
}
}
// 更新用户等级
$this->upgrade($user['id'], true);
$result = [1, '绑定代理成功'];
});
return $result;
}
/**

View File

@ -1,6 +1,7 @@
<?php
use app\data\command\OrderClean;
use app\data\command\UserAgent;
use app\data\command\UserAmount;
use app\data\command\UserTransfer;
use app\data\command\UserUpgrade;
@ -15,6 +16,7 @@ $app = app();
if ($app->request->isCli()) {
Console::starting(function (Console $console) {
$console->addCommand(OrderClean::class);
$console->addCommand(UserAgent::class);
$console->addCommand(UserAmount::class);
$console->addCommand(UserUpgrade::class);
$console->addCommand(UserTransfer::class);

View File

@ -101,7 +101,17 @@
<div>累计交易:<b class="color-blue font-s14">{$vo.order_amount_total+0}</b> </div>
<div>使用状态:{if $vo.status eq 0}<b class="color-red">已冻结</b>{elseif $vo.status eq 1}<b class="color-green">已激活</b>{/if}
<!--{notempty name='vo.pids'}--><b class="margin-left-5 color-green">永久绑定</b><!--{else}-->
{notempty name='vo.pid0'}<b class="margin-left-5 color-red">临时绑定</b>{else}<b class="margin-left-5 color-desc">没有绑定</b>{/notempty}
{notempty name='vo.pid0'}
<b class="margin-left-5 color-red">临时绑定</b>
<!--{if auth('forever')}-->
<a data-confirm="设置之后不能撤回操作,确认操作吗?" data-load="{:url('forever')}?id={$vo.id}" class="margin-left-5 notselect">改为永久</a>
<!--{/if}-->
{else}
<b class="margin-left-5 color-desc">没有绑定</b>
<!--{if auth('parent')}-->
<a data-width="1080px" data-iframe="{:url('parent')}?uid={$vo.id}" class="margin-left-5 notselect">设置绑定</a>
<!--{/if}-->
{/notempty}
<!--{/notempty}-->
</div>
<div>注册时间:{$vo.create_at|format_datetime}</div>

View File

@ -2,13 +2,12 @@
{block name="content"}
<div class="iframe-pagination">
{include file='user/index_search'}
{include file='user/admin/parent_search'}
<table class="layui-table margin-top-10" lay-skin="line">
{notempty name='list'}
<thead>
<tr>
<th class='nowrap'>用户信息</th>
<th class='nowrap'>代理信息</th>
<th class='nowrap'>注册时间</th>
<th class='nowrap'></th>
</tr>
@ -60,10 +59,10 @@
使用状态:{if $vo.status eq 0}<b class="color-red margin-right-5">已冻结</b>{elseif $vo.status eq 1}<b class="color-green margin-right-5">已激活</b>{/if}<br>
注册时间:{$vo.create_at|format_datetime}
</td>
<td class="nowrap">
<td class="nowrap text-right">
<!--{if auth("parent")}-->
<a class="layui-btn layui-btn-sm layui-btn-primary" data-modal="{:url('parent')}?uid={:input('uid')}&pid={$vo.id}">确认选择</a>
<a class="layui-btn layui-btn-sm layui-btn-primary" data-parent-uid="{:input('uid')}" data-parent-pid="{$vo.id}">确认选择</a>
<!--{/if}-->
</td>
@ -74,3 +73,17 @@
{empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
</div>
{/block}
{block name='script'}
<script>
$('body').off('click', '[data-parent-uid]').on('click', '[data-parent-uid]', function () {
$.queue()
$.form.load('{:sysuri()}', {uid: this.dataset.parentUid, pid: this.dataset.parentPid}, 'post', function (ret) {
if (ret.code > 0) return $.msg.success(ret.info, 3, function () {
top.layer.close(top.layer.getFrameIndex(window.name));
top.$.form.reload();
}), false;
});
});
</script>
{/block}

View File

@ -0,0 +1,75 @@
<fieldset>
<legend>条件搜索</legend>
<form action="{:request()->url()}" autocomplete="off" class="layui-form layui-form-pane form-search" method="get" onsubmit="return false">
<div class="layui-form-item layui-inline">
<label class="layui-form-label">用户手机</label>
<label class="layui-input-inline">
<input class="layui-input" name="phone" placeholder="请输入用户手机" value="{:input('phone')}">
</label>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">用户昵称</label>
<label class="layui-input-inline">
<input class="layui-input" name="username" placeholder="请输入用户昵称" value="{:input('username')}">
</label>
</div>
<!--{notempty name='upgrades'}-->
<div class="layui-form-item layui-inline">
<label class="layui-form-label">用户等级</label>
<div class="layui-input-inline">
<select class="layui-select" name="vip_code">
<option value="">-- 全部 --</option>
{foreach $upgrades as $upgrade}{if input('vip_code') eq $upgrade.number.''}
<option selected value="{$upgrade.number|default=0}">[ VIP{$upgrade.number|default='0'} ] {$upgrade.name|default=''}</option>
{else}
<option value="{$upgrade.number|default=0}">[ VIP{$upgrade.number|default='0'} ] {$upgrade.name|default=''}</option>
{/if}{/foreach}
</select>
</div>
</div>
<!--{/notempty}-->
<div class="layui-form-item layui-inline">
<label class="layui-form-label">代理手机</label>
<label class="layui-input-inline">
<input class="layui-input" name="from_phone" placeholder="请输入代理手机" value="{:input('from_phone')}">
</label>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">代理昵称</label>
<label class="layui-input-inline">
<input class="layui-input" name="from_username" placeholder="请输入代理昵称" value="{:input('from_username')}">
</label>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">使用状态</label>
<div class="layui-input-inline">
<select class="layui-select" name="status">
<option value="">-- 全部 --</option>
{foreach ['已冻结的用户', '已激活的用户'] as $k=>$v}
{if $k.'' eq input('status')}
<option selected value="{$k}">{$v}</option>
{else}
<option value="{$k}">{$v}</option>
{/if}{/foreach}
</select>
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">注册时间</label>
<div class="layui-input-inline">
<input class="layui-input" data-date-range name="create_at" placeholder="请选择注册时间" value="{:input('create_at','')}">
</div>
</div>
<div class="layui-form-item layui-inline">
<button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
</div>
</form>
</fieldset>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -708,7 +708,7 @@ label.think-radio, label.think-checkbox {
/*! 重置 Iframe 页面样式 */
.iframe-pagination {
padding: 20px 20px 45px 20px;
padding: 20px 20px 0 20px;
.pagination-container {
left: 0;

View File

@ -201,6 +201,7 @@ return array(
'app\\admin\\controller\\api\\Update' => $baseDir . '/app/admin/controller/api/Update.php',
'app\\admin\\controller\\api\\Upload' => $baseDir . '/app/admin/controller/api/Upload.php',
'app\\data\\command\\OrderClean' => $baseDir . '/app/data/command/OrderClean.php',
'app\\data\\command\\UserAgent' => $baseDir . '/app/data/command/UserAgent.php',
'app\\data\\command\\UserAmount' => $baseDir . '/app/data/command/UserAmount.php',
'app\\data\\command\\UserTransfer' => $baseDir . '/app/data/command/UserTransfer.php',
'app\\data\\command\\UserUpgrade' => $baseDir . '/app/data/command/UserUpgrade.php',

View File

@ -330,6 +330,7 @@ class ComposerStaticInit0ec6378467f464339c264d61cf644c03
'app\\admin\\controller\\api\\Update' => __DIR__ . '/../..' . '/app/admin/controller/api/Update.php',
'app\\admin\\controller\\api\\Upload' => __DIR__ . '/../..' . '/app/admin/controller/api/Upload.php',
'app\\data\\command\\OrderClean' => __DIR__ . '/../..' . '/app/data/command/OrderClean.php',
'app\\data\\command\\UserAgent' => __DIR__ . '/../..' . '/app/data/command/UserAgent.php',
'app\\data\\command\\UserAmount' => __DIR__ . '/../..' . '/app/data/command/UserAmount.php',
'app\\data\\command\\UserTransfer' => __DIR__ . '/../..' . '/app/data/command/UserTransfer.php',
'app\\data\\command\\UserUpgrade' => __DIR__ . '/../..' . '/app/data/command/UserUpgrade.php',

View File

@ -889,17 +889,17 @@
},
{
"name": "zoujingli/wechat-developer",
"version": "v1.2.30",
"version_normalized": "1.2.30.0",
"version": "v1.2.31",
"version_normalized": "1.2.31.0",
"source": {
"type": "git",
"url": "https://github.com/zoujingli/WeChatDeveloper.git",
"reference": "4ba213dceae358c028dd23a0572e0c85cb6be2aa"
"reference": "0cf699c725f69d66657a50e60d22f71c9e5a5e16"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zoujingli/WeChatDeveloper/zipball/4ba213dceae358c028dd23a0572e0c85cb6be2aa",
"reference": "4ba213dceae358c028dd23a0572e0c85cb6be2aa",
"url": "https://api.github.com/repos/zoujingli/WeChatDeveloper/zipball/0cf699c725f69d66657a50e60d22f71c9e5a5e16",
"reference": "0cf699c725f69d66657a50e60d22f71c9e5a5e16",
"shasum": "",
"mirrors": [
{
@ -919,7 +919,7 @@
"ext-xml": "*",
"php": ">=5.4"
},
"time": "2021-04-15T03:16:50+00:00",
"time": "2021-05-19T06:25:20+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -946,7 +946,7 @@
}
],
"description": "WeChat platform and WeChat payment development tools",
"homepage": "https://github.com/zoujingli/WeChatDeveloper",
"homepage": "https://github.com/kentwangit/WeChatDeveloper",
"keywords": [
"WeChatDeveloper",
"WeMini",

2
vendor/services.php vendored
View File

@ -1,5 +1,5 @@
<?php
// This file is automatically generated at:2021-05-19 13:57:33
// This file is automatically generated at:2021-05-19 17:44:07
declare (strict_types = 1);
return array (
0 => 'think\\admin\\Library',

View File

@ -88,7 +88,7 @@ class We
* 定义当前版本
* @var string
*/
const VERSION = '1.2.30';
const VERSION = '1.2.31';
/**
* 静态配置

View File

@ -60,7 +60,7 @@ class Script extends BasicWeChat
throw new InvalidResponseException('Invalid Resoponse Ticket.', '0');
}
$ticket = $result['ticket'];
Tools::setCache($cache_name, $ticket, 5000);
Tools::setCache($cache_name, $ticket, 7000);
}
return $ticket;
}

View File

@ -60,10 +60,10 @@ class Order extends BasicWePay
$prepayId = $result['prepay_id'];
$nonceStr = Tools::createNoncestr();
if ($type === 'app') {
$sign = $this->signBuild(join("\n", [$appid, $time, $nonceStr, $prepayId]));
$sign = $this->signBuild(join("\n", [$appid, $time, $nonceStr, $prepayId, '']));
return ['partnerId' => $this->config['mch_id'], 'prepayId' => $prepayId, 'package' => 'Sign=WXPay', 'nonceStr' => $nonceStr, 'timeStamp' => $time, 'sign' => $sign];
} elseif ($type === 'jsapi') {
$sign = $this->signBuild(join("\n", [$appid, $time, $nonceStr, "prepay_id={$prepayId}"]));
$sign = $this->signBuild(join("\n", [$appid, $time, $nonceStr, "prepay_id={$prepayId}", '']));
return ['appId' => $appid, 'timeStamp' => $time, 'nonceStr' => $nonceStr, 'package' => "prepay_id={$prepayId}", 'signType' => 'RSA', 'paySign' => $sign];
} else {
return $result;
@ -103,4 +103,4 @@ class Order extends BasicWePay
return $data;
}
}
}

View File

@ -14,10 +14,10 @@ try {
'appid' => 'wx60a43dd8161666d4',
'mchid' => $config['mch_id'],
'description' => '商品描述',
'out_trade_no' => date("YmdHis"),
'out_trade_no' => (string)time(),
'notify_url' => 'https://thinkadmin.top',
'payer' => ['openid' => 'o38gps3vNdCqaggFfrBRCRikwlWY'],
'amount' => ['total' => 1, 'currency' => 'CNY'],
'amount' => ['total' => 2, 'currency' => 'CNY'],
]);
echo '<pre>';

View File

@ -1,7 +1,7 @@
{
"type": "library",
"name": "zoujingli/wechat-developer",
"homepage": "https://github.com/zoujingli/WeChatDeveloper",
"name": "zoujingli/wechat-developer-kentwangit",
"homepage": "https://github.com/kentwangit/WeChatDeveloper",
"description": "WeChat platform and WeChat payment development tools",
"license": "MIT",
"authors": [
@ -42,4 +42,4 @@
"WePayV3\\": "WePayV3"
}
}
}
}