示例#1
0
 /**
  * Auther:langxi
  *$uid, $pid, $money
  * app投资接口
  */
 public function actionInvest()
 {
     $result = App::AppGet();
     try {
         if ($result['errorNum']) {
             $result = array('errorNum' => $result['errorNum'], 'errorMsg' => $result['errorMsg'], 'data' => null);
         } else {
             $data = $result['data'];
             if (array_key_exists('uid', $data) && array_key_exists('pid', $data) && array_key_exists('money', $data)) {
                 $uid = $data['uid'];
                 $pid = $data['pid'];
                 $money = $data['money'];
                 $result = Invest::Invest($uid, $pid, $money);
                 Invest::goldtwo($uid, $money);
                 //体验金
                 //                    if($result['errorNum'] == '0'){
                 //                        //投资成功
                 //                        $user = UcenterMember::findOne(['id'=>$uid]);
                 //                        $phone = $user->phone;
                 //                        Port::ValidatePhone2($phone,'2',$money);
                 //                    }
             } else {
                 $result = array('errorNum' => '1', 'errorMsg' => '参数错误', 'data' => null);
             }
         }
     } catch (ErrorException $e) {
         Yii::error("app投资接口---异常 方法:actionInvest 参数:" . json_encode($result['data']), "app");
         Yii::trace($e->getMessage(), "app");
         $result = array('errorNum' => '7', 'errorMsg' => '服务器异常,请联系管理员', 'data' => null);
     }
     $result = App::AppReturn($result);
     return $result;
 }
示例#2
0
 public function actionDoinvest()
 {
     $uid = Yii::$app->user->id;
     if ($_POST) {
         $money = $_POST['money'];
         $pid = $_POST['product_id'];
         $result = Invest::Invest($uid, $pid, $money);
         Invest::gold($uid, $money);
         //体验金
         if ($result['errorNum'] == 1) {
             return $result['errorMsg'];
         } else {
             return '您已成功完成了投资';
         }
     }
 }