```
feat(split-order): 添加微信交易单号搜索功能 - 在订单模型中添加Db类引入以支持数据库查询 - 在搜索字段中添加wx_transaction_id支持 - 实现通过微信交易单号查找订单ID的功能,包括在payment_json和pay_ext表中的查询 - 添加微信交易单号输入框到前端界面 - 更新JavaScript过滤器配置以包含新的搜索字段 ```
这个提交包含在:
@@ -9,6 +9,7 @@ use addons\shopro\library\split\SplitExecutor;
|
||||
use addons\shopro\library\split\ProfitSharingService;
|
||||
use app\admin\model\shopro\order\Order as ShopOrder;
|
||||
use app\admin\model\shopro\user\User as ShopUser;
|
||||
use think\Db;
|
||||
|
||||
class Order extends Base
|
||||
{
|
||||
@@ -32,7 +33,7 @@ class Order extends Base
|
||||
{
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax()) {
|
||||
$nobuildfields = ['buyer_keyword', 'order_sn', 'status', 'channel', 'createtime'];
|
||||
$nobuildfields = ['buyer_keyword', 'order_sn', 'wx_transaction_id', 'status', 'channel', 'createtime'];
|
||||
list($where, $sort, $order, $offset, $limit) = $this->custombuildparams(null, $nobuildfields);
|
||||
|
||||
$query = $this->buildSearch();
|
||||
@@ -71,6 +72,17 @@ class Order extends Base
|
||||
$orderIds = ShopOrder::where('order_sn', 'like', '%' . trim($filter['order_sn']) . '%')->column('id');
|
||||
$query = $query->where('order_id', 'in', $orderIds ?: [0]);
|
||||
}
|
||||
if (!empty($filter['wx_transaction_id'])) {
|
||||
$orderIds = $this->resolveOrderIdsByWxTransactionId($filter['wx_transaction_id']);
|
||||
$query = $query->where(function ($q) use ($orderIds, $filter) {
|
||||
$txn = trim($filter['wx_transaction_id']);
|
||||
$like = '%' . $txn . '%';
|
||||
$q->where('transaction_id', 'like', $like);
|
||||
if ($orderIds) {
|
||||
$q->whereOr('order_id', 'in', $orderIds);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!empty($filter['buyer_keyword'])) {
|
||||
$kw = trim($filter['buyer_keyword']);
|
||||
$userIds = ShopUser::where('nickname|mobile', 'like', '%' . $kw . '%')->column('id');
|
||||
@@ -99,6 +111,26 @@ class Order extends Base
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信交易单号 → 商城 order_id(汇付单号在 payment_json / pay_ext.extra)
|
||||
*/
|
||||
protected function resolveOrderIdsByWxTransactionId($txn)
|
||||
{
|
||||
$txn = trim((string) $txn);
|
||||
if ($txn === '') {
|
||||
return [];
|
||||
}
|
||||
$like = '%' . $txn . '%';
|
||||
$ids = ShopOrder::where('transaction_id', 'like', $like)->column('id');
|
||||
$ids = array_merge($ids, ShopOrder::where('payment_json', 'like', $like)->column('id'));
|
||||
try {
|
||||
$ids = array_merge($ids, Db::name('shopro_huifu_pay_ext')->where('extra', 'like', $like)->column('order_id'));
|
||||
} catch (\Exception $e) {
|
||||
// table may not exist
|
||||
}
|
||||
return array_values(array_unique(array_filter(array_map('intval', $ids))));
|
||||
}
|
||||
|
||||
protected function formatSplitOrderList($list)
|
||||
{
|
||||
$rows = [];
|
||||
|
||||
在新工单中引用
屏蔽一个用户