Browse Source

商户提现页面数据

master
weigang 5 years ago
parent
commit
cbed35d9b0
  1. 7
      app/Constants/v3/ErrorCode.php
  2. 89
      app/Controller/v3/WithdrawController.php
  3. 21
      app/Service/v3/Implementations/FinancialRecordService.php
  4. 13
      app/Service/v3/Interfaces/FinancialRecordServiceInterface.php
  5. 1
      config/routes.php

7
app/Constants/v3/ErrorCode.php

@ -131,6 +131,13 @@ class ErrorCode extends AbstractConstants
* @Message("账号密码错误")
*/
const STORE_LOGIN_ERROR = 706;
/**
* 商户异常,当前商户可能不存在或失效了
* @Message("当前商户异常")
*/
const STORE_NOT_AVAILABLE = 707;
/************************************/
/* 定位相关 751-800 */
/************************************/

89
app/Controller/v3/WithdrawController.php

@ -0,0 +1,89 @@
<?php
namespace App\Controller\v3;
use App\Constants\v3\ErrorCode;
use App\Constants\v3\UserType;
use App\Controller\BaseController;
use App\Exception\ErrorCodeException;
use App\Model\v3\FinancialRecord;
use App\Model\v3\Store;
use App\Model\v3\UserBalance;
use App\Service\v3\Interfaces\FinancialRecordServiceInterface;
use Hyperf\Di\Annotation\Inject;
use Hyperf\Validation\ValidationException;
class WithdrawController extends BaseController
{
/**
* @Inject
* @var FinancialRecordServiceInterface
*/
protected $financialService;
/**
* 商户提现页数据
* 1、可提现金额
* 2、获得的奖励金额(历史总奖励金额)
* 3、用户须知
* 4、提现须知
*/
public function pageByStore()
{
$validator = $this->validationFactory->make(
$this->request->all(),
[
'user_id' => 'required|nonempty|integer',
'store_id' => 'required|nonempty|integer',
],
['*.*' => ':attribute 参数不正确']
);
if ($validator->fails()) {
throw new ValidationException($validator);
}
$userId = $this->request->input('user_id', 0);
$storeId = $this->request->input('store_id', 0);
$store = Store::query()->where(['user_id' => $userId, 'id' => $storeId])->first();
if (empty($store)) {
throw new ErrorCodeException(ErrorCode::STORE_NOT_AVAILABLE);
}
$data['balance'] = UserBalance::query()
->where(['source_id' => $store->user_id, 'user_type' => UserType::STORE])
->value('balance');
$data['award'] = $this->financialService->sumAmount(
$store->user_id,
UserType::STORE,
[FinancialRecord::MONEY_TYPE_STORE_PLAT_NEW_USER, FinancialRecord::MONEY_TYPE_STORE_FIRST_ORDER]
);
$data['notice'] = [
[
'title' => '用户须知',
'content' => '<p>请仔细填写相关信息,如果由于您填写的信息有误导致资金流失,平台概不负责。</p><p>注意:因微信限制当前用户账户余额满<span style="color:red;">1</span>元后才可提现</p>'
],
[
'title' => '提现须知',
'content' => '<p>一次提现金额最低为<span style="color:red;">1</span>元</p>'
.'<p>一次提现金额最高为<span style="color:red;">5000</span>元</p>'
.'<p>每天可提现<span style="color:red;">10</span>次</p>'
],
];
return $this->success($data);
}
public function applyByStore()
{
$validator = $this->validationFactory->make(
$this->request->all(),
[
'user_id' => 'required|nonempty'
]
);
}
}

21
app/Service/v3/Implementations/FinancialRecordService.php

@ -312,4 +312,25 @@ class FinancialRecordService implements FinancialRecordServiceInterface
{
$this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment);
}
/**
* @inheritDoc
*/
public function sumAmount($user_id, $user_type, $money_type = [])
{
$financialRecord = new FinancialRecord();
if ($user_id != FinancialRecord::ACCOUNT_LEDGER) {
$mod = bcmod((string)$user_id, '5', 0);
$financialRecord->suffix($mod);
}
$sumAmount = $financialRecord->where([
'source_id' => $user_id,
'user_type' => $user_type
])->whereIn('money_type', $money_type)
->sum('money');
return bcadd($sumAmount, '0', 2);
}
}

13
app/Service/v3/Interfaces/FinancialRecordServiceInterface.php

@ -250,4 +250,17 @@ interface FinancialRecordServiceInterface
$comment=''
);
/**
* 统计用户某些金额
* @param $user_id
* @param $user_type
* @param array $money_type
* @return mixed
*/
public function sumAmount(
$user_id,
$user_type,
$money_type = []
);
}

1
config/routes.php

@ -137,6 +137,7 @@ Router::addGroup('/v3/', function () {
Router::post('orderOnline/complete', 'App\Controller\v3\OrderOnlineController@complete');
Router::post('user/oflOrders', 'App\Controller\v3\OrderListController@offlineForUser');
Router::post('shopCart/delete', 'App\Controller\v3\ShopCartUpdateController@delete');
Router::post('withdraw/pageByStore', 'App\Controller\v3\WithdrawController@pageByStore');
},['middleware' => [\App\Middleware\Auth\ApiMiddleware::class, \App\Middleware\Auth\UserMiddleware::class]]);
// 微信支付回调

Loading…
Cancel
Save