feat: 优化腾讯地图地址选点插件,完善订单管理与分销服务
这个提交包含在:
@@ -80,40 +80,70 @@ class Order extends Backend
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单补单
|
||||
* 订单补单(含权益发放与分销结算)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function supplement()
|
||||
{
|
||||
$orderNo = $this->request->post('orderNo');
|
||||
if (trim((string)$orderNo) === '') {
|
||||
$orderNo = trim((string)$this->request->post('orderNo', ''));
|
||||
if ($orderNo === '') {
|
||||
$this->error('订单号不能为空');
|
||||
}
|
||||
$order = Db::name('fc_order')->where('order_no', $orderNo)->find();
|
||||
if (!$order) {
|
||||
$this->error('订单不存在');
|
||||
}
|
||||
if ($order['status'] === 'paid') {
|
||||
if ((string)$order['status'] === 'paid') {
|
||||
$this->success('订单已支付');
|
||||
}
|
||||
Db::name('fc_order')->where('id', $order['id'])->update([
|
||||
'status' => 'paid',
|
||||
'paytime' => time(),
|
||||
'updatetime' => time(),
|
||||
]);
|
||||
Db::name('fc_finance_flow')->insert([
|
||||
'user_id' => (int)$order['user_id'],
|
||||
'flow_no' => 'SK' . date('YmdHis') . $order['id'],
|
||||
'type' => 'income',
|
||||
'scene' => '订单补单',
|
||||
'amount' => $order['amount'],
|
||||
'balance' => 0,
|
||||
'related_id' => $order['id'],
|
||||
'remark' => '订单补单',
|
||||
'createtime' => time(),
|
||||
]);
|
||||
if ((string)$order['status'] !== 'pending') {
|
||||
$this->error('订单状态不支持补单(当前:' . $order['status'] . ')');
|
||||
}
|
||||
|
||||
$now = time();
|
||||
try {
|
||||
Db::transaction(function () use ($order, $now) {
|
||||
$locked = Db::name('fc_order')->where('id', (int)$order['id'])->lock(true)->find();
|
||||
if (!$locked || (string)$locked['status'] !== 'pending') {
|
||||
return;
|
||||
}
|
||||
|
||||
$affected = Db::name('fc_order')
|
||||
->where('id', (int)$order['id'])
|
||||
->where('status', 'pending')
|
||||
->update([
|
||||
'status' => 'paid',
|
||||
'paytime' => $now,
|
||||
'updatetime' => $now,
|
||||
]);
|
||||
if (!$affected) {
|
||||
return;
|
||||
}
|
||||
|
||||
$locked['status'] = 'paid';
|
||||
$locked['paytime'] = $now;
|
||||
|
||||
Db::name('fc_finance_flow')->insert([
|
||||
'user_id' => (int)$locked['user_id'],
|
||||
'flow_no' => 'SK' . date('YmdHis') . $locked['id'],
|
||||
'type' => 'income',
|
||||
'scene' => '订单补单',
|
||||
'amount' => $locked['amount'],
|
||||
'balance' => 0,
|
||||
'related_id' => $locked['id'],
|
||||
'remark' => '订单补单',
|
||||
'createtime' => $now,
|
||||
]);
|
||||
|
||||
// 统一发放订单权益(会员开通 / 余额充值入账 / 付费查看解锁 / 发帖激活)并触发分销佣金结算
|
||||
\app\common\library\OrderFulfill::handle($locked);
|
||||
});
|
||||
} catch (\Throwable $e) {
|
||||
\think\Log::record('后台订单补单失败:订单 ' . $orderNo . ',' . $e->getMessage(), 'error');
|
||||
$this->error('补单失败:' . $e->getMessage());
|
||||
}
|
||||
|
||||
$this->success('补单成功');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@
|
||||
|
||||
<input type="hidden" id="area-options" value="{$areaOptionsJson|htmlentities}">
|
||||
|
||||
<div class="fc-area-actions">
|
||||
<button type="submit" class="btn btn-primary btn-embossed disabled">保存</button>
|
||||
<div class="fc-area-actions normal-footer">
|
||||
<button type="submit" class="btn btn-success btn-embossed fc-area-submit-btn"><i class="fa fa-check"></i> 保存</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -110,7 +110,7 @@
|
||||
|
||||
<input type="hidden" id="area-options" data-current-id="{$row.id|htmlentities}" value="{$areaOptionsJson|htmlentities}">
|
||||
|
||||
<div class="fc-area-actions">
|
||||
<button type="submit" class="btn btn-primary btn-embossed disabled">保存</button>
|
||||
<div class="fc-area-actions normal-footer">
|
||||
<button type="submit" class="btn btn-success btn-embossed fc-area-submit-btn"><i class="fa fa-check"></i> 保存</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -221,7 +221,7 @@ class Distribution extends V1
|
||||
/**
|
||||
* D4 分销海报生成要素
|
||||
* GET /api/v1/distribution/poster
|
||||
* 获取用于前端合成或分享专属推广海报的元数据
|
||||
* 获取用于前端合成或分享专属推广海报的元数据(含官方小程序码 URL,支持传入 postId 生成详情页小程序码)
|
||||
*
|
||||
* @return void 输出海报配置与素材信息的JSON
|
||||
*/
|
||||
@@ -234,6 +234,16 @@ class Distribution extends V1
|
||||
$siteName = (string)$this->cfg('app.name', '同城分类信息');
|
||||
$slogan = (string)$this->cfg('dist.slogan', '同城便民生活 · 随时随地发布与求助');
|
||||
$code = (string)$ext['invite_code'];
|
||||
$postId = (int)$this->input('postId', 0);
|
||||
|
||||
if ($postId > 0) {
|
||||
$scene = 'id_' . $postId . '_u_' . $uid;
|
||||
$page = 'pages/detail/detail';
|
||||
} else {
|
||||
$scene = 'ic_' . $code;
|
||||
$page = 'pages/index/index';
|
||||
}
|
||||
$wxacodeUrl = \app\common\library\WxMini::wxacodeUnlimit($scene, $page, 280);
|
||||
|
||||
$this->ok([
|
||||
'inviteCode' => $code,
|
||||
@@ -241,7 +251,8 @@ class Distribution extends V1
|
||||
'slogan' => $slogan,
|
||||
'nickname' => (string)(isset($user['nickname']) && $user['nickname'] !== '' ? $user['nickname'] : '同城合伙人'),
|
||||
'avatar' => (string)(isset($user['avatar']) ? $user['avatar'] : ''),
|
||||
'path' => 'pages/index/index?ic=' . $code,
|
||||
'path' => $postId > 0 ? ('pages/detail/detail?id=' . $postId . '&ic=' . $code) : ('pages/index/index?ic=' . $code),
|
||||
'wxacodeUrl' => $wxacodeUrl,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -578,6 +578,7 @@ class V1 extends Api
|
||||
'memberLevel' => $isMember ? (string)$ext['member_level'] : '',
|
||||
'memberExpireAt' => $ext['member_expiretime'] ? $this->iso($ext['member_expiretime']) : null,
|
||||
'balance' => (float)$user['money'],
|
||||
'inviteCode' => isset($ext['invite_code']) ? (string)$ext['invite_code'] : '',
|
||||
'realnameStatus' => (int)$ext['realname_status'],
|
||||
'realname' => isset($ext['realname']) ? (string)$ext['realname'] : '',
|
||||
'isMerchant' => (bool)$isMerchant,
|
||||
|
||||
@@ -185,9 +185,12 @@ class DistributionService
|
||||
'createtime' => $now,
|
||||
]);
|
||||
|
||||
// 发送分销佣金入账站内信通知
|
||||
// 发送分销佣金入账站内信通知(区分待结算周期与实时结算)
|
||||
$levelText = ($level === 1) ? '直接下线' : '间接下线';
|
||||
$noticeContent = '您的 ' . $levelText . ' 产生了一笔消费(¥' . $amount . '),为您带来分销佣金 ¥' . $commissionAmount . ',已计入可提现资产。';
|
||||
$settleTip = ($settleDays > 0)
|
||||
? '已计入待结算佣金(预计 T+' . $settleDays . ' 自动结算转入可提现资产)。'
|
||||
: '已计入可提现资产。';
|
||||
$noticeContent = '您的 ' . $levelText . ' 产生了一笔消费(¥' . $amount . '),为您带来分销佣金 ¥' . $commissionAmount . ',' . $settleTip;
|
||||
Db::name('fc_message')->insert([
|
||||
'user_id' => $parentId,
|
||||
'type' => 'interact',
|
||||
|
||||
@@ -207,6 +207,60 @@ class WxMini
|
||||
return isset($token['access_token']) ? (string)$token['access_token'] : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成并缓存不限次数微信小程序码(wxacode.getUnlimited)
|
||||
* 若未配置小程序或线上尚未发布正式版,静默返回空字符串以便前端自动回退至普通二维码
|
||||
*
|
||||
* @param string $scene 场景值(最长32个可见字符,如 ic_ABCD12)
|
||||
* @param string $page 小程序页面路径(不带前导 /,如 pages/index/index)
|
||||
* @param int $width 二维码宽度(px)
|
||||
* @return string 成功返回相对 URL(如 /uploads/wxacode/xxx.png),失败返回空字符串
|
||||
*/
|
||||
public static function wxacodeUnlimit($scene, $page = 'pages/index/index', $width = 280)
|
||||
{
|
||||
$scene = substr(trim((string)$scene), 0, 32);
|
||||
$page = ltrim(trim((string)$page), '/');
|
||||
if ($scene === '' || !self::isConfigured()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$hash = md5($scene . '|' . $page . '|' . (int)$width);
|
||||
$relDir = '/uploads/wxacode';
|
||||
$absDir = ROOT_PATH . 'public' . DS . 'uploads' . DS . 'wxacode';
|
||||
$relUrl = $relDir . '/' . $hash . '.png';
|
||||
$absFile = $absDir . DS . $hash . '.png';
|
||||
|
||||
if (is_file($absFile) && filesize($absFile) > 200) {
|
||||
return $relUrl;
|
||||
}
|
||||
|
||||
try {
|
||||
$response = self::app()->app_code->getUnlimit($scene, [
|
||||
'page' => $page !== '' ? $page : 'pages/index/index',
|
||||
'width' => max(280, min(1280, (int)$width)),
|
||||
'check_path' => false,
|
||||
]);
|
||||
|
||||
if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) {
|
||||
$body = $response->getBody()->getContents();
|
||||
// 校验 PNG (\x89PNG) 或 JPEG (\xFF\xD8) 魔数,避免把微信返回的 JSON 错误当图片落盘
|
||||
if (strlen($body) > 200 && (substr($body, 0, 4) === "\x89PNG" || substr($body, 0, 2) === "\xFF\xD8")) {
|
||||
if (!is_dir($absDir)) {
|
||||
@mkdir($absDir, 0755, true);
|
||||
}
|
||||
@file_put_contents($absFile, $body);
|
||||
if (is_file($absFile) && filesize($absFile) > 200) {
|
||||
return $relUrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
// 静默降级:小程序未发布或网络受限时由前端自动回退绘制二维码
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/* ==================== 内部工具 ==================== */
|
||||
|
||||
/** SDK 返回 Collection / array / object 统一转数组 */
|
||||
|
||||
在新工单中引用
屏蔽一个用户