admin/addon/store/storeapi/controller/Store.php

143 lines
5.5 KiB
PHP

<?php
/**
* ThinkShop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.cdcloudshop.com
* =========================================================
*/
namespace addon\store\storeapi\controller;
use app\model\express\Local as LocalModel;
use app\model\store\Store as StoreModel;
use app\storeapi\controller\BaseStoreApi;
/**
* 门店控制器
*/
class Store extends BaseStoreApi
{
/**
* 获取门店信息
* @return false|string
* @throws \app\exception\ApiException
*/
public function info()
{
$store_model = new StoreModel();
$store_info = $store_model->getStoreInfo([ [ 'store_id', '=', $this->store_id ] ]);
return $this->response($store_info);
}
/**
* 门店修改
*/
public function edit()
{
$condition = array (
[ "site_id", "=", $this->site_id ],
[ "store_id", "=", $this->store_id ]
);
$store_model = new StoreModel();
$store_name = $this->params[ 'store_name' ] ?? '';
$telphone = $this->params[ 'telphone' ] ?? '';
$store_image = $this->params[ 'store_image' ] ?? '';
$status = $this->params[ 'status' ] ?? 0;
$province_id = $this->params[ 'province_id'] ?? 0;
$city_id = $this->params[ 'city_id'] ?? 0;
$district_id = $this->params[ 'district_id' ] ?? 0;
$community_id = $this->params[ 'community_id' ] ?? 0;
$address = $this->params[ 'address' ] ?? '';
$full_address = $this->params[ 'full_address' ] ?? '';
$longitude = $this->params[ 'longitude'] ?? 0;
$latitude = $this->params[ 'latitude' ] ?? 0;
$open_date = $this->params[ 'open_date' ] ?? '';
$start_time = $this->params[ 'start_time' ] ?? 0;
$end_time = $this->params[ 'end_time' ] ?? 0;
$time_type = $this->params[ 'time_type' ] ?? 0;
$time_week = $this->params[ 'time_week' ] ?? '';
$support_trade_type = $this->params[ 'support_trade_type' ] ?? '';
$stock_type = $this->params[ 'stock_type' ] ?? '';
if (!empty($time_week)) {
$time_week = implode(',', $time_week);
}
$data = array (
"store_name" => $store_name,
"telphone" => $telphone,
"store_image" => $store_image,
"status" => $status,
"province_id" => $province_id,
"city_id" => $city_id,
"district_id" => $district_id,
"community_id" => $community_id,
"address" => $address,
"full_address" => $full_address,
"longitude" => $longitude,
"latitude" => $latitude,
"open_date" => $open_date,
'start_time' => $start_time,
'end_time' => $end_time,
'time_type' => $time_type,
'time_week' => $time_week,
'support_trade_type' => $support_trade_type,
'stock_type' => $stock_type,
);
$result = $store_model->editStore($data, $condition, [], 1, 1);
return $this->response($result);
}
/**
* 同城配送详情
* @return false|string
*/
public function localInfo()
{
$local_model = new LocalModel();
$local_result = $local_model->getLocalInfo([ [ 'site_id', '=', $this->site_id ], ['store_id', '=', $this->store_id]]);
return $this->response($local_result);
}
/**
* 同城配送修改
* @return false|string
*/
public function editLocal()
{
$data = [
'type' => $this->params[ 'type' ] ?? 'default',
'area_type' => $this->params[ 'area_type' ] ?? 1,
'local_area_json' => $this->params[ 'local_area_json' ] ?? '',//区域及业务集合json
'time_is_open' => $this->params[ 'time_is_open' ] ?? 0,
'time_type' => $this->params[ 'time_type' ] ?? 0,//时间选取类型 0 全天 1 自定义
'time_week' => $this->params[ 'time_week' ] ?? '',
'start_time' => $this->params[ 'start_time' ] ?? 0,
'end_time' => $this->params[ 'end_time' ] ?? 0,
'update_time' => time(),
'is_open_step' => $this->params[ 'is_open_step' ] ?? 0,
'start_distance' => $this->params[ 'start_distance' ] ?? 0,
'start_delivery_money' => $this->params[ 'start_delivery_money' ] ?? 0,
'continued_distance' => $this->params[ 'continued_distance' ] ?? 0,
'continued_delivery_money' => $this->params[ 'continued_delivery_money' ] ?? 0,
'start_money' => $this->params[ 'start_money' ] ?? 0,
'delivery_money' => $this->params[ 'delivery_money' ] ?? 0,
'area_array' => $this->params[ 'area_array' ] ?? '',//地域集合
'man_money' => $this->params[ 'man_money' ] ?? '',
'man_type' => $this->params[ 'man_type' ] ?? '',
'man_discount' => $this->params[ 'man_discount' ] ?? '',
'time_interval' => $this->params[ 'time_interval'] ?? 30,
'delivery_time' => $this->params[ 'delivery_time'] ?? ''
];
$condition = array (
[ 'site_id', '=', $this->site_id ],
[ 'store_id', '=', $this->store_id ],
);
$local_model = new LocalModel();
$res = $local_model->editLocal($data, $condition);
return $this->response($res);
}
}