Пример #1
0
 public function actionDispute()
 {
     $user = $this->checkAccess("create");
     $class_id = (int) Yii::$app->request->post('class_id');
     $dispute_type = (int) Yii::$app->request->post('dispute_type');
     $dispute = \common\models\TransactionHistory::checkDispute($class_id, $user->user_id);
     $class = \common\models\Classes::findOne($class_id);
     if ($dispute && $class) {
         if ($class->class_etime + 60 * 60 * 24 < time()) {
             return ApiHelper::errorResponse('Time for dispute expired.');
         }
         $dispute->transaction_dispute_status = 'open';
         $dispute->transaction_dispute_time = time();
         $dispute->transaction_dispute_type = $dispute_type;
         $dispute->save();
         return ApiHelper::successResponse(true);
     }
     return ApiHelper::errorResponse('Incorrect Access.');
 }
Пример #2
0
 public function getRefundedClass($class)
 {
     $data = TransactionHistory::find()->select('transation_id,transaction_refund,amount,created_at')->where(['class_id' => $class->class_id, 'user_id' => $this->id])->orderBy('created_at DESC')->one();
     return $data->transaction_refund ? false : $data;
 }
Пример #3
0
 public static function getWeekEarningPdf($user_id, $speriod, $eperiod)
 {
     $array = [];
     $subquery = (new \yii\db\Query())->from('classes')->select('class_id')->where(['class_trainer_id' => $user_id])->andWhere('`class_etime` >= :start AND `class_etime` <= :end', [":start" => $speriod, ":end" => $eperiod])->all();
     if ($subquery) {
         foreach ($subquery as $val) {
             @($array[] = $val['class_id']);
         }
         $array = implode(',', $array);
         $subquery = TransactionHistory::find()->select('class_id')->where("`class_id` IN ({$array})")->andWhere(['transaction_dispute_status' => 'close'])->orWhere(['transaction_dispute_status' => 'declined'])->all();
         if ($subquery) {
             $array = [];
             foreach ($subquery as $val) {
                 @($array[] = $val['class_id']);
             }
             $array = implode(',', $array);
             return Classes::find()->where("`class_id` IN ({$array})");
         }
     }
     return false;
 }