mirror of
https://gitee.com/ShopeX/OMS
synced 2026-04-01 21:46:43 +08:00
114 lines
4.7 KiB
PHP
114 lines
4.7 KiB
PHP
<?php
|
||
/**
|
||
* Copyright © ShopeX (http://www.shopex.cn). All rights reserved.
|
||
* See LICENSE file for license details.
|
||
*/
|
||
|
||
#第三方应用中心
|
||
class channel_ctl_admin_logistics_examin extends desktop_controller{
|
||
/**
|
||
* index
|
||
* @return mixed 返回值
|
||
*/
|
||
public function index(){
|
||
#检测是否需要上传模板
|
||
$need_upload_temple = kernel::single('channel_func')->check_need_upload_temple();
|
||
|
||
#检查发货仓库信息的完整性
|
||
$branch_info_fullfill = kernel::single('ome_func')->check_branch_info_fullfill();
|
||
|
||
|
||
$this->pagedata['info_fullfill'] = $branch_info_fullfill;
|
||
|
||
|
||
$obj_delivery = app::get('ome')->model('delivery');
|
||
#先检查已签收或揽收发货单,数量是不是已经大于500,只有大于500条的,才可以体检
|
||
$this->pagedata['history_order_count'] = $obj_delivery->count(array('is_received'=>array('1','2')));
|
||
|
||
|
||
#计算发货仓库数量(模板上传,以仓库为单位进行上传)
|
||
$_all_branch = app::get('ome')->model('branch')->getList('branch_id',array('is_deliv_branch'=>'true'));
|
||
$all_branch = array();
|
||
foreach( $_all_branch as $key=>$val){
|
||
$all_branch_id[$val['branch_id']] = $val['branch_id'];
|
||
}
|
||
|
||
$this->pagedata['need_upload_temple'] = $need_upload_temple;
|
||
$this->pagedata['all_warehouse_id'] = json_encode($all_branch_id);
|
||
$this->pagedata['total_warehouse_amount'] = count($all_branch_id);
|
||
$this->page('admin/logistics/setting.html');
|
||
}
|
||
/**
|
||
* ajax_get_used_times
|
||
* @return mixed 返回值
|
||
*/
|
||
public function ajax_get_used_times(){
|
||
$examin_service_info = kernel::single('ome_addedservice')->get_service('examin');
|
||
$used_times = $examin_service_info['used_times']?$examin_service_info['used_times']:'0';#总使用次数
|
||
$filter['examin_status'] = array('running','succ');
|
||
#获取本地已使用体检次数(运行中和已成功)
|
||
$local_used_times = $this->app->model('logistics_examinreport')->count($filter);
|
||
if($local_used_times >= $used_times){
|
||
$used_times = $local_used_times ;
|
||
}
|
||
$available_times = $examin_service_info['available_times']?$examin_service_info['available_times']:'0';#可授权次数
|
||
echo json_encode(array('used_times'=>$used_times,'available_times'=>$available_times));
|
||
}
|
||
#以发货网店为单位,进行模板上传
|
||
/**
|
||
* ajax_warehouse_template_upload
|
||
* @return mixed 返回值
|
||
*/
|
||
public function ajax_warehouse_template_upload(){
|
||
$warehouse_id = $_POST['warehouse_id'];
|
||
$exrecommend_souce = $_POST['exrecommend_souce']?$exrecommend_souce:'hqepay';
|
||
|
||
$status = kernel::single('ome_event_trigger_exrecommend_recommend')->strategyUpdate($warehouse_id);#同步与仓库相关的所有模板策略
|
||
|
||
if($status['rsp'] == 'succ'){
|
||
echo json_encode(array('status'=>'succ'));die;
|
||
}else{
|
||
echo json_encode(array('status'=>'fail'));die;
|
||
}
|
||
}
|
||
#添加体检
|
||
/**
|
||
* ajax_start_examin
|
||
* @return mixed 返回值
|
||
*/
|
||
public function ajax_start_examin(){
|
||
$obj_examin_report = app::get('channel')->model('logistics_examinreport');
|
||
$rs = $obj_examin_report->getList('*',array('is_first_examin'=>'true'));
|
||
#查看是否已经第一次体检
|
||
if(!empty($rs)){
|
||
$is_first_examin = false;
|
||
}else{
|
||
$is_first_examin = true;
|
||
}
|
||
$examin_data['examin_time'] = time();
|
||
$examin_data['is_first_examin'] = $is_first_examin?'true':'false';
|
||
$examin_data['examin_op_user'] = kernel::single('desktop_user')->get_name();
|
||
$obj_examin_report = app::get('channel')->model('logistics_examinreport');
|
||
#预先生成报告日志
|
||
$obj_examin_report->save($examin_data);
|
||
|
||
$params = array(
|
||
'is_first_examin' => $is_first_examin,
|
||
'examin_id'=>$examin_data['examin_id'],
|
||
);
|
||
#开始体检
|
||
kernel::single('ome_event_trigger_shop_hqepay')->logistics_examin_send($params);
|
||
echo 'succ';
|
||
}
|
||
function ajax_upload_log(){
|
||
$data['op_user'] = kernel::single('desktop_user')->get_name();
|
||
$data['op_type'] = '1';#已同步模板
|
||
$data['create_time'] = time();
|
||
$data['exrecommend_souce'] = $_POST['exrecommend_souce']?$_POST['exrecommend_souce']:'hqepay';
|
||
|
||
$obj_logistics_logs = app::get('channel')->model('logistics_logs');
|
||
$obj_logistics_logs->save($data);
|
||
|
||
$obj_logistics_logs->update(array('status'=>''),array('op_type'=>3));#上传完毕,把模板变动的状态都清除
|
||
}
|
||
} |