...
|
...
|
@@ -558,14 +558,45 @@ class Store extends Api |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 发布信息
|
|
|
* 计算发布所需板币
|
|
|
* @ApiWeigh (31)
|
|
|
*
|
|
|
* @ApiTitle (计算发布所需板币)
|
|
|
* @ApiSummary (计算发布所需板币)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/store/store_inform_score)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="red_package", type="string", required=false, description="红包总金额")
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturn ({
|
|
|
'code':'1',
|
|
|
'msg':'返回成功'
|
|
|
})
|
|
|
*/
|
|
|
public function store_inform_score()
|
|
|
{
|
|
|
$param = (new StoreValidate())->goCheck('store_inform_score');
|
|
|
$store = $this->get_store();
|
|
|
$basic = config('site.send_score');
|
|
|
$score = bcadd($basic,$param['red_package'] * config('site.withdraw_percent'),0);
|
|
|
$return = [
|
|
|
'score' => $score,
|
|
|
'basic' => $basic
|
|
|
];
|
|
|
$this->success('成功',$return);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 发布/编辑信息
|
|
|
* @ApiWeigh (30)
|
|
|
*
|
|
|
* @ApiTitle (发布信息)
|
|
|
* @ApiSummary (发布信息)
|
|
|
* @ApiTitle (发布/编辑信息)
|
|
|
* @ApiSummary (发布/编辑信息)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/store/store_inform_add)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="inform_id", type="string", required=false, description="信息id")
|
|
|
* @ApiParams (name="content", type="string", required=true, description="详细内容")
|
|
|
* @ApiParams (name="images", type="string", required=true, description="图片")
|
|
|
* @ApiParams (name="house_ids", type="string", required=true, description="推广社区")
|
...
|
...
|
@@ -600,6 +631,20 @@ class Store extends Api |
|
|
$this->error('板币不足,请充值');
|
|
|
}
|
|
|
}
|
|
|
$model = new StoreInform();
|
|
|
// 如果为编辑,判断状态是否为下架
|
|
|
if($param['inform_id']) {
|
|
|
$where = [
|
|
|
'where' => [
|
|
|
'id' => $param['inform_id'],
|
|
|
'store_id' => $param['store_id']
|
|
|
]
|
|
|
];
|
|
|
$inform = $model->findOrFail($where);
|
|
|
if($inform['status'] != 3) {
|
|
|
$this->error('当前状态无法编辑');
|
|
|
}
|
|
|
}
|
|
|
Db::startTrans();
|
|
|
$result = false;
|
|
|
$res_user = $res_log = true;
|
...
|
...
|
@@ -607,8 +652,17 @@ class Store extends Api |
|
|
$param['user_id'] = $this->auth->id;
|
|
|
$param['store_id'] = $store['id'];
|
|
|
$param['house_ids'] = ','.$param['house_ids'].',';
|
|
|
$model = new StoreInform();
|
|
|
$param['surplus'] = $param['number'];
|
|
|
$param['status'] = 1;
|
|
|
if($param['inform_id']) {
|
|
|
$param['id'] = $param['inform_id'];
|
|
|
$param['get'] = 0;
|
|
|
$param['surplus'] = $param['number'];
|
|
|
unset($param['inform_id']);
|
|
|
$result = $model->edit($param);
|
|
|
} else {
|
|
|
$result = $model->add($param);
|
|
|
}
|
|
|
if($param['type'] == 1) {
|
|
|
// 减少用户板币余额
|
|
|
$res_user = Db::name('user')->where('id',$param['user_id'])->setDec('score',$param['score']);
|
...
|
...
|
@@ -642,6 +696,88 @@ class Store extends Api |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 下架/删除信息
|
|
|
* @ApiWeigh (29)
|
|
|
*
|
|
|
* @ApiTitle (下架/删除信息)
|
|
|
* @ApiSummary (下架/删除信息)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/store/store_inform_down)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="type", type="integer", required=true, description="1=下架2=删除")
|
|
|
* @ApiParams (name="inform_id", type="string", required=false, description="信息id")
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturn ({
|
|
|
'code':'1',
|
|
|
'msg':'返回成功'
|
|
|
})
|
|
|
*/
|
|
|
public function store_inform_down()
|
|
|
{
|
|
|
$param = (new StoreValidate())->goCheck('store_inform_down');
|
|
|
$store = $this->get_store();
|
|
|
$model = new StoreInform();
|
|
|
$where = [
|
|
|
'where' => ['id' => $param['inform_id'],'store_id'=>$store['id']]
|
|
|
];
|
|
|
$inform = $model->findOrFail($where);
|
|
|
if($param['type'] == 1) {
|
|
|
if($inform['status'] == 3) {
|
|
|
$this->error('该信息已下架');
|
|
|
}
|
|
|
}
|
|
|
if($param['type'] == 2) {
|
|
|
if($inform['status'] != 3) {
|
|
|
$this->error('请下架后进行删除');
|
|
|
}
|
|
|
}
|
|
|
$name = $param['type'] == 1 ? '下架' : '删除';
|
|
|
Db::startTrans();
|
|
|
$result = false;
|
|
|
$res_user = $res_log = true;
|
|
|
try{
|
|
|
$edit = [
|
|
|
'id' => $param['inform_id'],
|
|
|
'status' => $param['type'] == 1 ? 3 : 9
|
|
|
];
|
|
|
$result = $model->edit($edit);
|
|
|
if($param['type'] == 1 && $inform['type'] == 1) {
|
|
|
// 返还用户板币余额
|
|
|
$score = $inform['surplus'] * $inform['single'];
|
|
|
if($score > 0) {
|
|
|
$res_user = Db::name('user')->where('id',$this->auth->id)->setInc('score',$score);
|
|
|
//记录钱包log
|
|
|
$insert_data = array(
|
|
|
'user_id' => $this->auth->id,
|
|
|
'score' => $score,
|
|
|
'before' => $this->auth->score,
|
|
|
'after' => $this->auth->score + $score,
|
|
|
'createtime' => time(),
|
|
|
'memo' => '下架信息',
|
|
|
);
|
|
|
$res_log = Db::name('user_score_log')->insert($insert_data);
|
|
|
}
|
|
|
}
|
|
|
if(!$result || !$res_user || !$res_log) {
|
|
|
Db::rollback();
|
|
|
} else {
|
|
|
Db::commit();
|
|
|
}
|
|
|
} catch (PDOException $e) {
|
|
|
Db::rollback();
|
|
|
$this->error($e->getMessage());
|
|
|
} catch (Exception $e) {
|
|
|
Db::rollback();
|
|
|
$this->error($e->getMessage());
|
|
|
}
|
|
|
if(!$result || !$res_log || !$res_user) {
|
|
|
$this->error($name.'失败');
|
|
|
}
|
|
|
$this->success($name.'成功');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 商圈信息列表
|
|
|
* @ApiWeigh (29)
|
|
|
*
|
...
|
...
|
@@ -666,7 +802,7 @@ class Store extends Api |
|
|
"content": "标题",
|
|
|
"images": "/assets/img/qrcode.png",
|
|
|
"house_ids": ",1,",
|
|
|
"type": 2,
|
|
|
"type": 1=红包信息2=一般信息,
|
|
|
"score": "0",
|
|
|
"red_package": "红包总金额",
|
|
|
"number": 红包数量,
|
...
|
...
|
@@ -743,7 +879,7 @@ class Store extends Api |
|
|
"content": "内容",
|
|
|
"images": "/assets/img/qrcode.png",
|
|
|
"house_ids": ",1,",
|
|
|
"type": 2,
|
|
|
"type": 1=红包信息2=一般信息,
|
|
|
"score": "0",
|
|
|
"red_package": "红包总金额",
|
|
|
"number": 红包数量,
|
...
|
...
|
|