优化ctms-api语法、修复已知BUG;
主要修复ctms-api、dacms对PHP新版本的支持问题
This commit is contained in:
@@ -4,10 +4,10 @@
|
||||
# @Date: 2022-04-24T20:28:47+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-07-13T14:23:16+08:00
|
||||
# @Last modified time: 2024-08-09T09:00:19+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers\client\v1;
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use addons\models\AcEmployee;
|
||||
use addons\models\AcOrderPre;
|
||||
@@ -20,7 +20,7 @@ class OrderpreController extends Common
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
@@ -40,8 +40,8 @@ class OrderpreController extends Common
|
||||
{
|
||||
$s = $this->search();
|
||||
$res = $s['res'];
|
||||
if(!$res){
|
||||
$this->result('没有查询到相应的数据!',[],0);
|
||||
if (!$res) {
|
||||
$this->result('没有查询到相应的数据!', [], 0);
|
||||
}
|
||||
$data = $s['data'];
|
||||
$this->showOrder($res, $data);
|
||||
@@ -55,14 +55,14 @@ class OrderpreController extends Common
|
||||
$where = $orwhere = [];
|
||||
$where[]='and';
|
||||
$where[] = ['=','pid',$pid];
|
||||
|
||||
|
||||
$post = $this->postdata;
|
||||
$search = isset($post['search']) ? $post['search'] : [];
|
||||
//预置搜索条件,只允许查询与自己完全相关的订单
|
||||
$where[] = ['=','from_uid',$this->user_id];
|
||||
//预置搜索条件,只允许查询与自己完全相关的订单
|
||||
$where[] = ['=', 'from_uid', $this->user_id];
|
||||
$search['phone'] = $this->user_info->mobile;
|
||||
$where[] = ['=','from_mobile',$search['phone']];
|
||||
|
||||
$where[] = ['=', 'from_mobile', $search['phone']];
|
||||
|
||||
if (isset($search['carno']) && !empty($search['carno'])) {
|
||||
$search['carno'] = trim($search['carno']);
|
||||
$where[] = ['LIKE','car_no',$search['carno']];
|
||||
@@ -94,7 +94,7 @@ class OrderpreController extends Common
|
||||
$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']];
|
||||
@@ -111,7 +111,7 @@ class OrderpreController extends Common
|
||||
if (!empty($search['aim_city'])) {
|
||||
$where[] = ['LIKE','aim_city',$search['aim_city']];
|
||||
}
|
||||
|
||||
|
||||
$search['bind'] = isset($search['bind']) ? trim($search['bind']) : '';
|
||||
if (!empty($search['bind'])) {
|
||||
$where[] = ['LIKE','bind',$search['bind']];
|
||||
@@ -215,23 +215,23 @@ class OrderpreController extends Common
|
||||
$AcOrderPre = new AcOrderPre();
|
||||
$order = $AcOrderPre->findOne($id);
|
||||
$detail = $order->toArray();
|
||||
|
||||
if($detail['store_id']){
|
||||
|
||||
if ($detail['store_id']) {
|
||||
$model = new AcStore();
|
||||
$store = $model->findOne($detail['store_id']);
|
||||
if ($store) {
|
||||
$detail['store_title'] = $store->title;
|
||||
}
|
||||
}
|
||||
|
||||
if($detail['employee_id']){
|
||||
|
||||
if ($detail['employee_id']) {
|
||||
$model = new AcEmployee();
|
||||
$employee = $model->findOne($detail['employee_id']);
|
||||
if ($employee) {
|
||||
$detail['employee_title'] = $employee->name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$sn = '00000000000'; //11位
|
||||
$sn = substr($sn, 0, 11-strlen($id));
|
||||
$sn .=$id;
|
||||
@@ -262,10 +262,10 @@ class OrderpreController extends Common
|
||||
}
|
||||
$AcOrderPre = new AcOrderPre();
|
||||
$order = $AcOrderPre->findOne($id);
|
||||
if($order->from_uid != $this->user_id){
|
||||
if ($order->from_uid != $this->user_id) {
|
||||
$this->result('非本人订单,不允许操作!');
|
||||
}
|
||||
if($order->status_code <= 0 || $order->status_code >= 99 ){
|
||||
if ($order->status_code <= 0 || $order->status_code >= 99) {
|
||||
$this->result('订单已取消或已经完成,不允许操作!');
|
||||
}
|
||||
$order->status_code = -1;
|
||||
@@ -297,7 +297,7 @@ class OrderpreController extends Common
|
||||
$data[$col] = trim($post[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$cols = ['car_value'=>'car_value','from_gender'=>'from_gender'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = 0;
|
||||
@@ -319,7 +319,7 @@ class OrderpreController extends Common
|
||||
|
||||
$mid = isset($post['mid']) ? (int)$post['mid'] : 0 ;
|
||||
$data['from_mid'] = $mid;
|
||||
|
||||
|
||||
$data['status_code'] = 1; //订单处于创建待审核状态
|
||||
|
||||
$data['create_at'] = time();
|
||||
@@ -328,7 +328,7 @@ class OrderpreController extends Common
|
||||
|
||||
$data['employee_id'] = isset($post['employee_id']) ? (int)$post['employee_id'] : 0;
|
||||
$data['store_id'] = isset($post['store_id']) ? (int)$post['store_id'] : 0;
|
||||
|
||||
|
||||
//保存资料
|
||||
$AcOrderPre = new AcOrderPre();
|
||||
foreach ($data as $key=>$val) {
|
||||
@@ -339,9 +339,9 @@ class OrderpreController extends Common
|
||||
$id = $AcOrderPre->attributes['id']; //获取插入后id
|
||||
|
||||
if ($res) {
|
||||
$this->result('询单保存成功!',['id'=>$id],200);
|
||||
$this->result('询单保存成功!', ['id' => $id], 200);
|
||||
} else {
|
||||
$this->result('询单保存失败!',[],100);
|
||||
$this->result('询单保存失败!', [], 100);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,24 +359,24 @@ class OrderpreController extends Common
|
||||
$get = Yii::$app->request->get();
|
||||
$post = $this->postdata;
|
||||
$id = isset($post['id']) ? (int)$post['id'] : 0;
|
||||
if(!$id){
|
||||
if (!$id) {
|
||||
$this->result('未指定询价单!');
|
||||
}
|
||||
$model = new AcOrderPre();
|
||||
$detail = $model->findOne($id);
|
||||
if(!$detail){
|
||||
if (!$detail) {
|
||||
$this->result('询价单信息不存在!');
|
||||
}
|
||||
if($detail->pid != $this->pid){
|
||||
if ($detail->pid != $this->pid) {
|
||||
$this->result('非法操作!');
|
||||
}
|
||||
if($detail->from_uid != $this->user_id){
|
||||
if ($detail->from_uid != $this->user_id) {
|
||||
$this->result('非法操作,请检查订单归属!');
|
||||
}
|
||||
|
||||
//格式化数据 为空的项则不修改
|
||||
|
||||
//目标键=》POST键
|
||||
|
||||
//目标键=》POST键
|
||||
$cols = ['start_province'=>'start_province','start_city'=>'start_city','aim_province'=>'aim_province','aim_city'=>'aim_city',
|
||||
'car_title'=>'car_title','car_no'=>'car_no',
|
||||
'from_name'=>'from_name','from_mobile'=>'from_mobile',
|
||||
@@ -386,8 +386,8 @@ class OrderpreController extends Common
|
||||
$detail->$col = trim($post[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$cols = ['car_value'=>'car_value','from_gender'=>'from_gender'];
|
||||
|
||||
$cols = ['car_value'=>'car_value','from_gender'=>'from_gender'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
if (isset($post[$key]) && $post[$key] !='') {
|
||||
$detail->$col = (int)$post[$key];
|
||||
@@ -405,14 +405,14 @@ class OrderpreController extends Common
|
||||
|
||||
$detail->status_code = 1; //标记订单处于创建待审核状态
|
||||
$detail->update_at = time();
|
||||
|
||||
//保存资料
|
||||
|
||||
//保存资料
|
||||
$res = $detail->save();
|
||||
|
||||
if ($res) {
|
||||
$this->result('询单保存成功!',['id'=>$id],200);
|
||||
$this->result('询单保存成功!', ['id' => $id], 200);
|
||||
} else {
|
||||
$this->result('询单保存失败!',[],100);
|
||||
$this->result('询单保存失败!', [], 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user