一号通接口传入appid

This commit is contained in:
evoxwht 2023-06-13 11:04:39 +08:00
parent 48eeed4a27
commit 5995482385
7 changed files with 37 additions and 20 deletions

View File

@ -66,12 +66,12 @@ class SmsService extends NoticeService
$this->isOpen = $this->noticeInfo['is_sms'] === 1;
$mark = $this->noticeInfo['mark'];
if ($this->isOpen) {
try{
try {
/** @var SmsService $smsServices */
$smsServices = app()->make(SmsService::class);
$smsServices->send(true, $phone, $data, $mark);
return true;
}catch (\Throwable $e) {
} catch (\Throwable $e) {
Log::error('发送短信失败,失败原因:' . $e->getMessage());
}
//SmsJob::dispatch('doJob', [$phone, $data, $mark]);
@ -111,7 +111,7 @@ class SmsService extends NoticeService
}
$smsMake = $services->sms($type);
//发送短信
$res = $smsMake->send($phone, $templateId, $data);
$res = $smsMake->send($phone, $templateId, $data, sys_config('yihaotong_sms_appid', ''));
if ($res === false) {
throw new ApiException($smsMake->getError());
}

View File

@ -518,7 +518,7 @@ class StoreOrderDeliveryServices extends BaseServices
if (!sys_config('config_export_open', 0)) {
throw new AdminException(400528);
}
$dump = $expressService->express()->dump($expData);
$dump = $expressService->express()->dump($expData, sys_config('yihaotong_face_appid', ''));
$orderInfo->delivery_id = $dump['kuaidinum'];
$data['express_dump'] = json_encode([
'com' => $expData['com'],
@ -561,10 +561,13 @@ class StoreOrderDeliveryServices extends BaseServices
$expData['temp_id'] = $data['express_temp_id'];
$expData['weight'] = $this->getOrderSumWeight($id);
$expData['cargo'] = $orderInfoServices->getCarIdByProductTitle((int)$orderInfo->id, true);
$expData['day_type'] = $data['day_type'];
$expData['pickup_start_time'] = $data['pickup_start_time'];
$expData['pickup_end_time'] = $data['pickup_end_time'];
if (!sys_config('config_shippment_open', 0)) {
throw new AdminException('商家寄件未开启无法寄件');
}
$dump = $expressService->express()->shippmentCreateOrder($expData);
$dump = $expressService->express()->shippmentCreateOrder($expData, sys_config('yihaotong_send_appid', ''));
$orderInfo->delivery_id = $dump['kuaidinum'] ?? '';
$data['express_dump'] = json_encode([
'com' => $expData['com'],

View File

@ -55,7 +55,7 @@ class CopyTaobaoServices extends BaseServices
case 1://平台
/** @var ServeServices $services */
$services = app()->make(ServeServices::class);
$resultData = $services->copy('copy')->goods($url);
$resultData = $services->copy('copy')->goods($url, sys_config('yihaotong_copy_appid', ''));
if (isset($resultData['description_image']) && is_string($resultData['description_image'])) {
$resultData['description_image'] = json_decode($resultData['description_image'], true);
}

View File

@ -203,7 +203,7 @@ class ExpressServices extends BaseServices
case 1:
/** @var ServeServices $services */
$services = app()->make(ServeServices::class);
$result = $services->express()->query($expressNum, $com, $phone);
$result = $services->express()->query($expressNum, $com, $phone, sys_config('yihaotong_express_appid', ''));
if (isset($result['ischeck']) && $result['ischeck'] == 1) {
$cacheTime = 0;
} else {

View File

@ -49,12 +49,14 @@ class Copy extends BaseCopyProduct
/** 复制商品
* @param string $url
* @param array $options
* @param string $yihaotongCopyAppid
* @return mixed
*/
public function goods(string $url, array $options = [])
public function goods(string $url, array $options = [], string $yihaotongCopyAppid = '')
{
$param['url'] = $url;
return $this->accessToken->httpRequest(self::PRODUCT_GOODS, $param);
$header = $yihaotongCopyAppid != '' ? ['AppId:' . $yihaotongCopyAppid] : [];
return $this->accessToken->httpRequest(self::PRODUCT_GOODS, $param, 'post', true, $header);
}

View File

@ -85,7 +85,7 @@ class Express extends BaseExpress
* @email 136327134@qq.com
* @date 2023/5/15
*/
public function shippmentCreateOrder(array $data)
public function shippmentCreateOrder(array $data, string $yihaotongSendAppid = '')
{
$siid = sys_config('config_export_siid');
$param = [
@ -102,8 +102,12 @@ class Express extends BaseExpress
'tempid' => $data['tempid'],
'cargo' => $data['cargo'],
'weight' => $data['weight'],
'day_type' => $data['day_type'],
'pickup_start_time' => $data['pickup_start_time'],
'pickup_end_time' => $data['pickup_end_time'],
];
return $this->accessToken->httpRequest(self::SHIPMENT_CREATE_ORDER, $param);
$header = $yihaotongSendAppid != '' ? ['AppId:' . $yihaotongSendAppid] : [];
return $this->accessToken->httpRequest(self::SHIPMENT_CREATE_ORDER, $param, 'post', true, $header);
}
/**
@ -202,7 +206,7 @@ class Express extends BaseExpress
* @return 物流状态:status 0在途,1揽收,2疑难,3签收,4退签,5派件,6退回,7转单,10待清关,11清关中,12已清关,13清关异常,14收件人拒签
* @return 物流详情 content
*/
public function query(string $num, string $com = '', $phone = '')
public function query(string $num, string $com = '', $phone = '', $yihaotongExpressAppid = '')
{
$param = [
'com' => $com,
@ -212,15 +216,20 @@ class Express extends BaseExpress
if ($com === null) {
unset($param['com']);
}
return $this->accessToken->httpRequest(self::EXPRESS_QUERY, $param);
$header = $yihaotongExpressAppid != '' ? ['AppId:' . $yihaotongExpressAppid] : [];
return $this->accessToken->httpRequest(self::EXPRESS_QUERY, $param, 'post', true, $header);
}
/**
* 电子面单打印
* @param array $data 必需参数: com(快递公司编码)、to_name(寄件人)、to_tel(寄件人电话)、to_addr(寄件人详细地址)、from_name(收件人)、from_tel(收件人电话)、from_addr(收件人地址)、temp_id(电子面单模板ID)、siid(云打印机编号)、count(商品数量)
* @param string $yihaotongFaceAppid
* @return bool|mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function dump($data)
public function dump($data, $yihaotongFaceAppid = '')
{
$param = $data;
$param['com'] = $data['com'] ?? '';
@ -264,6 +273,7 @@ class Express extends BaseExpress
if (!sys_config('config_export_siid')) {
$header = ['version:v1.1'];
}
$header = array_merge($header, $yihaotongFaceAppid != '' ? ['AppId:' . $yihaotongFaceAppid] : []);
return $this->accessToken->httpRequest(self::EXPRESS_DUMP, $param, 'POST', true, $header);
}

View File

@ -196,26 +196,28 @@ class Yihaotong extends BaseSms
/**
* 发送短信
* @param $phone
* @param $template
* @param $param
* @param string $phone
* @param string $templateId
* @param array $data
* @param string $yihaotongSmsAppid
* @return bool|string
*/
public function send(string $phone, string $templateId, array $data = [])
public function send(string $phone, string $templateId, array $data = [], string $yihaotongSmsAppid = '')
{
if (!$phone) {
throw new AdminException(400719);
}
$param = [
'phone' => $phone,
'host' => request()->host()
'host' => request()->host()
];
$param['temp_id'] = $templateId;
if (is_null($param['temp_id'])) {
throw new AdminException(400720);
}
$param['param'] = json_encode($data);
return $this->accessToken->httpRequest(self::SMS_SEND, $param);
$header = $yihaotongSmsAppid != '' ? ['AppId:' . $yihaotongSmsAppid] : [];
return $this->accessToken->httpRequest(self::SMS_SEND, $param, 'post', true, $header);
}
/**