Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复商家转账参数缺失的问题 #977

Merged
merged 3 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ jobs:
- name: Run Coverage
run: vendor/bin/phpunit --coverage-clover coverage.xml
- name: Upload Coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v3.7.3

### fixed

- fix: 修复商家转账参数缺失的问题(#977)

## v3.7.2

### added
Expand Down
3 changes: 2 additions & 1 deletion src/Plugin/Wechat/V3/Marketing/Transfer/CreatePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ protected function normal(array $params, array $config, Collection $payload): ar
*/
protected function encryptSensitiveData(array $params, array $config, Collection $payload): array
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改为以下代码吧

protected function encryptSensitiveData(array $params, array $config, Collection $payload): array
{
    $data['transfer_detail_list'] = $payload->get('transfer_detail_list', []);
    $data['_serial_no'] = get_wechat_serial_no($params);
    $publicKey = get_wechat_public_key($config, $data['_serial_no']);

    foreach ($data['transfer_detail_list'] as $key => $list) {
        if (!empty($list['user_name'])) {
            $data['transfer_detail_list'][$key]['user_name'] = encrypt_wechat_contents($list['user_name'], $publicKey);
        }
    }

    return $data;
}

然后帮忙把单测补充一下

{
$data['transfer_detail_list'] = $payload->get('transfer_detail_list', []);
$data['_serial_no'] = get_wechat_serial_no($params);
$publicKey = get_wechat_public_key($config, $data['_serial_no']);

foreach ($payload->get('transfer_detail_list', []) as $key => $list) {
foreach ($data['transfer_detail_list'] as $key => $list) {
if (!empty($list['user_name'])) {
$data['transfer_detail_list'][$key]['user_name'] = encrypt_wechat_contents($list['user_name'], $publicKey);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ public function testNormalWithName()
"test" => "111",
'transfer_detail_list' => [
[
'user_name' => 'yansongda'
'user_name' => 'yansongda',
'foo' => 'bar',
]
]
]));
Expand All @@ -102,5 +103,6 @@ public function testNormalWithName()
self::assertArrayHasKey('_serial_no', $payload);
self::assertArrayHasKey('user_name', $payload['transfer_detail_list'][0]);
self::assertNotEquals('yansongda', $payload['transfer_detail_list'][0]['user_name']);
self::assertEquals('bar', $payload['transfer_detail_list'][0]['foo']);
}
}