作者 竞泽

alter:排序

@@ -112,8 +112,11 @@ class Client implements ClientInterface @@ -112,8 +112,11 @@ class Client implements ClientInterface
112 'timestamp' => date('Y-m-d H:i:s'), 112 'timestamp' => date('Y-m-d H:i:s'),
113 ] + $pathQueryArray; 113 ] + $pathQueryArray;
114 $data['sign'] = SignatureUtil::generate($data, Arr::get($this->config, 'app_secret')); 114 $data['sign'] = SignatureUtil::generate($data, Arr::get($this->config, 'app_secret'));
  115 + ksort($data);
115 $response = $this->guzzleClient->request($this->request->getMethod(), $this->request->getPath(), [ 116 $response = $this->guzzleClient->request($this->request->getMethod(), $this->request->getPath(), [
116 - $key => $data, 117 + $key => array_filter($data, function ($v) {
  118 + return !(is_null($v) || $v === '');
  119 + }),
117 RequestOptions::HEADERS => [ 120 RequestOptions::HEADERS => [
118 'Content-Type' => 'application/json;charset=UTF-8', 121 'Content-Type' => 'application/json;charset=UTF-8',
119 ] 122 ]
@@ -310,10 +310,11 @@ class OrdersB2cAddRequest extends Request @@ -310,10 +310,11 @@ class OrdersB2cAddRequest extends Request
310 */ 310 */
311 public function appendOrderGoods($goods_id, $good_name, $price, $num, $dec_total, $deliveryItemId) 311 public function appendOrderGoods($goods_id, $good_name, $price, $num, $dec_total, $deliveryItemId)
312 { 312 {
313 - $item = ['index' => count($this->order_goods) + 1] + array_filter(get_defined_vars(), function ($v) { 313 + $index = count($this->order_goods) + 1;
  314 + $item = ['index' => (string)$index] + array_filter(get_defined_vars(), function ($v) {
314 return !(is_null($v) || $v === ''); 315 return !(is_null($v) || $v === '');
315 }); 316 });
316 - 317 + ksort($item);
317 return parent::append('order_goods', count($this->order_goods), $item); 318 return parent::append('order_goods', count($this->order_goods), $item);
318 } 319 }
319 320