|
@@ -558,14 +558,45 @@ class Store extends Api |
|
@@ -558,14 +558,45 @@ class Store extends Api |
558
|
}
|
558
|
}
|
559
|
|
559
|
|
560
|
/**
|
560
|
/**
|
561
|
- * 发布信息
|
561
|
+ * 计算发布所需板币
|
|
|
562
|
+ * @ApiWeigh (31)
|
|
|
563
|
+ *
|
|
|
564
|
+ * @ApiTitle (计算发布所需板币)
|
|
|
565
|
+ * @ApiSummary (计算发布所需板币)
|
|
|
566
|
+ * @ApiMethod (POST)
|
|
|
567
|
+ * @ApiRoute (/api/store/store_inform_score)
|
|
|
568
|
+ * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
569
|
+ * @ApiParams (name="red_package", type="string", required=false, description="红包总金额")
|
|
|
570
|
+ * @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
571
|
+ * @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
572
|
+ * @ApiReturn ({
|
|
|
573
|
+ 'code':'1',
|
|
|
574
|
+ 'msg':'返回成功'
|
|
|
575
|
+ })
|
|
|
576
|
+ */
|
|
|
577
|
+ public function store_inform_score()
|
|
|
578
|
+ {
|
|
|
579
|
+ $param = (new StoreValidate())->goCheck('store_inform_score');
|
|
|
580
|
+ $store = $this->get_store();
|
|
|
581
|
+ $basic = config('site.send_score');
|
|
|
582
|
+ $score = bcadd($basic,$param['red_package'] * config('site.withdraw_percent'),0);
|
|
|
583
|
+ $return = [
|
|
|
584
|
+ 'score' => $score,
|
|
|
585
|
+ 'basic' => $basic
|
|
|
586
|
+ ];
|
|
|
587
|
+ $this->success('成功',$return);
|
|
|
588
|
+ }
|
|
|
589
|
+
|
|
|
590
|
+ /**
|
|
|
591
|
+ * 发布/编辑信息
|
562
|
* @ApiWeigh (30)
|
592
|
* @ApiWeigh (30)
|
563
|
*
|
593
|
*
|
564
|
- * @ApiTitle (发布信息)
|
|
|
565
|
- * @ApiSummary (发布信息)
|
594
|
+ * @ApiTitle (发布/编辑信息)
|
|
|
595
|
+ * @ApiSummary (发布/编辑信息)
|
566
|
* @ApiMethod (POST)
|
596
|
* @ApiMethod (POST)
|
567
|
* @ApiRoute (/api/store/store_inform_add)
|
597
|
* @ApiRoute (/api/store/store_inform_add)
|
568
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
598
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
599
|
+ * @ApiParams (name="inform_id", type="string", required=false, description="信息id")
|
569
|
* @ApiParams (name="content", type="string", required=true, description="详细内容")
|
600
|
* @ApiParams (name="content", type="string", required=true, description="详细内容")
|
570
|
* @ApiParams (name="images", type="string", required=true, description="图片")
|
601
|
* @ApiParams (name="images", type="string", required=true, description="图片")
|
571
|
* @ApiParams (name="house_ids", type="string", required=true, description="推广社区")
|
602
|
* @ApiParams (name="house_ids", type="string", required=true, description="推广社区")
|
|
@@ -600,6 +631,20 @@ class Store extends Api |
|
@@ -600,6 +631,20 @@ class Store extends Api |
600
|
$this->error('板币不足,请充值');
|
631
|
$this->error('板币不足,请充值');
|
601
|
}
|
632
|
}
|
602
|
}
|
633
|
}
|
|
|
634
|
+ $model = new StoreInform();
|
|
|
635
|
+ // 如果为编辑,判断状态是否为下架
|
|
|
636
|
+ if($param['inform_id']) {
|
|
|
637
|
+ $where = [
|
|
|
638
|
+ 'where' => [
|
|
|
639
|
+ 'id' => $param['inform_id'],
|
|
|
640
|
+ 'store_id' => $param['store_id']
|
|
|
641
|
+ ]
|
|
|
642
|
+ ];
|
|
|
643
|
+ $inform = $model->findOrFail($where);
|
|
|
644
|
+ if($inform['status'] != 3) {
|
|
|
645
|
+ $this->error('当前状态无法编辑');
|
|
|
646
|
+ }
|
|
|
647
|
+ }
|
603
|
Db::startTrans();
|
648
|
Db::startTrans();
|
604
|
$result = false;
|
649
|
$result = false;
|
605
|
$res_user = $res_log = true;
|
650
|
$res_user = $res_log = true;
|
|
@@ -607,8 +652,17 @@ class Store extends Api |
|
@@ -607,8 +652,17 @@ class Store extends Api |
607
|
$param['user_id'] = $this->auth->id;
|
652
|
$param['user_id'] = $this->auth->id;
|
608
|
$param['store_id'] = $store['id'];
|
653
|
$param['store_id'] = $store['id'];
|
609
|
$param['house_ids'] = ','.$param['house_ids'].',';
|
654
|
$param['house_ids'] = ','.$param['house_ids'].',';
|
610
|
- $model = new StoreInform();
|
|
|
611
|
- $result = $model->add($param);
|
655
|
+ $param['surplus'] = $param['number'];
|
|
|
656
|
+ $param['status'] = 1;
|
|
|
657
|
+ if($param['inform_id']) {
|
|
|
658
|
+ $param['id'] = $param['inform_id'];
|
|
|
659
|
+ $param['get'] = 0;
|
|
|
660
|
+ $param['surplus'] = $param['number'];
|
|
|
661
|
+ unset($param['inform_id']);
|
|
|
662
|
+ $result = $model->edit($param);
|
|
|
663
|
+ } else {
|
|
|
664
|
+ $result = $model->add($param);
|
|
|
665
|
+ }
|
612
|
if($param['type'] == 1) {
|
666
|
if($param['type'] == 1) {
|
613
|
// 减少用户板币余额
|
667
|
// 减少用户板币余额
|
614
|
$res_user = Db::name('user')->where('id',$param['user_id'])->setDec('score',$param['score']);
|
668
|
$res_user = Db::name('user')->where('id',$param['user_id'])->setDec('score',$param['score']);
|
|
@@ -642,6 +696,88 @@ class Store extends Api |
|
@@ -642,6 +696,88 @@ class Store extends Api |
642
|
}
|
696
|
}
|
643
|
|
697
|
|
644
|
/**
|
698
|
/**
|
|
|
699
|
+ * 下架/删除信息
|
|
|
700
|
+ * @ApiWeigh (29)
|
|
|
701
|
+ *
|
|
|
702
|
+ * @ApiTitle (下架/删除信息)
|
|
|
703
|
+ * @ApiSummary (下架/删除信息)
|
|
|
704
|
+ * @ApiMethod (POST)
|
|
|
705
|
+ * @ApiRoute (/api/store/store_inform_down)
|
|
|
706
|
+ * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
707
|
+ * @ApiParams (name="type", type="integer", required=true, description="1=下架2=删除")
|
|
|
708
|
+ * @ApiParams (name="inform_id", type="string", required=false, description="信息id")
|
|
|
709
|
+ * @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
710
|
+ * @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
711
|
+ * @ApiReturn ({
|
|
|
712
|
+ 'code':'1',
|
|
|
713
|
+ 'msg':'返回成功'
|
|
|
714
|
+ })
|
|
|
715
|
+ */
|
|
|
716
|
+ public function store_inform_down()
|
|
|
717
|
+ {
|
|
|
718
|
+ $param = (new StoreValidate())->goCheck('store_inform_down');
|
|
|
719
|
+ $store = $this->get_store();
|
|
|
720
|
+ $model = new StoreInform();
|
|
|
721
|
+ $where = [
|
|
|
722
|
+ 'where' => ['id' => $param['inform_id'],'store_id'=>$store['id']]
|
|
|
723
|
+ ];
|
|
|
724
|
+ $inform = $model->findOrFail($where);
|
|
|
725
|
+ if($param['type'] == 1) {
|
|
|
726
|
+ if($inform['status'] == 3) {
|
|
|
727
|
+ $this->error('该信息已下架');
|
|
|
728
|
+ }
|
|
|
729
|
+ }
|
|
|
730
|
+ if($param['type'] == 2) {
|
|
|
731
|
+ if($inform['status'] != 3) {
|
|
|
732
|
+ $this->error('请下架后进行删除');
|
|
|
733
|
+ }
|
|
|
734
|
+ }
|
|
|
735
|
+ $name = $param['type'] == 1 ? '下架' : '删除';
|
|
|
736
|
+ Db::startTrans();
|
|
|
737
|
+ $result = false;
|
|
|
738
|
+ $res_user = $res_log = true;
|
|
|
739
|
+ try{
|
|
|
740
|
+ $edit = [
|
|
|
741
|
+ 'id' => $param['inform_id'],
|
|
|
742
|
+ 'status' => $param['type'] == 1 ? 3 : 9
|
|
|
743
|
+ ];
|
|
|
744
|
+ $result = $model->edit($edit);
|
|
|
745
|
+ if($param['type'] == 1 && $inform['type'] == 1) {
|
|
|
746
|
+ // 返还用户板币余额
|
|
|
747
|
+ $score = $inform['surplus'] * $inform['single'];
|
|
|
748
|
+ if($score > 0) {
|
|
|
749
|
+ $res_user = Db::name('user')->where('id',$this->auth->id)->setInc('score',$score);
|
|
|
750
|
+ //记录钱包log
|
|
|
751
|
+ $insert_data = array(
|
|
|
752
|
+ 'user_id' => $this->auth->id,
|
|
|
753
|
+ 'score' => $score,
|
|
|
754
|
+ 'before' => $this->auth->score,
|
|
|
755
|
+ 'after' => $this->auth->score + $score,
|
|
|
756
|
+ 'createtime' => time(),
|
|
|
757
|
+ 'memo' => '下架信息',
|
|
|
758
|
+ );
|
|
|
759
|
+ $res_log = Db::name('user_score_log')->insert($insert_data);
|
|
|
760
|
+ }
|
|
|
761
|
+ }
|
|
|
762
|
+ if(!$result || !$res_user || !$res_log) {
|
|
|
763
|
+ Db::rollback();
|
|
|
764
|
+ } else {
|
|
|
765
|
+ Db::commit();
|
|
|
766
|
+ }
|
|
|
767
|
+ } catch (PDOException $e) {
|
|
|
768
|
+ Db::rollback();
|
|
|
769
|
+ $this->error($e->getMessage());
|
|
|
770
|
+ } catch (Exception $e) {
|
|
|
771
|
+ Db::rollback();
|
|
|
772
|
+ $this->error($e->getMessage());
|
|
|
773
|
+ }
|
|
|
774
|
+ if(!$result || !$res_log || !$res_user) {
|
|
|
775
|
+ $this->error($name.'失败');
|
|
|
776
|
+ }
|
|
|
777
|
+ $this->success($name.'成功');
|
|
|
778
|
+ }
|
|
|
779
|
+
|
|
|
780
|
+ /**
|
645
|
* 商圈信息列表
|
781
|
* 商圈信息列表
|
646
|
* @ApiWeigh (29)
|
782
|
* @ApiWeigh (29)
|
647
|
*
|
783
|
*
|
|
@@ -666,7 +802,7 @@ class Store extends Api |
|
@@ -666,7 +802,7 @@ class Store extends Api |
666
|
"content": "标题",
|
802
|
"content": "标题",
|
667
|
"images": "/assets/img/qrcode.png",
|
803
|
"images": "/assets/img/qrcode.png",
|
668
|
"house_ids": ",1,",
|
804
|
"house_ids": ",1,",
|
669
|
- "type": 2,
|
805
|
+ "type": 1=红包信息2=一般信息,
|
670
|
"score": "0",
|
806
|
"score": "0",
|
671
|
"red_package": "红包总金额",
|
807
|
"red_package": "红包总金额",
|
672
|
"number": 红包数量,
|
808
|
"number": 红包数量,
|
|
@@ -743,7 +879,7 @@ class Store extends Api |
|
@@ -743,7 +879,7 @@ class Store extends Api |
743
|
"content": "内容",
|
879
|
"content": "内容",
|
744
|
"images": "/assets/img/qrcode.png",
|
880
|
"images": "/assets/img/qrcode.png",
|
745
|
"house_ids": ",1,",
|
881
|
"house_ids": ",1,",
|
746
|
- "type": 2,
|
882
|
+ "type": 1=红包信息2=一般信息,
|
747
|
"score": "0",
|
883
|
"score": "0",
|
748
|
"red_package": "红包总金额",
|
884
|
"red_package": "红包总金额",
|
749
|
"number": 红包数量,
|
885
|
"number": 红包数量,
|