mirror of
https://gitee.com/ShopeX/OMS
synced 2026-03-31 13:25:32 +08:00
78 lines
3.1 KiB
PHP
78 lines
3.1 KiB
PHP
<?php
|
||
/**
|
||
* Copyright 2026 ShopeX (https://www.shopex.cn)
|
||
*
|
||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
* you may not use this file except in compliance with the License.
|
||
* You may obtain a copy of the License at
|
||
*
|
||
* http://www.apache.org/licenses/LICENSE-2.0
|
||
*
|
||
* Unless required by applicable law or agreed to in writing, software
|
||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
* See the License for the specific language governing permissions and
|
||
* limitations under the License.
|
||
*/
|
||
|
||
class erpapi_unionpay_response_process_logistics {
|
||
static public $sms_method = array(
|
||
'1'=>'express',#已揽收
|
||
'3'=>'received',#已签收
|
||
);
|
||
|
||
/**
|
||
* push
|
||
* @param mixed $params 参数
|
||
* @return mixed 返回值
|
||
*/
|
||
public function push($params) {
|
||
$filter = array(
|
||
'delivery_id' => $params['delivery_id'],
|
||
'logi_status|noequal' => $params['logi_status']
|
||
);
|
||
|
||
$strReceived = $params['logi_status'] == '1' ? '签收' : ($params['logi_status'] == '2' ? '揽收' : '');
|
||
if ($params['sign_time']){
|
||
$data['sign_time'] = $params['sign_time'];
|
||
}
|
||
|
||
$data = array('logi_status'=>$params['logi_status']);
|
||
if ($params['embrace_time']){
|
||
$data['embrace_time'] = $params['embrace_time'];
|
||
}
|
||
|
||
$ret = app::get('ome')->model('delivery')->update($data, $filter);
|
||
if(is_bool($ret)) {
|
||
return array('rsp'=>'succ', 'msg'=>'该发货单已' . $strReceived);
|
||
}
|
||
|
||
$memo = '更新签收状态为:已' . $strReceived . '(物流单号:'.$params['logi_no'].')';
|
||
app::get('ome')->model('operation_log')->write_log('delivery_process@ome',$params['delivery_id'],$memo);
|
||
|
||
#已揽收、已签收的,需要发送短信
|
||
$method = self::$sms_method[$params['logi_status']];
|
||
if($method){
|
||
#如果taoexlib存在,发货短信开启的 发送短信
|
||
if(kernel::service('message_setting') && defined('APP_TOKEN') && defined('APP_SOURCE')){
|
||
kernel::single('taoexlib_sms')->sendSms(array('event_type'=>$method,'delivery_id'=>$params['delivery_id']), $error_msg);
|
||
}
|
||
}
|
||
|
||
#只有已签收的货到付款单才自动支付
|
||
if($params['logi_status'] == '1' && $params['is_cod'] == 'true' && 'false' != app::get('ome')->getConf('ome.codorder.autopay')){
|
||
kernel::single('ome_order')->codAutoPay($params['delivery_id']);
|
||
}
|
||
|
||
//已签收的获取order_id 调用自动电子发票业务
|
||
if($params['logi_status'] == '1'){
|
||
$funcObj = kernel::single('invoice_func');
|
||
$orderDelivery = app::get('ome')->model('delivery_order')->getList('*',array('delivery_id'=>$params['delivery_id']));
|
||
foreach($orderDelivery as $od) {
|
||
$funcObj->do_einvoice_bill($od['order_id'],"2");
|
||
}
|
||
}
|
||
|
||
return array('rsp'=>'succ', 'msg' => '更新物流状态成功!');
|
||
}
|
||
} |