```
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 addons\shopro\library\split\ProfitSharingService;
|
||||||
use app\admin\model\shopro\order\Order as ShopOrder;
|
use app\admin\model\shopro\order\Order as ShopOrder;
|
||||||
use app\admin\model\shopro\user\User as ShopUser;
|
use app\admin\model\shopro\user\User as ShopUser;
|
||||||
|
use think\Db;
|
||||||
|
|
||||||
class Order extends Base
|
class Order extends Base
|
||||||
{
|
{
|
||||||
@@ -32,7 +33,7 @@ class Order extends Base
|
|||||||
{
|
{
|
||||||
$this->request->filter(['strip_tags']);
|
$this->request->filter(['strip_tags']);
|
||||||
if ($this->request->isAjax()) {
|
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);
|
list($where, $sort, $order, $offset, $limit) = $this->custombuildparams(null, $nobuildfields);
|
||||||
|
|
||||||
$query = $this->buildSearch();
|
$query = $this->buildSearch();
|
||||||
@@ -71,6 +72,17 @@ class Order extends Base
|
|||||||
$orderIds = ShopOrder::where('order_sn', 'like', '%' . trim($filter['order_sn']) . '%')->column('id');
|
$orderIds = ShopOrder::where('order_sn', 'like', '%' . trim($filter['order_sn']) . '%')->column('id');
|
||||||
$query = $query->where('order_id', 'in', $orderIds ?: [0]);
|
$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'])) {
|
if (!empty($filter['buyer_keyword'])) {
|
||||||
$kw = trim($filter['buyer_keyword']);
|
$kw = trim($filter['buyer_keyword']);
|
||||||
$userIds = ShopUser::where('nickname|mobile', 'like', '%' . $kw . '%')->column('id');
|
$userIds = ShopUser::where('nickname|mobile', 'like', '%' . $kw . '%')->column('id');
|
||||||
@@ -99,6 +111,26 @@ class Order extends Base
|
|||||||
return $query;
|
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)
|
protected function formatSplitOrderList($list)
|
||||||
{
|
{
|
||||||
$rows = [];
|
$rows = [];
|
||||||
|
|||||||
@@ -199,6 +199,7 @@
|
|||||||
<div class="toolbar-row">
|
<div class="toolbar-row">
|
||||||
<el-input v-model="filters.buyer_keyword" placeholder="买家昵称/手机号" size="small" style="width:160px;" clearable></el-input>
|
<el-input v-model="filters.buyer_keyword" placeholder="买家昵称/手机号" size="small" style="width:160px;" clearable></el-input>
|
||||||
<el-input v-model="filters.order_sn" placeholder="订单号" size="small" style="width:170px;" clearable></el-input>
|
<el-input v-model="filters.order_sn" placeholder="订单号" size="small" style="width:170px;" clearable></el-input>
|
||||||
|
<el-input v-model="filters.wx_transaction_id" placeholder="微信交易单号" size="small" style="width:200px;" clearable></el-input>
|
||||||
<el-select v-model="filters.status" placeholder="分账状态" size="small" style="width:120px;" clearable>
|
<el-select v-model="filters.status" placeholder="分账状态" size="small" style="width:120px;" clearable>
|
||||||
<el-option label="待分账" value="0"></el-option>
|
<el-option label="待分账" value="0"></el-option>
|
||||||
<el-option label="分账中" value="1"></el-option>
|
<el-option label="分账中" value="1"></el-option>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ define(['jquery', 'bootstrap', 'backend', 'form'], function ($, undefined, Backe
|
|||||||
filters: {
|
filters: {
|
||||||
buyer_keyword: '',
|
buyer_keyword: '',
|
||||||
order_sn: '',
|
order_sn: '',
|
||||||
|
wx_transaction_id: '',
|
||||||
status: '',
|
status: '',
|
||||||
channel: ''
|
channel: ''
|
||||||
},
|
},
|
||||||
@@ -36,7 +37,7 @@ define(['jquery', 'bootstrap', 'backend', 'form'], function ($, undefined, Backe
|
|||||||
this.getList();
|
this.getList();
|
||||||
},
|
},
|
||||||
resetFilters() {
|
resetFilters() {
|
||||||
this.filters = { buyer_keyword: '', order_sn: '', status: '', channel: '' };
|
this.filters = { buyer_keyword: '', order_sn: '', wx_transaction_id: '', status: '', channel: '' };
|
||||||
this.dateRange = [];
|
this.dateRange = [];
|
||||||
this.currentPage = 1;
|
this.currentPage = 1;
|
||||||
this.getList();
|
this.getList();
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户