1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace app\api\controller\user;
- use app\models\user\UserMoney;
- use app\Request;
- use crmeb\services\UtilService;
- class Exchange
- {
- //闪兑
- public function exchange(Request $request)
- {
- list($origin_money_type, $money_type, $num) = UtilService::postMore([['origin_money_type', '', '', '', ['not_empty_check', function ($item) {
- $money_type = sys_data('money_type');
- $flag = false;
- foreach ($money_type as $v) {
- if ($v['code'] == $item) {
- if (!$v['do_exchange']) {
- return false;
- }
- $flag = true;
- }
- }
- return $flag;
- }], ['请选择支付币种', '请选择正确的支付币种']], ['money_type', '', '', '', ['not_empty_check', function ($item) {
- $money_type = sys_data('money_type');
- $flag = false;
- foreach ($money_type as $v) {
- if ($v['code'] == $item) {
- if (!$v['exchange']) {
- return false;
- }
- $flag = true;
- }
- }
- return $flag;
- }], ['请选择兑换币种', '请选择正确的兑换币种']], ['num', 0, '', '', ['not_empty_check', function ($item) {
- return $item > 0 && is_integer((int)$item);
- }], ['请输入要兑换数量', '请输入大于0的整数']]], $request, true);
- $res = UserMoney::exchangeMoney($request->uid(), $origin_money_type, $money_type, $num);
- if (!$res) {
- return app('json')->fail(UserMoney::getErrorInfo());
- } else {
- return app('json')->success('闪兑成功');
- }
- }
- }
|