切换导航条
此项目
正在载入...
登录
李忠强
/
temporaryfood
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
李忠强
3 years ago
提交
55963b92e90a45ae394ecf1a59aa100b4bb4e159
1 个父辈
d85e27eb
更新
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
65 行增加
和
21 行删除
application/api/controller/Order.php
application/api/controller/Order.php
查看文件 @
55963b9
...
...
@@ -5,6 +5,7 @@ namespace app\api\controller;
use
addons\epay\library\Service
;
use
app\api\model\GoodsComment
;
use
app\api\model\GoodsSpec
;
use
app\api\model\SpecValue
;
use
app\api\model\Third
;
...
...
@@ -537,40 +538,83 @@ class Order extends Api
}
/**
* @ApiTitle (评价订单)
* @ApiTitle (评价订单
详情页
)
* @ApiMethod (POST)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="id", type="integer", required=true, description="订单ID")
* @ApiParams (name="score", type="integer", required=true, description="评价分数")
* @ApiParams (name="comment", type="string", required=true, description="评价内容")
* @ApiParams (name="images", type="string", required=true, description="评价图片逗号隔开")
* @ApiReturn ({
'code':'1',
'msg':'返回成功'
'data':
order_id:订单id
goods_name:商品名称
goods_id:商品id
goods_attr:规格描述
image_text:商品图片
})
*/
public
function
commentOrder
()
public
function
commentOrder
Detail
()
{
$order_id
=
$this
->
request
->
post
(
'id'
);
$score
=
$this
->
request
->
post
(
'score'
);
$comment
=
$this
->
request
->
post
(
'comment'
);
$images
=
$this
->
request
->
post
(
'images'
);
if
(
!
is_numeric
(
$order_id
))
$this
->
error
(
'订单id参数不合法'
);
if
(
!
is_numeric
(
$score
)
||
$score
>
5
||
$score
<
1
)
$this
->
error
(
'评价分数不合法'
);
if
(
!
$comment
)
$this
->
error
(
'请填写评价内容'
);
if
(
!
$comment
)
$this
->
error
(
'请填写评价内容'
);
if
(
$images
){
$arr
=
explode
(
','
,
$images
);
if
(
count
(
$arr
)
>
3
)
$this
->
error
(
'请上传最多3张评价图片'
);
$model
=
new
\app\api\model\OrderGoods
();
$list
=
$model
->
where
(
'order_id'
,
$order_id
)
->
field
(
'order_id,goods_name,goods_id,goods_attr,image'
)
->
select
();
$this
->
success
(
'商品列表'
,
$list
);
}
/**
* @ApiTitle (评价订单)
* @ApiMethod (POST)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="data_json", type="string", required=true, description="评价数据 json对象")
* @ApiParams (name="order_id", type="integer", required=false, description="订单ID 不传")
* @ApiParams (name="score", type="integer", required=false, description="评价分数 不传")
* @ApiParams (name="comment", type="string", required=false, description="评价内容 不传")
* @ApiParams (name="goods_id", type="string", required=false, description="商品id 不传")
* @ApiParams (name="images", type="string", required=false, description="评价图片逗号隔开 不传")
* @ApiReturn ({
'code':'1',
'msg':'返回成功'
})
*/
public
function
commentOrder
()
{
$data
=
$this
->
request
->
post
(
'data_json'
);
if
(
!
$data
)
$this
->
error
(
'data_json参数缺失'
);
$data
=
json_decode
(
$data
,
true
);
$params
=
[];
$orderids
=
[];
foreach
(
$data
as
$key
=>
$value
){
if
(
!
is_numeric
(
$value
[
'order_id'
]))
$this
->
error
(
'订单id参数不合法'
);
if
(
!
is_numeric
(
$value
[
'goods_id'
]))
$this
->
error
(
'商品id参数不合法'
);
if
(
!
is_numeric
(
$value
[
'score'
])
||
$value
[
'score'
]
>
5
||
$value
[
'score'
]
<
1
)
$this
->
error
(
'评价分数不合法'
);
if
(
!
$value
[
'comment'
])
$this
->
error
(
'请填写评价内容'
);
if
(
$value
[
'images'
]){
$arr
=
explode
(
','
,
$value
[
'images'
]);
if
(
count
(
$arr
)
>
3
)
$this
->
error
(
'请上传最多3张评价图片'
);
}
$params
[]
=
[
'user_id'
=>
$this
->
auth
->
id
,
'order_id'
=>
$value
[
'order_id'
],
'goods_id'
=>
$value
[
'goods_id'
],
'comment'
=>
$value
[
'comment'
],
'images'
=>
$value
[
'images'
],
'score'
=>
$value
[
'score'
],
];
$orderids
[]
=
$value
[
'order_id'
];
}
$model
=
new
\app\api\model\Order
();
$model
->
where
(
'id'
,
$order_id
)
->
isUpdate
()
->
save
([
'order_status'
=>
'30'
]);
// $data = [
// 'user_id' => $this->auth->id,
// 'goods_id' => $
// ]
$this
->
success
(
'取消成功'
);
$ordermodel
=
new
\app\api\model\Order
();
$ordermodel
->
whereIn
(
'id'
,
$orderids
)
->
isUpdate
()
->
save
([
'order_status'
=>
'30'
]);
$commentmodel
=
new
GoodsComment
();
$commentmodel
->
isUpdate
(
false
)
->
saveAll
(
$params
);
$this
->
success
(
'评价成功'
);
}
}
\ No newline at end of file
...
...
请
注册
或
登录
后发表评论