作者 郭宇鹏
1 个管道 的构建 通过 耗费 1 秒

'1-4'

... ... @@ -641,13 +641,13 @@ class Article extends BaseApi
//4.判断是自定义价格
if ($data['status'] == 1){
//4.1 查询礼物
$article_gift = $this->get_data('price','价格不能为空');
$price = $this->get_data('price','价格不能为空');
//4.2 查询礼物订单
$is_order = model('article_gift_order')
->where('article_id',$article['id'])
->where('is_custom',1)
->where('status',0)
->where('price',$article_gift['price'])
->where('price',$price)
->find();
if (!$is_order){
$a_data = [
... ... @@ -659,7 +659,7 @@ class Article extends BaseApi
'nickname'=>$this->auth->nickname,
'username'=>$this->auth->username,
'mobile'=>$this->auth->mobile,
'price'=>$article_gift['price'],
'price'=>$price,
'status'=>0,
'is_custom'=>0,
];
... ...
... ... @@ -4,6 +4,10 @@
namespace app\api\controller;
use dh2y\qrcode\QRcode;
use think\Db;
use think\Exception;
use think\exception\PDOException;
use think\exception\ValidateException;
/**
* 墨宝档案
... ... @@ -203,7 +207,17 @@ class Treasured extends BaseApi
if ($treasured && $data['page'] == 1){
model('config')->where('name','mobao_num')->setInc('value');
}
//4.返回数据
//4.判断是不是点赞
if ($treasured){
foreach ($treasured as $key => $val){
$treasured[$key]['is_zan'] = 0;
$zan = model('treasured_zan')->where('user_id',$this->auth->id)->where('treasured_id',$val['id'])->find();
if ($zan){
$treasured[$key]['is_zan'] = 1;
}
}
}
//5.返回数据
$this->success('查询数据成功',$treasured);
}
... ... @@ -255,6 +269,16 @@ class Treasured extends BaseApi
}
$treasured = $treasured->page($data['page'],$data['num'])
->select();
//3.判断是不是点赞
if ($treasured){
foreach ($treasured as $key => $val){
$treasured[$key]['is_zan'] = 0;
$zan = model('treasured_zan')->where('user_id',$this->auth->id)->where('treasured_id',$val['id'])->find();
if ($zan){
$treasured[$key]['is_zan'] = 1;
}
}
}
//4.返回数据
$this->success('查询数据成功',$treasured);
}
... ... @@ -268,14 +292,49 @@ class Treasured extends BaseApi
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
* @ApiReturn ()
* @ApiReturn ({
"code": 1,
"msg": "查询数据成功",
"time": "1609742416",
"data": {
"id": 1,
"user_id": 2,
"avatar": "头像",
"nickname": "署名",
"title": "墨宝标题",
"number": "墨宝编号",
"author": "作者",
"images": "墨宝图片",
"content": "内容",
"production_typeface": "字体",
"production_typeface_id": "字体ID",
"production_format": "格式",
"production_format_id": "格式ID",
"treasured_size": "尺寸名称",
"treasured_size_id": "尺寸ID",
"status": "状态:0=待出售,1=已出售,2=非卖品",
"zan_num": "点赞数量",
"createtime": "2020-12-30 13:38:38",
"qr_code": "二维码",
"qr_code_d": "海报二维码",
"updatetime": "2020-12-30 13:38:38",
"deletetime": "删除时间",
"message": "删除提示",
"is_zan": "是否点赞 0=未点赞,1=已点赞"
}
})
*/
public function getTreasuredContent(){
//1.获取动态id
$id = $this->get_data('id','墨宝档案ID不能为空');
//2.查询数据
$treasured = model('treasured')->where('id',$id)->find();
//
//3.查询有没有点赞
$treasured['is_zan'] = 0;
$zan = model('treasured_zan')->where('user_id',$this->auth->id)->where('treasured_id',$id)->find();
if ($zan){
$treasured['is_zan'] = 1;
}
//4.返回数据
$this->success('查询数据成功',$treasured);
}
... ... @@ -310,11 +369,14 @@ class Treasured extends BaseApi
->find();
if ($treasured_zan){
$treasured_zan->delete();
model('treasured')->where('id',$treasured_id)->setDec('zan_num');
$this->success('查询成功',['code'=>0,'msg'=>'取消点赞成功']);
}
//3.增加点赞
//4.增加点赞
model('treasured_zan')->create(['user_id'=>$this->auth->id,'treasured_id'=>$treasured_id]);
//4.返回结果
//5.增加点赞数量
model('treasured')->where('id',$treasured_id)->setInc('zan_num');
//6.返回结果
$this->success('查询成功',['code'=>1,'msg'=>'点赞成功']);
}
... ...
... ... @@ -7636,7 +7636,37 @@
<div class="tab-pane" id="sample49">
<div class="row">
<div class="col-md-12">
<pre id="sample_response49"></pre>
<pre id="sample_response49">{
"code": 1,
"msg": "查询数据成功",
"time": "1609742416",
"data": {
"id": 1,
"user_id": 2,
"avatar": "头像",
"nickname": "署名",
"title": "墨宝标题",
"number": "墨宝编号",
"author": "作者",
"images": "墨宝图片",
"content": "内容",
"production_typeface": "字体",
"production_typeface_id": "字体ID",
"production_format": "格式",
"production_format_id": "格式ID",
"treasured_size": "尺寸名称",
"treasured_size_id": "尺寸ID",
"status": "状态:0=待出售,1=已出售,2=非卖品",
"zan_num": "点赞数量",
"createtime": "2020-12-30 13:38:38",
"qr_code": "二维码",
"qr_code_d": "海报二维码",
"updatetime": "2020-12-30 13:38:38",
"deletetime": "删除时间",
"message": "删除提示",
"is_zan": "是否点赞 0=未点赞,1=已点赞"
}
}</pre>
</div>
</div>
</div><!-- #sample -->
... ... @@ -9475,7 +9505,7 @@
<div class="row mt0 footer">
<div class="col-md-6" align="left">
Generated on 2021-01-04 14:26:38 </div>
Generated on 2021-01-04 14:46:39 </div>
<div class="col-md-6" align="right">
<a href="./" target="_blank">书法公众号</a>
</div>
... ...