ADD:添加后台管理端接口;
DEL:删除不必要的头部注释; FIX:修正若干已知错误;
This commit is contained in:
@@ -1,14 +1,8 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-04-15 20:22:03
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T09:02:06+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
//前端用户入口
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use yii\web\Controller;
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-04-15 20:22:03
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T08:59:44+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
//前端普通用户入口
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use common\models\Fans; //‘from’字段为ctms的数据
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\web\UploadedFile;
|
||||
use yii\helpers\Url;
|
||||
use common\models\CAttachment;
|
||||
|
||||
class ImageController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'list'=>'图片列表',
|
||||
];
|
||||
$this->result('您正使用CMTS-CLIENT图库管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
public function actionList()
|
||||
{
|
||||
$siteId =$this->site_id;
|
||||
$pid = $this->pid;
|
||||
$model = new CAttachment();
|
||||
$search = $where = [];
|
||||
$where[] = 'and';
|
||||
$where[] = ['=','status_code',1];
|
||||
$where[] = ['=','type',0];
|
||||
$where[] = ['=','siteid',$siteId];
|
||||
$where[] = ['=','pid',$pid];
|
||||
$post = $this->postdata;
|
||||
|
||||
$search = $post['search'];
|
||||
if ($search) {
|
||||
if ($search['create_m']) {
|
||||
$start = strtotime($search['create_m']);
|
||||
$s = date("Y-m-d H:i:s", $start);
|
||||
$ldm = strtotime("last day of ".$s);
|
||||
$m = date("Y-m-d", $ldm)." 23:59:59";
|
||||
$end = strtotime($m);
|
||||
$where[] = ['between','create_at',$start,$end];
|
||||
} elseif (!empty($search['create_after']) && !empty($search['create_before'])) {
|
||||
$start = strtotime($search['create_after']);
|
||||
$end = strtotime($search['create_before']);
|
||||
$where[] = ['between','create_at',$start,$end];
|
||||
} elseif (!empty($search['create_after'])) {
|
||||
$start = strtotime($search['create_after']);
|
||||
$where[] = ['>=','create_at',$start];
|
||||
} elseif (!empty($search['create_before'])) {
|
||||
$end = strtotime($search['create_before']);
|
||||
$where[] = ['<=','create_at',$end];
|
||||
}
|
||||
if ($search['title']) {
|
||||
$where[] = ['LIKE','title',$search['title']];
|
||||
}
|
||||
}
|
||||
//分页
|
||||
$orderby = ['id' => SORT_DESC];
|
||||
$Attachment = new CAttachment();
|
||||
$list = $Attachment->getData($model, $where, $orderby);
|
||||
$pager = $Attachment->getPagination();
|
||||
|
||||
//附件网址前缀
|
||||
$src = Url::base(true)."/../../upload"; //在网站根目录下使用upload/pics目录;适合使用yii框架主目录入口而非绑定子域名的情形
|
||||
if ($_SERVER['DOCUMENT_ROOT'].'/upload' != Yii::getAlias("@upload")) {
|
||||
// $src = Url::toRoute(['attach/index','img'=>'']); //换用网络加载转换的方式-反应慢
|
||||
$src = Yii::$app->params['attachSrc'].Yii::$app->params['attachDir'];
|
||||
}
|
||||
|
||||
$callback = $_GET['callback'] ?? 'thumb';
|
||||
$data = [
|
||||
'list'=>$list,
|
||||
'pager' => $pager,
|
||||
'src'=>$src,
|
||||
'callback'=>$callback
|
||||
];
|
||||
$this->result('', $data, 200);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,8 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-13T09:20:03+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T08:59:48+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
|
||||
//主入口页
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
|
||||
+707
@@ -0,0 +1,707 @@
|
||||
<?php
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use addons\models\AcCar;
|
||||
use addons\models\AcCarOwner;
|
||||
use addons\models\AcCarBrand;
|
||||
use addons\models\AcCarSeries;
|
||||
use addons\models\AcStore;
|
||||
use addons\models\AcEmployee;
|
||||
use addons\models\AcOrder;
|
||||
use addons\models\AcOrderPre;
|
||||
use addons\models\AcOrderStatus;
|
||||
use addons\models\AcTruck;
|
||||
use addons\models\AcDriver;
|
||||
use addons\models\AcPlat;
|
||||
use common\models\CVcode;
|
||||
use addons\models\AcContact;
|
||||
use common\models\Member as User;
|
||||
use addons\models\AcUserExt;
|
||||
use common\models\Fans;
|
||||
use addons\models\AcFansExt;
|
||||
|
||||
class JiaocheController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'list'=>'搜索运单',
|
||||
'detail'=>'运单详情',
|
||||
'create'=>'创建运单'
|
||||
];
|
||||
$this->result('您正使用CMTS-CLIENT交车单管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
//订单列表
|
||||
public function actionList()
|
||||
{
|
||||
$s = $this->search();
|
||||
$res = $s['res'];
|
||||
if (!$res) {
|
||||
$this->result('没有查询到相应的数据!', [], 0);
|
||||
}
|
||||
$data = $s['data'];
|
||||
$this->showOrder($res, $data);
|
||||
}
|
||||
|
||||
public function actionDetail()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$status = Yii::$app->params['OrderStatus'];
|
||||
$post = $this->postdata;
|
||||
|
||||
$id = $post['oid'] ?? 0;
|
||||
if ($id<=0) {
|
||||
$this->result('查询参数错误!');
|
||||
}
|
||||
$AcOrder = new AcOrder();
|
||||
$order = $AcOrder->findOne($id);
|
||||
$detail = $order->toArray();
|
||||
$detail['thumbs'] = $detail['thumbs'] ? json_decode($detail['thumbs']) : [];
|
||||
|
||||
$model = new AcStore();
|
||||
$store = $model->findOne($detail['store_id']);
|
||||
if ($store) {
|
||||
$detail['store_title'] = $store->title;
|
||||
}
|
||||
|
||||
$model = new AcEmployee();
|
||||
$employee = $model->findOne($detail['employee_id']);
|
||||
if ($employee) {
|
||||
$detail['employee_title'] = $employee->name;
|
||||
}
|
||||
|
||||
$detail['car_owner_id']=$detail['car_brand_id']=$detail['car_series_id']=0;
|
||||
$model = new AcCar();
|
||||
$car = $model->findOne($detail['car_id']);
|
||||
if ($car) {
|
||||
$detail['car_owner_id'] = $car->owner_id;
|
||||
$detail['car_brand_id'] = $car->brand_id;
|
||||
$detail['car_series_id'] = $car->series_id;
|
||||
$detail['car_number'] = $car->num_p.$car->num_area.$car->num_left;
|
||||
$detail['car_number'] = $detail['car_number'] ? $detail['car_number'] : $car->num_frame;
|
||||
}
|
||||
|
||||
$model = new Fans();
|
||||
$user = $model->findOne($detail['from_mid']);
|
||||
|
||||
$model = new AcFansExt();
|
||||
$exts = [];
|
||||
$_exts = $model->find()->where(['mid'=>$detail['from_mid'],'pid'=>$pid,'deleted'=>0])->indexBy('id')->all();
|
||||
foreach ($_exts as $ext) {
|
||||
$ext = $ext->toArray();
|
||||
if (isset($users[$s['id']])) {
|
||||
if ($ext['mobile']==$user->mobile) {
|
||||
$exts[$ext['mid']][$ext['key']] = $ext['value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$AcCarOwner = new AcCarOwner();
|
||||
$owner = $AcCarOwner->findOne($detail['car_owner_id']);
|
||||
if ($owner) {
|
||||
$_owner = User::findOne($detail['car_owner_id']);
|
||||
$detail['car_owner'] = $_owner->username.'【'.$_owner->mobile.'】';
|
||||
}
|
||||
|
||||
$AcCarBrand = new AcCarBrand();
|
||||
$brand = $AcCarBrand->findOne($detail['car_brand_id']);
|
||||
if ($brand) {
|
||||
$detail['car_title'] = $brand->title;
|
||||
}
|
||||
|
||||
$AcCarSeries = new AcCarSeries();
|
||||
$where = [];
|
||||
$series= $AcCarSeries->findOne($detail['car_series_id']);
|
||||
if ($series) {
|
||||
$detail['car_title'] .= $series->title;
|
||||
}
|
||||
|
||||
$sn = '00000000000'; //11位
|
||||
$sn = substr($sn, 0, 11-strlen($id));
|
||||
$sn .=$id;
|
||||
$detail['sn'] = $sn;
|
||||
|
||||
$weekdays = [0=>'日',1=>'一',2=>'二',3=>'三',4=>'四',5=>'五',6=>'六'];
|
||||
$wk = date('w', $detail['sign_date']);
|
||||
$detail['signdate'] = date('Y-m-d 星期'.$weekdays[$wk], $detail['sign_date']);
|
||||
$detail['from_province'] = isset($detail['start_province']) ? Yii::$app->params['regionAreas'][$detail['start_province']] : '';
|
||||
$detail['to_province'] = isset($detail['aim_province']) ? Yii::$app->params['regionAreas'][$detail['aim_province']] : '';
|
||||
$detail['remark'] = $detail['remark'] || '';
|
||||
$detail['remark'] = trim($detail['remark']) ? htmlspecialchars_decode(trim($detail['remark'])) : '';
|
||||
|
||||
$imgDir = Yii::getAlias('@upload');
|
||||
$imgKeys = ['driving_lisence','thumb_f','thumb_b','thumb_l','thumb_r'];
|
||||
foreach ($imgKeys as $k) {
|
||||
$detail[$k] = $detail[$k] ? $detail[$k] : '/pics/nopic.jpg';
|
||||
$url_pre = substr($detail[$k], 0, 4);
|
||||
if ($url_pre =='/pic') {
|
||||
$detail[$k.'_url'] = Url::to('@upload'.$detail[$k], $this->imgHttp);
|
||||
} elseif ($url_pre =='http') {
|
||||
$detail[$k.'_url'] = $detail[$k];
|
||||
}
|
||||
}
|
||||
|
||||
if ($detail['thumbs']) {
|
||||
$thumbs = $detail['thumbs'];
|
||||
$thumbs_url = [];
|
||||
foreach ($thumbs as $k=>$v) {
|
||||
$url_pre = substr($v, 0, 4);
|
||||
if ($url_pre =='/pic') {
|
||||
$v_url = Url::to('@upload'.$v, $this->imgHttp);
|
||||
} elseif ($url_pre =='http') {
|
||||
$v_url = $v;
|
||||
}
|
||||
$thumbs_url[] = ['src'=>$v,'url'=>$v_url];
|
||||
}
|
||||
$detail['thumbs_url'] = $thumbs_url;
|
||||
}
|
||||
|
||||
$unsets = ['commission','commission_left','fee_truck','create_at','create_by','deleted','income','expense','fee_deliver','fee_extra','fee_insurance','fee_pickup','fee_urgent','from_bid','from_mid','is_commission','is_cwqr','is_holdon','is_over','pay_receive_pids','pay_send_pids','pre_id'];
|
||||
foreach ($unsets as $us) {
|
||||
unset($detail[$us]);
|
||||
}
|
||||
|
||||
$this->result('订单查询成功!', $detail, 200);
|
||||
}
|
||||
|
||||
public function actionCreate($contactModel2)
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = $this->postdata;
|
||||
$pid = $this->pid;
|
||||
|
||||
//格式化数据 为空的项则不修改
|
||||
//目标键=》POST键
|
||||
$cols = ['start_province'=>'start_province','start_city'=>'start_city','aim_province'=>'aim_province','aim_city'=>'aim_city','aim_address'=>'aim_address',
|
||||
'signer'=>'signer','bind'=>'bind','wtdw'=>"wtdw",
|
||||
'sender_name'=>'sender_name','sender_idcard'=>'sender_idcard','sender_mobiles'=>'sender_mobiles',
|
||||
'receiver_name'=>'receiver_name','receiver_idcard'=>'receiver_idcard','receiver_mobiles'=>'receiver_mobiles',
|
||||
'car_extra'=>'car_extra'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
if (isset($post[$key]) && $post[$key] !='') {
|
||||
$data[$col] = trim($post[$key]);
|
||||
}
|
||||
}
|
||||
//'car_id'=>'car_id','employee_id'=>'employee_id',
|
||||
$cols = ['car_value'=>'car_value','fee_insurance'=>'fee_insurance','fee_truck'=>'fee_truck','fee_deliver'=>'fee_deliver','fee_pickup'=>'fee_pickup','fee_urgent'=>'fee_urgent','fee_extra'=>'fee_extra','fee_total'=>'fee_total','pay_send'=>'pay_send','pay_receive'=>'pay_receive','not_insurance'=>'not_insurance','weituo'=>'weituo'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = 0;
|
||||
if (isset($post[$key]) && $post[$key] !='') {
|
||||
$data[$col] = (int)$post[$key];
|
||||
}
|
||||
}
|
||||
|
||||
$cols = ['remark'=>'remark'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
if (isset($post[$key]) && $post[$key] !='') {
|
||||
$data[$col] = htmlspecialchars($post[$key]);
|
||||
}
|
||||
}
|
||||
$data['remark'] = $data['remark'] ?? '';
|
||||
|
||||
/*@sign_date: 1649952000000*/
|
||||
$sign_date = isset($post['sign_date']) ? $post['sign_date']/1000 : '';
|
||||
$data['sign_date'] = $sign_date ? $sign_date : TIMESTAMP;
|
||||
|
||||
// 指派运单的创建人(平台管理员ID)
|
||||
$mid = isset($post['mid']) ? (int)$post['mid'] : 0; //11是方孟
|
||||
$data['create_by'] = $mid;
|
||||
|
||||
$data['is_cwqr'] = 0; //修改财务确认状态为待确认
|
||||
$data['status_code'] = 1; //订单处于创建待审核状态
|
||||
|
||||
//关联运单前台用户;fans表
|
||||
$fid = $this->user_id;
|
||||
$data['from_mid'] = $fid;
|
||||
|
||||
//部分规则校验
|
||||
$hasError = 0;
|
||||
$msg = '';
|
||||
$fee_total = $data['fee_truck']+$data['fee_insurance']+$data['fee_deliver']+$data['fee_pickup']+$data['fee_urgent']+$data['fee_extra'];
|
||||
$fee_pay = $data['pay_send']+$data['pay_receive'];
|
||||
if (!$data['fee_truck']) {
|
||||
$hasError += 1;
|
||||
$msg .= '请注意,运费未正确填写!';
|
||||
}
|
||||
|
||||
if ($fee_total !=$data['fee_total']) {
|
||||
$hasError += 1;
|
||||
$msg .= '所填各项费用汇总的值与所填写的总费用不一致!';
|
||||
}
|
||||
if ($fee_pay !=$data['fee_total']) {
|
||||
$hasError += 1;
|
||||
$msg .= '所填现付与到收费用汇总的值与所填写的总费用不一致!';
|
||||
}
|
||||
|
||||
$data['create_at'] = time();
|
||||
$data['update_at'] = $data['create_at'];
|
||||
$data['pid'] = $pid;
|
||||
|
||||
$data['employee_id'] = isset($post['employee_id']) ? (int)$post['employee_id'] : 1; //1是宫雪
|
||||
$data['store_id'] = 0;
|
||||
$model = new AcEmployee();
|
||||
$employee = $model->findOne($data['employee_id']);
|
||||
if ($employee) {
|
||||
$data['store_id'] = $employee->store_id;
|
||||
}
|
||||
|
||||
//校验生成部分补充数据
|
||||
//生成现付说明
|
||||
$payments = [
|
||||
'wechat'=>'微信',
|
||||
'alipay'=>'支付宝',
|
||||
'cash'=>'现金',
|
||||
'bankcard'=>'银行卡',
|
||||
'bankunion'=>'银联',
|
||||
'others'=>'其他'
|
||||
];
|
||||
if ($post['pay_send']) {
|
||||
$txt = $post['payto'].'收款'.$post['pay_send'].'元('.$payments[$post['payment']].')';
|
||||
if ($data['remark']) {
|
||||
$data['remark'] .= ' ; '.$txt;
|
||||
} else {
|
||||
$data['remark'] = $txt;
|
||||
}
|
||||
}
|
||||
//生成车辆信息
|
||||
$carModel = new AcCar();
|
||||
$where = [];
|
||||
if ($post['isTempCarno']) {
|
||||
$post['carno_left'] .='临';
|
||||
}
|
||||
if (empty($post['carno_frame'])) {
|
||||
$where['num_p'] = $post['carno_p'];
|
||||
$where['num_area'] = $post['carno_area'];
|
||||
$where['num_left'] = $post['carno_left'];
|
||||
}
|
||||
$post['carno_frame'] = $post['carno_frame'] ?? '';
|
||||
if (!empty($post['carno_frame'])) {
|
||||
$where['num_frame'] = $post['carno_frame'];
|
||||
}
|
||||
$car = $carModel->find()->where($where)->one();
|
||||
if (empty($car)) {
|
||||
$carModel->pid = $pid;
|
||||
$carModel->num_frame = $post['carno_frame'];
|
||||
$carModel->num_p = $post['carno_p'];
|
||||
$carModel->num_area = $post['carno_area'];
|
||||
$carModel->num_left = $post['carno_left'];
|
||||
$carModel->title = $post['carno_title'];
|
||||
$carModel->status_code = 1;
|
||||
$carModel->create_at = TIMESTAMP;
|
||||
$carModel->update_at = TIMESTAMP;
|
||||
$carModel->save();
|
||||
$car_id = $carModel->attributes['id'];
|
||||
} else {
|
||||
$car_id = $car->id;
|
||||
}
|
||||
$data['car_id'] = $car_id;
|
||||
|
||||
//查询联系人信息是否在库
|
||||
//框架核心数据表Fans
|
||||
$userModel = new Fans();
|
||||
//项目分支自有数据表
|
||||
$contactModel = new AcContact();
|
||||
$sender_mobiles = $data['sender_mobiles'] ?? NULL;
|
||||
$receiver_mobiles = $data['receiver_mobiles'] ?? NULL;
|
||||
if ($sender_mobiles) {
|
||||
//项目分支自有数据表
|
||||
$_model = clone $contactModel;
|
||||
$contactor = $_model->find()->where(['mobile' => $data['sender_mobiles'], 'pid' => $pid])->one();
|
||||
if (empty($contactor)) {
|
||||
$_model->name = $data['sender_name'] ?? '客户';
|
||||
$_model->mobile = $data['sender_mobiles'];
|
||||
$_model->pid = $pid;
|
||||
$_model->idcard = $data['sender_idcard'] ?? '';
|
||||
$_model->create_at = TIMESTAMP;
|
||||
$_model->status_code = 1;
|
||||
$_model->save();
|
||||
} else {
|
||||
$_contactDatas = [];
|
||||
$_contactDatas['name'] = $data['sender_name'] ?? $contactor->name;
|
||||
$_contactDatas['idcard'] = $data['idcard'] ?? $contactor->idcard;
|
||||
if ($_contactDatas['name'] == $contactor->name && $_contactDatas['idcard'] == $contactor->idcard) {
|
||||
//无须做任何变化
|
||||
} else {
|
||||
$_contactDatas['update_at'] = time();
|
||||
$contactModel->updateAll($_contactDatas, ['id' => $contactor->id]);
|
||||
}
|
||||
}
|
||||
|
||||
//框架核心数据表Fans
|
||||
$_model = clone $userModel;
|
||||
$user = $_model->findByUsername($sender_mobiles);
|
||||
if (empty($user)) {
|
||||
$_model->mobile = $sender_mobiles;
|
||||
$_model->email = $sender_mobiles . '@hiluker.com';
|
||||
$_model->setPassword(Yii::$app->params['defaultFansPassword']);
|
||||
$_model->generateAuthKey();
|
||||
$_model->created_at = TIMESTAMP;
|
||||
$_model->from = Yii::$app->params['fansFrom'];;
|
||||
$_model->save();
|
||||
}
|
||||
}
|
||||
if ($receiver_mobiles && $receiver_mobiles != $sender_mobiles) {
|
||||
//项目分支自有数据表
|
||||
$_model = clone $contactModel;
|
||||
$contactor2 = $_model->find()->where(['mobile' => $data['receiver_mobiles'], 'pid' => $pid])->one();
|
||||
if (empty($contactor2)) {
|
||||
$_model->name = $data['receiver_name'] ?? '客户';
|
||||
$_model->mobile = $data['receiver_mobiles'];
|
||||
$_model->pid = $pid;
|
||||
$_model->idcard = $data['receiver_idcard'] ?? '';
|
||||
$_model->create_at = TIMESTAMP;
|
||||
$_model->status_code = 1;
|
||||
$_model->save();
|
||||
} else {
|
||||
$_contactDatas = [];
|
||||
$_contactDatas['name'] = $data['receiver_name'] ?? $contactor2->name;
|
||||
$_contactDatas['idcard'] = $data['idcard'] ?? $contactor2->idcard;
|
||||
if ($_contactDatas['name'] == $contactor2->name && $_contactDatas['idcard'] == $contactor2->idcard) {
|
||||
//无须做任何变化
|
||||
} else {
|
||||
$_contactDatas['update_at'] = time();
|
||||
$contactor2->updateAll($_contactDatas, ['id' => $contactor2->id]);
|
||||
}
|
||||
}
|
||||
//框架核心数据表Fans
|
||||
$_model = clone $userModel;
|
||||
$user = $_model->findByUsername($receiver_mobiles);
|
||||
if (empty($user)) {
|
||||
$_model->mobile = $receiver_mobiles;
|
||||
$_model->email = $receiver_mobiles . '@hiluker.com';
|
||||
$_model->setPassword(Yii::$app->params['defaultFansPassword']);
|
||||
$_model->generateAuthKey();
|
||||
$_model->created_at = TIMESTAMP;
|
||||
$_model->from = Yii::$app->params['fansFrom'];;
|
||||
$_model->save();
|
||||
}
|
||||
}
|
||||
|
||||
//保存资料
|
||||
$AcOrder = new AcOrder();
|
||||
foreach ($data as $key=>$val) {
|
||||
$AcOrder->$key = $val;
|
||||
}
|
||||
|
||||
$res = $AcOrder->save();
|
||||
$id = $AcOrder->attributes['id']; //获取插入后id
|
||||
|
||||
if ($res) {
|
||||
$return = [];
|
||||
$return['code'] = 200;
|
||||
$return['msg'] = '订单保存成功!'.$msg;
|
||||
$return['data']= ['id'=>$id];
|
||||
} else {
|
||||
$return = [];
|
||||
$return['code'] = 100;
|
||||
$return['msg'] = '订单保存失败!';
|
||||
$return['data']= [];
|
||||
}
|
||||
$this->result($return['msg'], $return['data'], $return['code']);
|
||||
}
|
||||
|
||||
//订单列表
|
||||
private function search()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$return = [];
|
||||
$model = new AcOrder();
|
||||
$where = [];
|
||||
$where[]='and';
|
||||
$where[] = ['=','pid',$pid];
|
||||
|
||||
$post = $this->postdata;
|
||||
$search = $post['search'] ?? [];
|
||||
//预置搜索条件,只允许查询与自己完全相关的订单
|
||||
$search['phone'] = $this->user_info->mobile;
|
||||
$orwhere = ['or', ['LIKE', 'sender_mobiles', $search['phone']], ['LIKE', 'receiver_mobiles', $search['phone']]];
|
||||
|
||||
//车牌号使用完整精准搜索(皖A88888)
|
||||
$CarModel = new AcCar();
|
||||
if (isset($search['carno']) && !empty($search['carno'])) {
|
||||
$search['carno'] = trim($search['carno']);
|
||||
$sql = 'CONCAT(num_p,num_area,num_left) = :carno or num_frame LIKE :carno';
|
||||
$cars = $CarModel->find()->where($sql, [':carno' => $search['carno']])->limit(5)->offset(0)->all();
|
||||
|
||||
//最多仅显示可匹配车牌号的前5个
|
||||
if (empty($cars)) {
|
||||
$return['code'] = 400;
|
||||
$return['msg'] = '未查询到相关车辆';
|
||||
return ['res'=>false,'data'=>$return];
|
||||
} else {
|
||||
$car_ids = [];
|
||||
foreach ($cars as $car) {
|
||||
$car_ids[] = $car->id;
|
||||
}
|
||||
$where[] = ['IN','car_id',$car_ids];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($search['city'])) {
|
||||
$search['city'] = trim($search['city']);
|
||||
$where[] = ['LIKE','aim_city',$search['city']];
|
||||
}
|
||||
|
||||
$search['employee'] = isset($search['employee']) ? (int)$search['employee'] : '';
|
||||
$EmployeeModel = new AcEmployee();
|
||||
if (!empty($search['employee'])) {
|
||||
$where[] = ['=','employee_id',$search['employee']];
|
||||
$employee = $EmployeeModel->findOne($search['employee']);
|
||||
$search['employee_title'] = isset($employee->name) ? $employee->name : '';
|
||||
}
|
||||
$search['store_id'] = isset($search['store_id']) ? (int)$search['store_id'] : '';
|
||||
if (empty($search['store_id'])) {
|
||||
$search['store_id'] = isset($get['store_id']) ? (int)$get['store_id'] : 0;
|
||||
}
|
||||
$StoreModel = new AcStore();
|
||||
if (!empty($search['store_id'])) {
|
||||
$where[] = ['=','store_id',$search['store_id']];
|
||||
$store = $StoreModel->findOne($search['store_id']);
|
||||
$search['store_title'] = isset($store->title) ? $store->title : '';
|
||||
}
|
||||
|
||||
$search['start_province'] = isset($search['start_province']) ? trim($search['start_province']) : '';
|
||||
if (!empty($search['start_province'])) {
|
||||
$where[] = ['=','start_province',$search['start_province']];
|
||||
}
|
||||
$search['start_city'] = isset($search['start_city']) ? trim($search['start_city']) : '';
|
||||
if (!empty($search['start_city'])) {
|
||||
$where[] = ['LIKE','start_city',$search['start_city']];
|
||||
}
|
||||
$search['aim_province'] = isset($search['aim_province']) ? trim($search['aim_province']) : '';
|
||||
if (!empty($search['aim_province'])) {
|
||||
$where[] = ['=','aim_province',$search['aim_province']];
|
||||
}
|
||||
$search['aim_city'] = isset($search['aim_city']) ? trim($search['aim_city']) : '';
|
||||
if (!empty($search['aim_city'])) {
|
||||
$where[] = ['LIKE','aim_city',$search['aim_city']];
|
||||
}
|
||||
$search['signer'] = isset($search['signer']) ? trim($search['signer']) : '';
|
||||
$search['wtdw'] = isset($search['wtdw']) ? trim($search['wtdw']) : '';
|
||||
$search['weituo'] = isset($search['weituo']) ? (int)$search['weituo'] : 0;
|
||||
if ($search['weituo']) {
|
||||
$where[] = ['=','weituo',$search['weituo']];
|
||||
} elseif (!empty($search['wtdw'])) {
|
||||
$where[] = ['LIKE','wtdw',$search['wtdw']];
|
||||
} elseif (!empty($search['signer'])) {
|
||||
$where[] = ['LIKE','signer',$search['signer']];
|
||||
}
|
||||
|
||||
$search['sender_name'] = isset($search['sender_name']) ? trim($search['sender_name']) : '';
|
||||
if (!empty($search['sender_name'])) {
|
||||
$where[] = ['LIKE','sender_name',$search['sender_name']];
|
||||
}
|
||||
$search['receiver_name'] = isset($search['receiver_name']) ? trim($search['receiver_name']) : '';
|
||||
if (!empty($search['receiver_name'])) {
|
||||
$where[] = ['LIKE','receiver_name',$search['receiver_name']];
|
||||
}
|
||||
$search['bind'] = isset($search['bind']) ? trim($search['bind']) : '';
|
||||
if (!empty($search['bind'])) {
|
||||
$where[] = ['LIKE','bind',$search['bind']];
|
||||
}
|
||||
if (isset($search['status_code']) && $search['status_code'] !='all') {
|
||||
$search['status_code'] = (int)$search['status_code'];
|
||||
$where[] = ['=','status_code',$search['status_code']];
|
||||
} else {
|
||||
unset($search['status_code']);
|
||||
}
|
||||
|
||||
if (isset($search['is_holdon'])) {
|
||||
$search['is_holdon'] = (int)$search['is_holdon'];
|
||||
$where[] = ['=','is_holdon',$search['is_holdon']];
|
||||
}
|
||||
if (isset($search['is_over'])) {
|
||||
$search['is_over'] = (int)$search['is_over'];
|
||||
$where[] = ['=','is_over',$search['is_over']];
|
||||
}
|
||||
if (isset($search['is_commission'])) {
|
||||
$search['is_commission'] = (int)$search['is_commission'];
|
||||
$where[] = ['=','is_commission',$search['is_commission']];
|
||||
}
|
||||
//运单是否通过了财务确认
|
||||
$search['is_cwqr'] = $search['is_cwqr'] ?? ($get['is_cwqr'] ?? '');
|
||||
if ($search['is_cwqr'] !='') {
|
||||
$search['is_cwqr'] = (int)$search['is_cwqr'];
|
||||
$where[] = ['=','is_cwqr',$search['is_cwqr']];
|
||||
}
|
||||
|
||||
//签约时间筛选
|
||||
$search['sign_m'] = isset($search['sign_m']) ? $search['sign_m'] : '';
|
||||
$search['sign_after'] = isset($search['sign_after']) ? $search['sign_after'] : '';
|
||||
$search['sign_before'] = isset($search['sign_before']) ? $search['sign_before'] : '';
|
||||
//按月份筛选
|
||||
if (!empty($search['sign_m'])) {
|
||||
$start = strtotime($search['sign_m']);
|
||||
$s = date("Y-m-d H:i:s", $start);
|
||||
$ldm = strtotime("last day of ".$s);
|
||||
$m = date("Y-m-d", $ldm)." 23:59:59";
|
||||
$end = strtotime($m);
|
||||
$where[] = ['between','sign_date',$start,$end];
|
||||
}
|
||||
//按指定时段筛选
|
||||
elseif (!empty($search['sign_after']) && !empty($search['sign_before'])) {
|
||||
$start = strtotime($search['sign_after']);
|
||||
$end = strtotime($search['sign_before']);
|
||||
$where[] = ['between','sign_date',$start,$end];
|
||||
}
|
||||
//按指定时间临界点筛选(以不早于为优先筛选条件)
|
||||
elseif (!empty($search['sign_after'])) {
|
||||
$start = strtotime($search['sign_after']);
|
||||
$where[] = ['>=','sign_date',$start];
|
||||
} elseif (!empty($search['sign_before'])) {
|
||||
$end = strtotime($search['sign_before']);
|
||||
$where[] = ['<=','sign_date',$end];
|
||||
}
|
||||
|
||||
//带序列号搜索(TBD:后期考虑改为精准唯一搜索)
|
||||
if (isset($search['sn']) && $search['sn'] != 'undefined' && $search['sn']) {
|
||||
$where[] = ['LIKE','sn',$search['sn']];
|
||||
}
|
||||
|
||||
$deleted = 0;
|
||||
$where[]=['=','deleted',$deleted];
|
||||
$where[]=['=','is_turnover',1]; //交车单
|
||||
|
||||
$page = $this->page;
|
||||
$pageSize = $this->pageSize;
|
||||
$data = $model->find()->where($where)->andwhere($orwhere);
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => $pageSize]);
|
||||
$pages->setPage($page-1, true); //设置分页的当前页面值
|
||||
$_orderby = 'sign_date DESC,id DESC';
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby($_orderby)->all();
|
||||
|
||||
return ['res'=>$res,'data'=>$data];
|
||||
}
|
||||
|
||||
/*
|
||||
订单数据显示格式化
|
||||
*/
|
||||
private function showOrder($orderRes, $data)
|
||||
{
|
||||
$status = Yii::$app->params['OrderStatus'];
|
||||
|
||||
$cids = $sids = $eids = $mids = [];
|
||||
if ($orderRes) {
|
||||
foreach ($orderRes as $r) {
|
||||
$cids[$r->car_id] = $r->car_id;
|
||||
$sids[$r->store_id] = $r->store_id;
|
||||
$eids[$r->employee_id] = $r->employee_id;
|
||||
$mids[$r->from_mid] = $r->from_mid;
|
||||
}
|
||||
}
|
||||
|
||||
$model = new AcStore();
|
||||
$where = [];
|
||||
$where['pid'] = $this->pid;
|
||||
$_stores = $model->find()->where(['in','id',$sids])->all();
|
||||
$stores = [];
|
||||
foreach ($_stores as $s) {
|
||||
$stores[$s->id] = $s->toArray();
|
||||
}
|
||||
|
||||
$model = new AcEmployee();
|
||||
$employees = [];
|
||||
$_employees = $model->find()->where(['in','id',$eids])->indexBy('id')->all();
|
||||
foreach ($_employees as $s) {
|
||||
$employees[$s->id] = $s->toArray();
|
||||
}
|
||||
|
||||
$model = new Fans();
|
||||
$users = [];
|
||||
$_users = $model->find()->where(['in','id',$mids])->all();
|
||||
foreach ($_users as $s) {
|
||||
$s = $s->toArray();
|
||||
$users[$s['id']] = $s;
|
||||
}
|
||||
|
||||
$model = new AcCar();
|
||||
$cars = [];
|
||||
$_cars = $model->find()->where(['in','id',$cids])->indexBy('id')->all();
|
||||
$bids = $sids =[];
|
||||
foreach ($_cars as $s) {
|
||||
$bids[] = $s->brand_id;
|
||||
$sids[] = $s->series_id;
|
||||
$cars[$s->id] = $s->toArray();
|
||||
}
|
||||
unset($s);
|
||||
|
||||
$model = new AcCarBrand();
|
||||
$brands = $model->find()->where(['in','id',$bids])->indexBy('id')->all();
|
||||
$model = new AcCarSeries();
|
||||
$series = $model->find()->where(['in','id',$sids])->indexBy('id')->all();
|
||||
|
||||
if ($cars) {
|
||||
foreach ($cars as &$car) {
|
||||
$car['title2'] = '';
|
||||
if (isset($brands[$car['brand_id']])) {
|
||||
$car['title2'] .= $brands[$car['brand_id']]['title'];
|
||||
}
|
||||
if (isset($series[$car['series_id']])) {
|
||||
$car['title2'] .= $series[$car['series_id']]['title'];
|
||||
}
|
||||
$car['number2'] = $car['num_frame'];
|
||||
if ($car['num_p']) {
|
||||
$car['number2'] = $car['num_p'];
|
||||
}
|
||||
if ($car['num_area']) {
|
||||
$car['number2'] .= $car['num_area'];
|
||||
}
|
||||
if ($car['num_left']) {
|
||||
$car['number2'] .= $car['num_left'];
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($car);
|
||||
|
||||
$orders = [];
|
||||
$unsets = ['pid','commission','commission_left','fee_truck','create_at','create_by','deleted','income','expense','fee_deliver','fee_extra','fee_insurance','fee_pickup','fee_urgent','from_bid','from_mid','is_commission','is_cwqr','is_holdon','is_over','pay_receive_pids','pay_send_pids','pre_id','remark','car_extra','thumb_b','thumb_f','thumb_l','thumb_r','thumbs','driving_lisence','videos'];
|
||||
|
||||
foreach ($orderRes as $s) {
|
||||
$car = [];
|
||||
if ($s->car_id) {
|
||||
$car = $cars[$s->car_id];
|
||||
}
|
||||
$s = $s->toArray();
|
||||
foreach ($unsets as $us) {
|
||||
unset($s[$us]);
|
||||
}
|
||||
$weekdays = [0=>'日',1=>'一',2=>'二',3=>'三',4=>'四',5=>'五',6=>'六'];
|
||||
$wk = date('w', $s['sign_date']);
|
||||
$s['signdate'] = date('Y-m-d ', $s['sign_date']) . '星期'.$weekdays[$wk];
|
||||
$s['from_province'] = $s['start_province'] ? Yii::$app->params['regionAreas'][$s['start_province']] : '';
|
||||
$s['to_province'] = $s['aim_province'] ? Yii::$app->params['regionAreas'][$s['aim_province']] : '';
|
||||
$s['car_number'] = $car['number2'] ?? '';
|
||||
$s['car_title'] = $car['title'] ?? '';
|
||||
$s['car_title'] = $s['car_title'] ? $s['car_title'] : ($car['title2'] ?? '');
|
||||
$s['status'] = $status[$s['status_code']];
|
||||
$orders[] = $s;
|
||||
}
|
||||
unset($s);
|
||||
|
||||
$return = [];
|
||||
$return['code'] = 200;
|
||||
$return['msg'] = '订单查询成功!';
|
||||
$return['data']= [
|
||||
'total'=>$data->count(),
|
||||
'orders' => $orders,
|
||||
'employees'=>$employees,
|
||||
'stores'=>$stores,
|
||||
'users'=>$users,
|
||||
'page'=>$this->page
|
||||
];
|
||||
$this->result($return['msg'], $return['data'], $return['code']);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,6 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2024-08-03T15:34:01+08:00
|
||||
# @Email: 1280880631@qq.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T09:00:02+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use addons\models\AcNews;
|
||||
use addons\models\AcNewsCat;
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2024-08-03T16:38:33+08:00
|
||||
# @Email: 1280880631@qq.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T08:59:58+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2024-08-02T01:08:31+08:00
|
||||
# @Email: 1280880631@qq.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T09:00:06+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use addons\models\AcNotice;
|
||||
use yii\data\Pagination;
|
||||
use addons\models\AcNotice;
|
||||
use yii\data\Pagination;
|
||||
|
||||
class NoticeController extends Common
|
||||
{
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use vendor\huawei\obsclient\Hwobs;
|
||||
use vendor\huawei\obsclient\TemporarySignature;
|
||||
use vendor\huawei\obsclient\PostObject;
|
||||
|
||||
class ObsController extends Common
|
||||
{
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'getkey'=>'获取访问Key',
|
||||
];
|
||||
$this->result('您正使用CMTS系统-华为云OBS接口(尚未开启)!', $apis, 200);
|
||||
}
|
||||
|
||||
private function getconf()
|
||||
{
|
||||
return [
|
||||
'id'=> 'ee124c5102064b83bccd2fdda53261cc', //账号ID
|
||||
'ak'=> '1DYBXUNEPNCIEEQOGGAE',
|
||||
'sk'=> '0VBI2xPlDB0NtqqVJv3hSFC8DY52G8OYPYNhncGK',
|
||||
'area'=>'cn-south-1', //华南广州
|
||||
'endpoint'=>'obs.cn-south-1.myhuaweicloud.com',
|
||||
'bucketName'=>'hilu-ctms',
|
||||
];
|
||||
}
|
||||
|
||||
public function actionGetkey()
|
||||
{
|
||||
$params = $this->getconf();
|
||||
$obs = new Hwobs($ak=$params['ak'], $sk=$params['sk'], $endpoint=$params['endpoint'], $t1=30, $t2=10);
|
||||
}
|
||||
|
||||
public function actionGeturl()
|
||||
{
|
||||
$params = $this->getconf();
|
||||
$obs = new TemporarySignature($ak=$params['ak'], $sk=$params['sk'], $endpoint=$params['endpoint'], $t1=30, $t2=10);
|
||||
$res = $obs->UploadUrl($params['bucketName']);
|
||||
// $res = $obs->getCors($params['bucketName']);
|
||||
var_dump($res);
|
||||
// $this->result('获取上传网址成功!', $res, 200);
|
||||
}
|
||||
|
||||
public function actionGetform()
|
||||
{
|
||||
$params = $this->getconf();
|
||||
$obs = new PostObject($ak=$params['ak'], $sk=$params['sk'], $endpoint=$params['endpoint'], $t1=30, $t2=10);
|
||||
$obs->init('obs');
|
||||
$res = $obs->claimPost('hilu-ctms', 'file.jpg');
|
||||
$url = 'https://'.$params['bucketName'].".".$params['endpoint'];
|
||||
$res['up_url'] = $url;
|
||||
$this->result('获取OBS上传准备信息!', $res, 200);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,6 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-04-24T20:28:47+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T09:00:15+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-04-24T20:28:47+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T09:00:10+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-04-24T20:28:47+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T09:00:19+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use addons\models\AcEmployee;
|
||||
use addons\models\AcOrderPre;
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-22T07:38:52+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T08:53:58+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use vendor\aliyun\dysms\Sms;
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use addons\models\AcStore;
|
||||
|
||||
class StoreController extends Common
|
||||
{
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'list'=>'网点清单',
|
||||
'detail'=>'网点详情'
|
||||
];
|
||||
$this->result('您正使用CMTS系统网点管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
public function actionList()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$model = new AcStore();
|
||||
$where = [];
|
||||
$where['pid'] = $pid;
|
||||
$citys = Yii::$app->params['citys'];
|
||||
$post = $this->postdata;
|
||||
|
||||
$where['deleted'] = 0;
|
||||
$where['status_code'] = 1;
|
||||
$data = $model->find()->where($where);
|
||||
|
||||
$page = $this->page;
|
||||
$pageSize = $this->pageSize;
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => $pageSize]);
|
||||
$pages->setPage($page-1, true); //设置分页的当前页面值
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
|
||||
if (!$res) {
|
||||
$this->result('没有符合条件的结果');
|
||||
}
|
||||
$stores = [];
|
||||
foreach ($res as $k=>$v) {
|
||||
$stores[$v->id] = $v->toArray();
|
||||
}
|
||||
$return = [];
|
||||
$return['data'] = [
|
||||
'stores'=>$stores,
|
||||
'citys'=>$citys,
|
||||
];
|
||||
$return['total'] = $data->count();
|
||||
$return['page'] = $this->page;
|
||||
$this->result('网点列表', $return, 200);
|
||||
}
|
||||
|
||||
public function actionSelect()
|
||||
{
|
||||
$model = new AcStore();
|
||||
$where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$citys = Yii::$app->params['citys'];
|
||||
$post = Yii::$app->request->post();
|
||||
|
||||
$where['deleted'] = 0;
|
||||
$where['status_code'] = 1;
|
||||
$data = $model->find()->where($where);
|
||||
$search = [];
|
||||
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
|
||||
if (!empty($search['title'])) {
|
||||
$where2 = ['LIKE','title',$search['title']];
|
||||
$data = $data->andwhere($where2);
|
||||
}
|
||||
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
|
||||
$status = ['0'=>'隐藏','1'=>'正常'];
|
||||
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'store';
|
||||
return $this->render('select', [
|
||||
'stores'=>$res,
|
||||
'pager' => $pages,
|
||||
'citys'=>$citys,
|
||||
'status'=>$status,
|
||||
'search'=>$search,
|
||||
'callback'=>$callback
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,373 @@
|
||||
<?php
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\web\UploadedFile;
|
||||
use common\models\CAttachment;
|
||||
use backend\controllers\Common;
|
||||
|
||||
class UploadController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'image'=>'上传图片(单传)',
|
||||
'images'=>'上传图片(多传)',
|
||||
];
|
||||
$this->result('您正使用CMTS系统文件上传接口!', $apis, 200);
|
||||
}
|
||||
|
||||
public function actionImage()
|
||||
{
|
||||
$post = $this->postdata;
|
||||
$model = new CAttachment();
|
||||
$file = UploadedFile::getInstanceByName('file');
|
||||
//{error: 0
|
||||
// name: "e8.png"
|
||||
// size: 5362
|
||||
// tempName: "/Applications/XAMPP/xamppfiles/temp/phpG8vgnV"
|
||||
// type: "image/png"}
|
||||
// 构建目录
|
||||
$attachDir = Yii::getAlias('@upload'); //附件所在目录
|
||||
|
||||
$targetDir = "/pics"; //开始构建目标转存目录
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$siteId = $this->site_id;
|
||||
$targetDir .= '/'.$siteId;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$pid = $this->pid;
|
||||
$targetDir .= '/'.$pid;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$timeDir = date('Ym');
|
||||
$targetDir .= "/".$timeDir;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
//处理请求的文件信息
|
||||
$title = isset($file->name) ? $file->name : md5(TIMESTAMP.rand(1, 99)).'.jpg'; //文件原名
|
||||
//取后缀名
|
||||
$_filetype = explode('/', $file->type);
|
||||
$suffix = strtolower($_filetype[1]);
|
||||
//重新命名以便转存
|
||||
$newName = date('dHis', TIMESTAMP).'_'.md5($title);
|
||||
$newFile = $attachDir . $targetDir."/".$newName.".".$suffix;
|
||||
|
||||
$res = $file->saveAs($newFile, true);
|
||||
|
||||
//文件入库
|
||||
//POST数据处理
|
||||
$member_id = 0;
|
||||
if (isset($post['mid']) && (int)$post['mid']>0) {
|
||||
$member_id = (int)$post['mid'];
|
||||
}
|
||||
$options = '';
|
||||
if (isset($post['options'])) {
|
||||
$options = json_encode($options, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT);
|
||||
}
|
||||
$model = new CAttachment();
|
||||
$model->siteid = $siteId;
|
||||
$model->pid = $this->pid;
|
||||
$model->uid = $this->user_id;
|
||||
$model->mid = $member_id;
|
||||
$model->type = 0; //附件类型,0图片1视频2音频3表格4文档5PPT888证书999其他
|
||||
$model->status_code = 1;
|
||||
$model->title = $title;
|
||||
$model->filesize = $file->size;
|
||||
$model->route = $targetDir."/".$newName.".".$suffix;
|
||||
$model->options = $options;
|
||||
$model->update_at = $model->create_at = time();
|
||||
$model->save();
|
||||
$id = $model->attributes['id']; //获取插入后id
|
||||
$this->result('上传成功', ['id'=>$id,'path'=>$model->route], 200);
|
||||
}
|
||||
|
||||
public function actionImages()
|
||||
{
|
||||
$post = $this->postdata;
|
||||
$model = new CAttachment();
|
||||
$files = UploadedFile::getInstancesByName('files');
|
||||
// 构建目录
|
||||
$attachDir = Yii::getAlias('@upload'); //附件所在目录
|
||||
|
||||
$targetDir = "/pics"; //开始构建目标转存目录
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$siteId = $this->site_id;
|
||||
$targetDir .= '/'.$siteId;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$pid = $this->pid;
|
||||
$targetDir .= '/'.$pid;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$timeDir = date('Ym');
|
||||
$targetDir .= "/".$timeDir;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
//处理请求的文件信息
|
||||
//POST数据处理
|
||||
$member_id = 0;
|
||||
if (isset($post['mid']) && (int)$post['mid']>0) {
|
||||
$member_id = (int)$post['mid'];
|
||||
}
|
||||
$options = '';
|
||||
if (isset($post['options'])) {
|
||||
$options = json_encode($options, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT);
|
||||
}
|
||||
|
||||
$attachModel = new CAttachment();
|
||||
$ids = $paths = $datas = [];
|
||||
foreach ($files as $file) {
|
||||
$tkey = microtime();
|
||||
$title = isset($file->name) ? $file->name : md5($tkey.rand(1, 99)).'.jpg'; //文件原名
|
||||
//取后缀名
|
||||
$_filetype = explode('/', $file->type);
|
||||
$suffix = strtolower($_filetype[1]);
|
||||
//重新命名以便转存
|
||||
$newName = date('dHis', TIMESTAMP).'_'.md5($title);
|
||||
$newFile = $attachDir . $targetDir."/".$newName.".".$suffix;
|
||||
|
||||
$res = $file->saveAs($newFile, true);
|
||||
|
||||
//文件入库
|
||||
$model = clone $attachModel;
|
||||
$model->siteid = $siteId;
|
||||
$model->pid = $this->pid;
|
||||
$model->uid = $this->user_id;
|
||||
$model->mid = $member_id;
|
||||
$model->type = 0; //附件类型,0图片1视频2音频3表格4文档5PPT888证书999其他
|
||||
$model->status_code = 1;
|
||||
$model->title = $title;
|
||||
$model->filesize = $file->size;
|
||||
$model->route = $targetDir."/".$newName.".".$suffix;
|
||||
$model->options = $options;
|
||||
$model->update_at = $model->create_at = time();
|
||||
$model->save();
|
||||
$id = $model->attributes['id']; //获取插入后id
|
||||
$ids[$id] = $id;
|
||||
$paths[$id] = $model->route;
|
||||
}
|
||||
|
||||
$this->result('上传成功', ['ids'=>$ids,'paths'=>$paths], 200);
|
||||
}
|
||||
|
||||
public function save_image()
|
||||
{
|
||||
$post = Yii::$app->request->post();
|
||||
$model = new CAttachment();
|
||||
$files = UploadedFile::getInstanceByName('files');
|
||||
//{error: 0
|
||||
// name: "e8.png"
|
||||
// size: 5362
|
||||
// tempName: "/Applications/XAMPP/xamppfiles/temp/phpG8vgnV"
|
||||
// type: "image/png"}
|
||||
// 构建目录
|
||||
$attachDir = Yii::getAlias('@upload'); //附件所在目录
|
||||
|
||||
$targetDir = "/pics"; //开始构建目标转存目录
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$siteId = $this->site_id;
|
||||
$targetDir .= '/'.$siteId;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$pid = $this->pid;
|
||||
$targetDir .= '/'.$pid;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$timeDir = date('Ym');
|
||||
$targetDir .= "/".$timeDir;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
//处理请求的文件信息
|
||||
$title = isset($file->name) ? $file->name : md5(TIMESTAMP.rand(1, 99)).'.jpg'; //文件原名
|
||||
//取后缀名
|
||||
$_filetype = explode('/', $file->type);
|
||||
$suffix = strtolower($_filetype[1]);
|
||||
//重新命名以便转存
|
||||
$newName = date('dHis', TIMESTAMP).'_'.md5($title);
|
||||
$newFile = $attachDir . $targetDir."/".$newName.".".$suffix;
|
||||
|
||||
$res = $file->saveAs($newFile, true);
|
||||
|
||||
//文件入库
|
||||
//POST数据处理
|
||||
$post = Yii::$app->request->post();
|
||||
$member_id = 0;
|
||||
if (isset($post['mid']) && (int)$post['mid']>0) {
|
||||
$member_id = (int)$post['mid'];
|
||||
}
|
||||
$options = '';
|
||||
if (isset($post['options'])) {
|
||||
$options = json_encode($options, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT);
|
||||
}
|
||||
$model = new CAttachment();
|
||||
$model->siteid = $siteId;
|
||||
$model->pid = $this->pid;
|
||||
$model->uid = $this->user_id;
|
||||
$model->mid = $member_id;
|
||||
$model->type = 0; //附件类型,0图片1视频2音频3表格4文档5PPT888证书999其他
|
||||
$model->status_code = 1;
|
||||
$model->title = $title;
|
||||
$model->filesize = $file->size;
|
||||
$model->route = $targetDir."/".$newName.".".$suffix;
|
||||
$model->options = $options;
|
||||
$model->update_at = $model->create_at = time();
|
||||
$model->save();
|
||||
$id = $model->attributes['id']; //获取插入后id
|
||||
$this->result('上传成功', ['id'=>$id,'path'=>$model->route], 200);
|
||||
}
|
||||
}
|
||||
|
||||
/*多图上传时的数据示例
|
||||
array(7) {
|
||||
[0]=>
|
||||
object(yii\web\UploadedFile)#60 (6) {
|
||||
["name"]=>
|
||||
string(18) "file-1652511550195"
|
||||
["tempName"]=>
|
||||
string(45) "/Applications/XAMPP/xamppfiles/temp/phpJvR1FV"
|
||||
["type"]=>
|
||||
string(9) "text/html"
|
||||
["size"]=>
|
||||
int(425)
|
||||
["error"]=>
|
||||
int(0)
|
||||
["_tempResource":"yii\web\UploadedFile":private]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
[1]=>
|
||||
object(yii\web\UploadedFile)#62 (6) {
|
||||
["name"]=>
|
||||
string(18) "file-1652511550195"
|
||||
["tempName"]=>
|
||||
string(45) "/Applications/XAMPP/xamppfiles/temp/phpzIuYVB"
|
||||
["type"]=>
|
||||
string(9) "text/html"
|
||||
["size"]=>
|
||||
int(425)
|
||||
["error"]=>
|
||||
int(0)
|
||||
["_tempResource":"yii\web\UploadedFile":private]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
[2]=>
|
||||
object(yii\web\UploadedFile)#63 (6) {
|
||||
["name"]=>
|
||||
string(18) "file-1652511550195"
|
||||
["tempName"]=>
|
||||
string(45) "/Applications/XAMPP/xamppfiles/temp/phpUHXR4W"
|
||||
["type"]=>
|
||||
string(9) "text/html"
|
||||
["size"]=>
|
||||
int(425)
|
||||
["error"]=>
|
||||
int(0)
|
||||
["_tempResource":"yii\web\UploadedFile":private]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
[3]=>
|
||||
object(yii\web\UploadedFile)#64 (6) {
|
||||
["name"]=>
|
||||
string(18) "file-1652511550195"
|
||||
["tempName"]=>
|
||||
string(45) "/Applications/XAMPP/xamppfiles/temp/phpEa5Q93"
|
||||
["type"]=>
|
||||
string(9) "text/html"
|
||||
["size"]=>
|
||||
int(425)
|
||||
["error"]=>
|
||||
int(0)
|
||||
["_tempResource":"yii\web\UploadedFile":private]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
[4]=>
|
||||
object(yii\web\UploadedFile)#65 (6) {
|
||||
["name"]=>
|
||||
string(18) "file-1652511550195"
|
||||
["tempName"]=>
|
||||
string(45) "/Applications/XAMPP/xamppfiles/temp/phpEDfHIr"
|
||||
["type"]=>
|
||||
string(9) "text/html"
|
||||
["size"]=>
|
||||
int(425)
|
||||
["error"]=>
|
||||
int(0)
|
||||
["_tempResource":"yii\web\UploadedFile":private]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
[5]=>
|
||||
object(yii\web\UploadedFile)#66 (6) {
|
||||
["name"]=>
|
||||
string(18) "file-1652511550195"
|
||||
["tempName"]=>
|
||||
string(45) "/Applications/XAMPP/xamppfiles/temp/phpiLqBVZ"
|
||||
["type"]=>
|
||||
string(9) "text/html"
|
||||
["size"]=>
|
||||
int(425)
|
||||
["error"]=>
|
||||
int(0)
|
||||
["_tempResource":"yii\web\UploadedFile":private]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
[6]=>
|
||||
object(yii\web\UploadedFile)#67 (6) {
|
||||
["name"]=>
|
||||
string(18) "file-1652511550195"
|
||||
["tempName"]=>
|
||||
string(45) "/Applications/XAMPP/xamppfiles/temp/php5rqzIk"
|
||||
["type"]=>
|
||||
string(9) "text/html"
|
||||
["size"]=>
|
||||
int(425)
|
||||
["error"]=>
|
||||
int(0)
|
||||
["_tempResource":"yii\web\UploadedFile":private]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use addons\models\AcWeituoren;
|
||||
use common\models\Member as User;
|
||||
use addons\models\AcUserExt;
|
||||
|
||||
class WeituorenController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
// $this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'list'=>'搜索委托单位清单',
|
||||
'detail'=>'委托单位详情'
|
||||
];
|
||||
$this->result('您正使用CMTS系统委托单位管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
//列表
|
||||
public function actionList()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$return = [];
|
||||
$model = new AcWeituoren();
|
||||
$where = $where2 = [];
|
||||
$where2[]='and';
|
||||
$where['pid'] = $pid;
|
||||
$post = $this->postdata;
|
||||
$search = isset($post['search']) ? $post['search'] : null;
|
||||
if (!$search) {
|
||||
$search = [];
|
||||
}
|
||||
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
|
||||
if (!empty($search['title'])) {
|
||||
$where2[] = ['LIKE','company',$search['title']];
|
||||
}
|
||||
$where['deleted'] = 0;
|
||||
$data = $model->find()->asArray()->where($where); //asArray() 放在find后,可让查询结果以数组形式呈现
|
||||
if ($search['title']) {
|
||||
$data = $data->andwhere($where2);
|
||||
}
|
||||
|
||||
$page = $this->page;
|
||||
$pageSize = $this->pageSize;
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => $pageSize]);
|
||||
$pages->setPage($page-1, true); //设置分页的当前页面值
|
||||
$_orderby = 'orderby DESC,id ASC';
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby($_orderby)->all();
|
||||
if (!$res) {
|
||||
$this->result('没有符合条件的结果');
|
||||
}
|
||||
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
$return['code'] = 200;
|
||||
$return['msg'] = '委托单位查询成功!';
|
||||
$return['data']= ['total'=>$data->count(),
|
||||
'data'=>[
|
||||
'weituoren' => $res
|
||||
],
|
||||
'page'=>$this->page];
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
|
||||
}
|
||||
|
||||
public function actionDetail()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$post = $this->postdata;
|
||||
|
||||
$id = isset($post['id']) ? $post['id'] : 0;
|
||||
if ($id<=0) {
|
||||
$this->result('查询参数错误!');
|
||||
}
|
||||
$model = new AcWeituoren();
|
||||
$weituo = $model->findOne($id);
|
||||
$detail = $weituo->toArray();
|
||||
|
||||
$this->result('查询成功!', $detail, 200);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user