Files
OMS/app/inventorydepth/controller/shop/mapping.php
2026-01-04 19:08:31 +08:00

103 lines
3.1 KiB
PHP

<?php
/**
* Copyright 2012-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.
*/
/**
* 基础物料控制层
*
* @author kamisama.xia@gmail.com
* @version 0.1
*/
class inventorydepth_ctl_shop_mapping extends desktop_controller
{
public function index()
{
kernel::single('inventorydepth_shop_mapping')->set_params($_REQUEST)->display();
}
//前段店铺拉取商品
public function downloadAllGoods()
{
$shop = app::get('ome')->model('shop');
$shop_list = $shop->getList('shop_id,name', ['shop_type' => 'luban']);
$this->pagedata['shop_list'] = $shop_list;
$this->pagedata['goods_type'] = array(
['key'=>'','value'=>'全部'],
['key'=>'0','value'=>'上架'],
['key'=>'1','value'=>'下架'],
);
//开始时间(默认为一个月前)
$start_time = date('Y-m-d', strtotime('-1 month'));
$this->pagedata['start_time'] = $start_time;
$this->display('shop/mapping/download_all_goods.html');
}
public function ajaxDownloadAllGoods()
{
parse_str($_POST['shopId'], $postdata);
$retArr = array(
'itotal' => 0,
'isucc' => 0,
'ifail' => 0,
'total' => 0,
'err_msg' => array(),
);
if (!$postdata) {
$retArr['err_msg'] = ['请先选择店铺'];
echo json_encode($retArr);
exit;
}
//page
$page = isset($_POST['nextPage']) && $_POST['nextPage'] > 1 ? $_POST['nextPage'] : 1;
//params
$params = array(
'shop_id' => $_POST['shopId'],
'goods_type' => $goodsType,
);
//商品状态(0上架 1下架)
if($_POST['goodsType']==='0' || $_POST['goodsType']==='1'){
$params['goods_type'] = intval($_POST['goodsType']);
}
//开始时间(年-月-日)
if($_POST['startTime']){
$params['start_time'] = $_POST['startTime'];
}
//request
$rs = kernel::single('inventorydepth_shop_mapping')->downloadAllGoods($params, $page);
if ($rs['rsp'] == 'succ') {
$retArr['itotal'] += ($rs['succ'] - $rs['fail']);
$retArr['ifail'] += $rs['ifail'];
$retArr['total'] = $rs['all'];
$retArr['next_page'] = $rs['next_page'];
} else {
$retArr['err_msg'] = [$rs['err_msg']];
}
echo json_encode($retArr);
exit;
}
}