mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-11-01 07:20:56 +00:00
fix: 修改小程序订单
This commit is contained in:
parent
72a3057622
commit
ed851f3e43
@ -32,6 +32,27 @@ class OrderClient extends BaseOrder
|
||||
return $this->redis;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理联系人
|
||||
* @param array $contact
|
||||
* @return array
|
||||
*
|
||||
* @date 2023/05/10
|
||||
* @author yyw
|
||||
*/
|
||||
protected function handleContact(array $contact = []): array
|
||||
{
|
||||
if (isset($contact)) {
|
||||
if (isset($contact['consignor_contact']) && $contact['consignor_contact']) {
|
||||
$contact['consignor_contact'] = Utility::encryptTel($contact['consignor_contact']);
|
||||
}
|
||||
if (isset($contact['receiver_contact']) && $contact['receiver_contact']) {
|
||||
$contact['receiver_contact'] = Utility::encryptTel($contact['receiver_contact']);
|
||||
}
|
||||
}
|
||||
return $contact;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发货
|
||||
* @param string $out_trade_no
|
||||
@ -71,11 +92,12 @@ class OrderClient extends BaseOrder
|
||||
}
|
||||
|
||||
foreach ($shipping_list as $shipping) {
|
||||
$contact = $this->handleContact($shipping['contact'] ?? []);
|
||||
$params['shipping_list'][] = [
|
||||
'tracking_no' => $shipping['tracking_no'],
|
||||
'express_company' => $this->getDelivery($shipping['express_company']),
|
||||
'tracking_no' => $shipping['tracking_no'] ?? '',
|
||||
'express_company' => isset($shipping['express_company']) ? $this->getDelivery($shipping['express_company']) : '',
|
||||
'item_desc' => $shipping['item_desc'],
|
||||
'contact' => $shipping['contact'] ?? []
|
||||
'contact' => $contact
|
||||
];
|
||||
}
|
||||
return $this->shipping($params);
|
||||
@ -107,16 +129,6 @@ class OrderClient extends BaseOrder
|
||||
'mchid' => $this->config['order_shipping']['merchant_id'],
|
||||
'out_trade_no' => $out_trade_no,
|
||||
],
|
||||
'sub_orders' => [
|
||||
'order_key' => [
|
||||
'order_number_type' => 1,
|
||||
'mchid' => $this->config['order_shipping']['merchant_id'],
|
||||
'out_trade_no' => '',
|
||||
'logistics_type' => '',
|
||||
],
|
||||
'delivery_mode' => $delivery_mode,
|
||||
'is_all_delivered' => $is_all_delivered
|
||||
],
|
||||
'upload_time' => date(DATE_RFC3339),
|
||||
'payer' => [
|
||||
'openid' => $payer_openid
|
||||
@ -135,11 +147,12 @@ class OrderClient extends BaseOrder
|
||||
'is_all_delivered' => $is_all_delivered
|
||||
];
|
||||
foreach ($sub_orders['shipping_list'] as $shipping) {
|
||||
$contact = $this->handleContact($shipping['contact'] ?? []);
|
||||
$sub_order['shipping_list'][] = [
|
||||
'tracking_no' => $shipping['tracking_no'],
|
||||
'express_company' => $this->getDelivery($shipping['express_company']),
|
||||
'tracking_no' => $shipping['tracking_no'] ?? '',
|
||||
'express_company' => isset($shipping['express_company']) ? $this->getDelivery($shipping['express_company']) : '',
|
||||
'item_desc' => $shipping['item_desc'],
|
||||
'contact' => $shipping['contact'] ?? []
|
||||
'contact' => $contact
|
||||
];
|
||||
}
|
||||
$params['sub_orders'][] = $sub_order;
|
||||
|
||||
42
crmeb/crmeb/services/easywechat/orderShipping/Utility.php
Normal file
42
crmeb/crmeb/services/easywechat/orderShipping/Utility.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace crmeb\services\easywechat\orderShipping;
|
||||
|
||||
use crmeb\exceptions\AdminException;
|
||||
|
||||
class Utility
|
||||
{
|
||||
/**
|
||||
* @param int $padding
|
||||
*/
|
||||
private static function paddingModeLimitedCheck(int $padding): void
|
||||
{
|
||||
if (!($padding === OPENSSL_PKCS1_OAEP_PADDING || $padding === OPENSSL_PKCS1_PADDING)) {
|
||||
throw new AdminException(sprintf("Doesn't supported padding mode(%d), here only support OPENSSL_PKCS1_OAEP_PADDING or OPENSSL_PKCS1_PADDING.", $padding));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加密数据
|
||||
* @param string $plaintext
|
||||
* @param int $padding
|
||||
* @return string
|
||||
*/
|
||||
public function encryptor(string $plaintext, int $padding = OPENSSL_PKCS1_OAEP_PADDING)
|
||||
{
|
||||
self::paddingModeLimitedCheck($padding);
|
||||
|
||||
if (!openssl_public_encrypt($plaintext, $encrypted, $this->getPublicKey(), $padding)) {
|
||||
throw new AdminException('Encrypting the input $plaintext failed, please checking your $publicKey whether or nor correct.');
|
||||
}
|
||||
|
||||
return base64_encode($encrypted);
|
||||
}
|
||||
|
||||
public static function encryptTel($tel)
|
||||
{
|
||||
$new_tel = substr_replace($tel, '****', 3, 4);
|
||||
return $new_tel;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user