作者 郭盛
1 个管道 的构建 通过 耗费 6 秒

修改订单状态

... ... @@ -102,6 +102,12 @@ class Teacher extends Backend
if ($params) {
$params = $this->preExcludeFields($params);
if($params['status'] == 1){
$teacher = Db::name('teacher')
->where('id',$ids)
->find();
Db::name('user')->where('id',$teacher['user_id'])->update(['identity'=>2]);
}
$params['level'] = ($params['help_num'] * 5)/$params['help_num'];
if($params['is_recommend'] == 1){
$teacher_list = Db::name('teacher')
... ...
... ... @@ -10,6 +10,7 @@ use think\Config;
use Qiniu\Storage\UploadManager;
use Qiniu\Auth;
use think\Cache;
use think\Db;
use think\Validate;
/**
... ... @@ -208,4 +209,107 @@ class Common extends Api
}
/**
* @ApiTitle (获取融云token)
* @ApiSummary (获取融云token)
* @ApiMethod (POST)
* @ApiRoute (/api/common/rong_getToken)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiReturn({
"code": 1,
"msg": "SUCCESS",
"time": "1553839125",
"data": {
}
})
*/
public function rong_getToken()
{
$user_id = $this->getUserId();
$data = Db::name('user')
->where('id',$user_id)
->find();
if($data['identity'] == 1){
$rong['name'] = $data['nickname'];
$rong['portraitUri'] = $data['avatar'];
}else{
//获取七牛云配置
$qiniu = get_addon_config('qiniu');
$http = $qiniu['cdnurl'];
//身份为老师
$teacher = Db::name('teacher')
->where('user_id',$user_id)
->find();
$rong['name'] = $teacher['name'];
$rong['portraitUri'] = $http.$teacher['thumbnail'];
}
$rong['userId'] = $user_id;
$url = 'http://api-cn.ronghub.com/user/getToken.json';
$postData = 'userId='.$rong['userId'].'&name='.$rong['name'].'&portraitUri='.$rong['portraitUri'];
// post提交-推送
$row = json_decode($this->request_post_push($url, $postData),true);
print_r($row);die;
}
public function request_post_push($url = "", $postData = "") {
// 参数为空返回状态
if (empty($url) || empty($postData)) {
return false;
}
//参数初始化
$appKey = config('App_Key');
$appSecret = config('App_Secret');
$nonce = mt_rand(); // 获取随机数。
$timeStamp = time();// 获取时间戳。
$signature = sha1($appSecret.$nonce.$timeStamp);
$httpHeader = array(
'App-Key:'.$appKey, // 平台分配
'Nonce:'.$nonce, // 随机数
'Timestamp:'.$timeStamp, // 时间戳
'Signature:'.$signature, // 签名
'Content-Type: application/x-www-form-urlencoded',
);
// 初始化curl
$ch = curl_init();
// 设置你需要抓取的URL
curl_setopt($ch, CURLOPT_URL, $url);
// post提交方式
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
// 设置cURL 参数,要求结果保存到字符串中还是输出到屏幕上。
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// 设置header
curl_setopt($ch, CURLOPT_HEADER, false);
// 增加 HTTP Header(头)里的字段
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeader);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
// 终止从服务端进行验证
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
// 运行curl
$data = curl_exec($ch);
// 关闭URL请求
curl_close($ch);
return $data ;
}
}
... ...
... ... @@ -165,4 +165,57 @@ class Coupon extends Api
}
$this->success('success',$data);
}
/**
* @ApiTitle (用户须知)
* @ApiSummary (用户须知)
* @ApiMethod (POST)
* @ApiRoute (/api/coupon/need)
*
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"id": //id,
"content"://用户须知内容
"createtime"://创建时间
}
})
*/
public function need()
{
$data = Db::name('need')
->where('id',1)
->find();
$data['createtime'] = date('Y-m-d H:i:s',$data['createtime']);
}
/**
* @ApiTitle (成为老师文案)
* @ApiSummary (成为老师文案)
* @ApiMethod (POST)
* @ApiRoute (/api/coupon/official)
*
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"id": //id,
"content"://成为老师文案内容
"createtime"://创建时间
}
})
*/
public function official()
{
$data = Db::name('official')
->where('id',1)
->find();
$data['createtime'] = date('Y-m-d H:i:s',$data['createtime']);
}
}
\ No newline at end of file
... ...
... ... @@ -70,6 +70,7 @@ class Index extends Api
->field('updatetime,createtime,type',true)
->where('type',1)
->order('id desc')
->limit(8)
->select();
$this->success('success',$data);
}elseif($type == 2){
... ... @@ -77,6 +78,7 @@ class Index extends Api
->field('updatetime,createtime,type',true)
->where('type',2)
->order('id desc')
->limit(8)
->select();
$this->success('success',$data);
}else{
... ... @@ -156,9 +158,10 @@ class Index extends Api
$token = $this->request->header('token');
$page = $this->request->param('page', 1, 'intval');
$pageNum = $this->request->param('pageNum', 10, 'intval');
//接收类型值
$type = $this->request->param('type');
//未登录的状态下
if(empty($token)){
$type = $this->request->param('type');
$keyword = $this->request->param('keyword');
if($type == '' || $type == 1){
$data = Db::name('teacher')
... ... @@ -339,14 +342,14 @@ class Index extends Api
"msg": "成功",
"time": "1571492001",
"data": {
* "list":[
"list":[
"id"://记录id,
"keyword"://搜索的内容
],
"hotlist":[
"id"://记录id,
"keyword"://搜索的内容
* ]
],
}
})
... ...
... ... @@ -157,6 +157,7 @@ class Order extends Api
->alias('a')
->join('teacher b','a.teacher_id = b.id')
->where('a.finish_status',3)
->where('a.is_complaint',['=',1],['=',3],'or')
->where('a.user_id',$user_id)
->field('a.*,b.name,b.thumbnail')
->select();
... ... @@ -212,6 +213,7 @@ class Order extends Api
$user_id = $this->getUserId();
$type = $this->request->param('type');
if($type == '' || $type == 1){
//进行中
$data = Db::name('order')
->alias('a')
->join('teacher b','a.teacher_id = b.id')
... ... @@ -220,6 +222,7 @@ class Order extends Api
->field('a.*,b.name,b.thumbnail')
->select();
}elseif ($type == 2){
//待总结
$data = Db::name('order')
->alias('a')
->join('teacher b','a.teacher_id = b.id')
... ... @@ -229,28 +232,34 @@ class Order extends Api
->field('a.*,b.name,b.thumbnail')
->select();
}elseif ($type == 3){
//结算中
$data = Db::name('order')
->alias('a')
->join('teacher b','a.teacher_id = b.id')
->where('a.finish_status',2)
->where('a.is_summarize',1)
->where('a.user_id',$user_id)
->where('a.order_status',2)
->field('a.*,b.name,b.thumbnail')
->select();
}elseif ($type == 4){
//已完成
$data = Db::name('order')
->alias('a')
->join('teacher b','a.teacher_id = b.id')
->where('a.finish_status',2)
->where('a.is_summarize',1)
->where('a.order_status',1)
->where('a.user_id',$user_id)
->field('a.*,b.name,b.thumbnail')
->select();
}elseif ($type == 5 ){
//退款/投诉
$data = Db::name('order')
->alias('a')
->join('teacher b','a.teacher_id = b.id')
->where('a.finish_status',3)
->where('a.is_complaint',['=',1],['=',3],'or')
->where('a.user_id',$user_id)
->field('a.*,b.name,b.thumbnail')
->select();
... ...
... ... @@ -60,36 +60,156 @@ class Teacher extends Api
'name' => 'require',
'sex' => 'require',
'birth' => 'require',
'idcard'=>'require',
'before'=>'require',
'behind'=>'require',
'phone'=>'require',
'thumbnail'=>'require',
'address'=>'require',
'honor'=>'require',
'content'=>'require',
'show'=>'require',
'desc'=>'require',
'online'=>'require',
'territory_id'=>"require"
'idcard' => 'require',
'before' => 'require',
'behind' => 'require',
'phone' => 'require',
'thumbnail' => 'require',
'address' => 'require',
'honor' => 'require',
'content' => 'require',
'show' => 'require',
'desc' => 'require',
'online' => 'require',
'territory_id' => "require"
]);
if (!$validate->check($param)) {
$this->error($validate->getError());
}
$qiniu = get_addon_config('qiniu');
$http = $qiniu['cdnurl'];
$param['before'] = str_replace($http,'',$param['before']);
$param['behind'] = str_replace($http,'',$param['behind']);
$param['thumbnail'] = str_replace($http,'',$param['thumbnail']);
$param['before'] = str_replace($http, '', $param['before']);
$param['behind'] = str_replace($http, '', $param['behind']);
$param['thumbnail'] = str_replace($http, '', $param['thumbnail']);
$param['createtime'] = time();
$data = Db::name('teacher')->insertGetId($param);
if(empty($data)){
if (empty($data)) {
$this->error('提交失败');
}else{
} else {
$this->success('提交成功');
}
}
/**
* @ApiTitle (成为老师表单详情)
* @ApiSummary (成为老师表单详情)
* @ApiMethod (POST)
* @ApiRoute (/api/teacher/tea_detail)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"id"://老师ID
"name"://真实姓名
"sex"://性别(1男2女)
"birth"://出生日期
"idcard"://身份证号
"before"://身份证正面照
"behind"://身份证反面照
"phone"://手机号
"thumbnail"://大头照
"address"://常住地
"honor"://头衔
"content"://个人履历
"show"://展示在最前
"desc"://个人简历
"online"://在线时段
"status"://状态(0待审核1审核通过2未通过)
"territory_id"://擅长领域ID
}
})
*/
public function tea_detail()
{
$user_id = $this->getUserId();
$data = Db::name('teacher')
->where('user_id',$user_id)
->find();
$qiniu = get_addon_config('qiniu')['cdnurl'];
$data['before'] = $qiniu.$data['before'];
$data['behind'] = $qiniu.$data['behind'];
$data['thumbnail'] = $qiniu.$data['thumbnail'];
$this->success('success',$data);
}
/**
* @ApiTitle (成为老师表单提交)
* @ApiSummary (成为老师表单提交)
* @ApiMethod (POST)
* @ApiRoute (/api/teacher/update)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiParams (name="id", type="int", required=true, description="老师ID")
* @ApiParams (name="name", type="string", required=true, description="真实姓名")
* @ApiParams (name="sex", type="int", required=true, description="性别(1男2女)")
* @ApiParams (name="birth", type="string", required=true, description="出生日期")
* @ApiParams (name="idcard", type="string", required=true, description="身份证号")
* @ApiParams (name="before", type="string", required=true, description="身份证正面")
* @ApiParams (name="behind", type="string", required=true, description="身份证反面")
* @ApiParams (name="phone", type="string", required=true, description="手机号")
* @ApiParams (name="thumbnail", type="string", required=true, description="头像")
* @ApiParams (name="address", type="string", required=true, description="常住地")
* @ApiParams (name="honor", type="string", required=true, description="头衔")
* @ApiParams (name="content", type="string", required=true, description="个人履历")
* @ApiParams (name="show", type="string", required=true, description="展示在最前")
* @ApiParams (name="desc", type="string", required=true, description="个人简历")
* @ApiParams (name="online", type="string", required=true, description="在线时段")
* @ApiParams (name="territory_id", type="string", required=true, description="擅长领域ID")
*
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
}
})
*/
public function update()
{
$user_id = $this->getUserId();
$param = $this->request->param();
if(empty($param['id'])){
$this->error('缺少必要参数');
}
$validate = new Validate([
'name' => 'require',
'sex' => 'require',
'birth' => 'require',
'idcard' => 'require',
'before' => 'require',
'behind' => 'require',
'phone' => 'require',
'thumbnail' => 'require',
'address' => 'require',
'honor' => 'require',
'content' => 'require',
'show' => 'require',
'desc' => 'require',
'online' => 'require',
'territory_id' => "require"
]);
if (!$validate->check($param)) {
$this->error($validate->getError());
}
$qiniu = get_addon_config('qiniu');
$http = $qiniu['cdnurl'];
$param['before'] = str_replace($http, '', $param['before']);
$param['behind'] = str_replace($http, '', $param['behind']);
$param['thumbnail'] = str_replace($http, '', $param['thumbnail']);
$param['updatetime'] = time();
$data = Db::name('teacher')->where('id',$param['id'])->update($param);
if (empty($data)) {
$this->error('提交失败');
} else {
$this->success('提交成功');
}
}
/**
... ...
... ... @@ -263,19 +263,71 @@ class User extends Api
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiReturn({
"identity"://身份(1学生2老师)
"nickname"://昵称
"avatar"://头像
"identity"://身份(1学生2老师)
"underway"://进行中的订单数
"finish"://已完成的订单数
"after"://售后的订单数
"summarize"://待总结的订单数
"jiesuan"://结算中的订单数
*
*/
public function judge()
{
$user_id = $this->getUserId();
$data = Db::name('teacher')
->where('user_id',$user_id)
$data = Db::name('user')
->field('id,avatar,nickname,identity')
->where('id',$user_id)
->find();
if(empty($data)){
$res['identity'] = 1;
if($data['identity'] == 1){
$data['underway'] = Db::name('order')
->where('user_id',$user_id)
->where('finish_status',1)
->count();
$data['finish'] = Db::name('order')
->where('user_id',$user_id)
->where('finish_status',2)
->count();
$data['after'] = Db::name('order')
->where('user_id',$user_id)
->where('finish_status',3)
->where('is_complaint',1)
->count();
}else{
$res['identity'] = 2;
//进行中
$data['underway'] = Db::name('order')
->where('user_id',$user_id)
->where('finish_status',1)
->count();
//待总结
$data['summarize'] = Db::name('order')
->where('user_id',$user_id)
->where('finish_status',2)
->where('is_summarize',2)
->count();
//结算中
$data['jiesuan'] = Db::name('order')
->where('user_id',$user_id)
->where('finish_status',2)
->where('is_summarize',1)
->where('order_status',2)
->count();
//已完成
$data['finish'] = Db::name('order')
->where('user_id',$user_id)
->where('finish_status',2)
->where('is_summarize',1)
->where('order_status',1)
->count();
//售后
$data['after'] = Db::name('order')
->where('user_id',$user_id)
->where('finish_status',3)
->where('is_complaint',['=',1],['=',3],'or')
->count();
}
$this->success('success',$res);
$this->success('success',$data);
}
}
... ...
... ... @@ -290,4 +290,8 @@ return [
// 如需使用敏感接口(如退款、发送红包等)需要配置 API 证书路径(登录商户平台下载 API 证书)
'cert_path' => ROOT_PATH.'public/cert/apiclient_cert.pem', // XXX: 绝对路径!!!!
'key_path' => ROOT_PATH.'public/cert/apiclient_key.pem', // XXX: 绝对路径!!!!
//融云参数
'App_Key' => '3argexb63q3he',
'App_Secret' => '1nb2RBxREmTICB',
];
... ...
此 diff 太大无法显示。
... ... @@ -20,4 +20,119 @@ require(['upload'], function (Upload) {
};
});
require.config({
paths: {
'summernote': '../addons/summernote/lang/summernote-zh-CN.min'
},
shim: {
'summernote': ['../addons/summernote/js/summernote.min', 'css!../addons/summernote/css/summernote.css'],
}
});
require(['form', 'upload'], function (Form, Upload) {
var _bindevent = Form.events.bindevent;
Form.events.bindevent = function (form) {
_bindevent.apply(this, [form]);
try {
//绑定summernote事件
if ($(".summernote,.editor", form).size() > 0) {
require(['summernote'], function () {
var imageButton = function (context) {
var ui = $.summernote.ui;
var button = ui.button({
contents: '<i class="fa fa-file-image-o"/>',
tooltip: __('Choose'),
click: function () {
parent.Fast.api.open("general/attachment/select?element_id=&multiple=true&mimetype=image/*", __('Choose'), {
callback: function (data) {
var urlArr = data.url.split(/\,/);
$.each(urlArr, function () {
var url = Fast.api.cdnurl(this);
context.invoke('editor.insertImage', url);
});
}
});
return false;
}
});
return button.render();
};
var attachmentButton = function (context) {
var ui = $.summernote.ui;
var button = ui.button({
contents: '<i class="fa fa-file"/>',
tooltip: __('Choose'),
click: function () {
parent.Fast.api.open("general/attachment/select?element_id=&multiple=true&mimetype=*", __('Choose'), {
callback: function (data) {
var urlArr = data.url.split(/\,/);
$.each(urlArr, function () {
var url = Fast.api.cdnurl(this);
var node = $("<a href='" + url + "'>" + url + "</a>");
context.invoke('insertNode', node[0]);
});
}
});
return false;
}
});
return button.render();
};
$(".summernote,.editor", form).summernote({
height: 250,
lang: 'zh-CN',
fontNames: [
'Arial', 'Arial Black', 'Serif', 'Sans', 'Courier',
'Courier New', 'Comic Sans MS', 'Helvetica', 'Impact', 'Lucida Grande',
"Open Sans", "Hiragino Sans GB", "Microsoft YaHei",
'微软雅黑', '宋体', '黑体', '仿宋', '楷体', '幼圆',
],
fontNamesIgnoreCheck: [
"Open Sans", "Microsoft YaHei",
'微软雅黑', '宋体', '黑体', '仿宋', '楷体', '幼圆'
],
toolbar: [
['style', ['style', 'undo', 'redo']],
['font', ['bold', 'underline', 'strikethrough', 'clear']],
['fontname', ['color', 'fontname', 'fontsize']],
['para', ['ul', 'ol', 'paragraph', 'height']],
['table', ['table', 'hr']],
['insert', ['link', 'picture', 'video']],
['select', ['image', 'attachment']],
['view', ['fullscreen', 'codeview', 'help']],
],
buttons: {
image: imageButton,
attachment: attachmentButton,
},
dialogsInBody: true,
followingToolbar: false,
callbacks: {
onChange: function (contents) {
$(this).val(contents);
$(this).trigger('change');
},
onInit: function () {
},
onImageUpload: function (files) {
var that = this;
//依次上传图片
for (var i = 0; i < files.length; i++) {
Upload.api.send(files[i], function (data) {
var url = Fast.api.cdnurl(data.url);
$(that).summernote("insertImage", url, 'filename');
});
}
}
}
});
});
}
} catch (e) {
}
};
});
});
\ No newline at end of file
... ...