$this->store_id, 'status' => StatusEnum::ENABLED ] ]; $where[] = !$type ? ['withdraw_status' => $type] : ['in', 'withdraw_status', [1, 2]]; $list = StoreWithdrawLog::listPage([ 'where' => $where, 'order' => 'id desc', 'select' => 'id, num, actual_num, poundage_num, type, withdraw_status, created_at, remark', 'limit' => $limit ]); // 提现方式 $type_map = PaymentLogic::getWithdrawTypeMap($this->mall_id); // 因为微信提现需要客户点击确认:所以此处传递微信打款信息给前端 $storeWithdrawLogIds = array_column($list['list'], 'id'); // 关联微信打款查询 $wechatTransferList = \common\models\wechat\WechatTransferLog::find() ->select('wechatLog.*') ->alias("wechatLog") ->innerJoin(\common\models\common\PaymentTransfer::tableName() . ' as payT', 'payT.order_no = wechatLog.out_trade_no') ->where(['payT.withdrawal_source_id' => $storeWithdrawLogIds, 'payT.withdrawal_source' => BossEnum::ADDONS_NAME]) ->indexBy('cash_id') ->asArray() ->all(); // 判断需要查询的字段 $wechatSearch = $platform == 'mp-wx' ? 'mini_program' : 'wechat'; $wechatProgram = \Yii::$app->services->setting->mall->get($this->mall_id, $wechatSearch, true); $appId = $wechatProgram['app_id'] ?? ''; array_walk($list['list'], function (&$item) use ($type_map, $wechatTransferList, $appId) { $item['transfer_result'] = []; if (isset($wechatTransferList[$item['id']])) { $payment_conf = \Yii::$app->services->setting->mall->get($this->mall_id, 'pay.wechat', true); $payment_conf = json_decode($payment_conf, true); $mchId = $payment_conf['wechat_mch_id'] ?? ''; $wechat_transfer = $wechatTransferList[$item['id']]; $transfer_result = json_decode($wechat_transfer['transfer_result'], true); $transfer_result['mchId'] = $mchId; $transfer_result['appId'] = $appId; $item['transfer_result'] = $transfer_result; } $item['created_at'] && $item['created_at_text'] = date('Y-m-d H:i:s', $item['created_at']); $item['type_text'] = $type_map[$item['type']] ?? WithdrawWayEnum::getDefaultWithDrawWayMap(WithdrawWayEnum::WITHDRAW_TYPE_2)[$item['type']] ?? '-'; $item['withdraw_status_text'] = WithdrawEnum::WITHDRAW_STATUS_MAP[$item['withdraw_status']] ?? '-'; }); return $list; } }