Example #1
0
 public function refund($refundInfo)
 {
     $requiredFields = ['subject', 'orderNumber', 'expectedAmount', 'realAmount', 'admin', 'user', 'refundMode'];
     ValidatorUtil::fieldsRequired($refundInfo, $requiredFields);
     // TODO  1. Call weconnect to refund
     // Save refund message to tradeRefund.
     return ModelRefund::refund($this->accountId, $refundInfo);
 }
 public function actionExport()
 {
     $params = $this->getQuery();
     $accountId = $this->getAccountId();
     $condition = TradeRefund::getSearchCondition($accountId, $params);
     $data = TradeRefund::findOne($condition);
     if (empty($data)) {
         return ['result' => 'error', 'message' => 'no datas', 'data' => []];
     }
     $key = Yii::t('channel', 'refund_file_name') . '_' . date('Y-m-d H:i:s');
     $fields = 'transactionId,user,expectedAmount,realAmount,subject,refundAt';
     $sort = ['refundAt' => -1];
     $fileTitle = Yii::t('channel', 'export_refund_title');
     $header = ['transactionId', 'userName', 'realAmount', 'subject', 'refundAt'];
     $header = array_combine($header, explode(',', $fileTitle));
     $args = ['accountId' => (string) $accountId, 'key' => $key, 'header' => $header, 'fields' => $fields, 'sort' => $sort, 'params' => [], 'collection' => 'tradeRefund', 'condition' => serialize($condition), 'classFunction' => '\\backend\\modules\\channel\\models\\TradeRefund::preProcessData', 'description' => 'Direct: Export TradeRefund data'];
     $jobId = Yii::$app->job->create('backend\\modules\\common\\job\\MongoExportFile', $args);
     unset($header, $args);
     return ['result' => 'success', 'message' => 'exporting file', 'data' => ['jobId' => $jobId, 'key' => $key]];
 }