|
@@ -257,14 +257,10 @@ class IndexController extends Controller
|
|
|
* @apiParam {int} type 知识类型 1 悬赏 2 付费
|
|
* @apiParam {int} type 知识类型 1 悬赏 2 付费
|
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* @apiSuccessExample {json} Success-Response:
|
|
|
* HTTP/1.1 200 OK
|
|
* HTTP/1.1 200 OK
|
|
|
- * {
|
|
|
|
|
- * "status": true,
|
|
|
|
|
- * "status_code": 0,
|
|
|
|
|
- * "message": "",
|
|
|
|
|
* "data": {
|
|
* "data": {
|
|
|
- * "msg": "获取成功"
|
|
|
|
|
|
|
+ * "code": 1
|
|
|
|
|
+ * "msg": "添加成功"
|
|
|
* }
|
|
* }
|
|
|
- *}
|
|
|
|
|
* @apiErrorExample {json} Error-Response:
|
|
* @apiErrorExample {json} Error-Response:
|
|
|
* HTTP/1.1 400 Bad Request
|
|
* HTTP/1.1 400 Bad Request
|
|
|
* {
|
|
* {
|
|
@@ -293,14 +289,16 @@ class IndexController extends Controller
|
|
|
$type = $request->input('type');
|
|
$type = $request->input('type');
|
|
|
$message = MessagesInfoModel::where([['id',$id],['type',$type],['state',0]])->first();
|
|
$message = MessagesInfoModel::where([['id',$id],['type',$type],['state',0]])->first();
|
|
|
if(!$message){
|
|
if(!$message){
|
|
|
- $msg = '该信息不存在或者已完成';
|
|
|
|
|
- return $this->api(compact('msg'));
|
|
|
|
|
|
|
+ $data['msg'] = '该信息不存在或者已完成';
|
|
|
|
|
+ $data['code'] = 0;
|
|
|
|
|
+ return $this->api($data);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$check_is_buy = MessagesFollowerModel::where([['user_id',$this->getUserId()],['messages_id',$message->id]])->first();
|
|
$check_is_buy = MessagesFollowerModel::where([['user_id',$this->getUserId()],['messages_id',$message->id]])->first();
|
|
|
if($check_is_buy){
|
|
if($check_is_buy){
|
|
|
- $msg = '您已获取该知识,请勿重复操作';
|
|
|
|
|
- return $this->api(compact('msg'));
|
|
|
|
|
|
|
+ $data['msg'] = '您已获取该知识,请勿重复操作';
|
|
|
|
|
+ $data['code'] = 0;
|
|
|
|
|
+ return $this->api($data);
|
|
|
}
|
|
}
|
|
|
$user = UserInfoModel::find($this->getUserId());
|
|
$user = UserInfoModel::find($this->getUserId());
|
|
|
if($type == 2) {
|
|
if($type == 2) {
|
|
@@ -308,13 +306,15 @@ class IndexController extends Controller
|
|
|
$out_trade_no = 'We'.date('YmdHis').rand(1000,9999);
|
|
$out_trade_no = 'We'.date('YmdHis').rand(1000,9999);
|
|
|
$user->money -= $message->price;
|
|
$user->money -= $message->price;
|
|
|
if($user->money<0){
|
|
if($user->money<0){
|
|
|
- $msg = '您的余额已不足,请先充值';
|
|
|
|
|
- return $this->api(compact('msg'));
|
|
|
|
|
|
|
+ $data['msg'] = '您的余额已不足,请先充值';
|
|
|
|
|
+ $data['code'] = 0;
|
|
|
|
|
+ return $this->api($data);
|
|
|
}
|
|
}
|
|
|
if(!$user->save()){
|
|
if(!$user->save()){
|
|
|
- $msg = '购买失败';
|
|
|
|
|
|
|
+ $data['msg'] = '购买失败';
|
|
|
DB::rollback();
|
|
DB::rollback();
|
|
|
- return $this->api(compact('msg'));
|
|
|
|
|
|
|
+ $data['code'] = 0;
|
|
|
|
|
+ return $this->api($data);
|
|
|
}
|
|
}
|
|
|
//dd(111);
|
|
//dd(111);
|
|
|
$save['openid'] = $user->openid;
|
|
$save['openid'] = $user->openid;
|
|
@@ -325,9 +325,10 @@ class IndexController extends Controller
|
|
|
$save['type'] = 2;
|
|
$save['type'] = 2;
|
|
|
$res = PaymentInfoModel::create($save);
|
|
$res = PaymentInfoModel::create($save);
|
|
|
if(!$res) {
|
|
if(!$res) {
|
|
|
- $msg = '购买失败';
|
|
|
|
|
|
|
+ $data['msg'] = '购买失败';
|
|
|
DB::rollback();
|
|
DB::rollback();
|
|
|
- return $this->api(compact('msg'));
|
|
|
|
|
|
|
+ $data['code'] = 0;
|
|
|
|
|
+ return $this->api($data);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -337,12 +338,14 @@ class IndexController extends Controller
|
|
|
$followers['mobile'] = $user->mobile;
|
|
$followers['mobile'] = $user->mobile;
|
|
|
$followers['state'] = $type == 1?0:1;
|
|
$followers['state'] = $type == 1?0:1;
|
|
|
if(MessagesFollowerModel::create($followers)){
|
|
if(MessagesFollowerModel::create($followers)){
|
|
|
- $msg = '获取成功';
|
|
|
|
|
|
|
+ $data['msg'] = '获取成功';
|
|
|
|
|
+ $data['code'] = 1;
|
|
|
DB::commit();
|
|
DB::commit();
|
|
|
} else {
|
|
} else {
|
|
|
- $msg = '购买失败';
|
|
|
|
|
|
|
+ $data['msg'] = '购买失败';
|
|
|
|
|
+ $data['code'] = 0;
|
|
|
DB::rollback();
|
|
DB::rollback();
|
|
|
}
|
|
}
|
|
|
- return $this->api(compact('msg'));
|
|
|
|
|
|
|
+ return $this->api($data);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|