充值记录
This commit is contained in:
parent
518a047343
commit
defd8b9e51
@ -23,6 +23,7 @@ use app\common\model\store\order\StoreOrderStatus;
|
||||
use app\common\model\store\order\StoreRefundOrder;
|
||||
use app\common\model\system\merchant\FinancialRecord;
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user\UserAddress;
|
||||
use app\common\model\user\UserBill;
|
||||
use app\common\model\user\UserRecharge;
|
||||
@ -38,6 +39,7 @@ use app\validate\api\ChangePasswordValidate;
|
||||
use app\validate\api\UserAuthValidate;
|
||||
use crmeb\basic\BaseController;
|
||||
use crmeb\services\MiniProgramService;
|
||||
use crmeb\services\PayService;
|
||||
use crmeb\services\SmsService;
|
||||
use crmeb\services\WechatService;
|
||||
use Exception;
|
||||
@ -921,4 +923,61 @@ class Auth extends BaseController
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
public function marginList()
|
||||
{
|
||||
$user = $this->request->userInfo();
|
||||
[$page, $limit] = $this->getPage();
|
||||
$count = Db::name('margin_order')->where('uid', $user['uid'])->where('paid', 1)->count();
|
||||
$list = Db::name('margin_order')->where('uid', $user['uid'])->where('paid', 1)->page($page, $limit)->order('order_id', 'desc')->select()->toArray();
|
||||
return app('json')->success(compact('count', 'list'));
|
||||
}
|
||||
|
||||
|
||||
public function doMargin()
|
||||
{
|
||||
$user = $this->request->userInfo();
|
||||
$merchant = Db::name('merchant')->where('uid', $user['uid'])->where('status', 1)->find();
|
||||
if (!$merchant) {
|
||||
return app('json')->fail('没有店铺');
|
||||
}
|
||||
if ($merchant['is_margin'] == 10) {
|
||||
return app('json')->fail('押金已缴纳');
|
||||
}
|
||||
if ($merchant['margin'] == 0) {
|
||||
$margin = Db::name('MerchantType')->where('mer_type_id', $merchant['type_id'])->value('margin');
|
||||
$margin = bcsub($margin, $merchant['paid_margin'], 2);
|
||||
} else {
|
||||
$margin = $merchant['margin'];
|
||||
}
|
||||
if ($margin == 0) {
|
||||
return app('json')->fail('当前金额为0,不能进行充值');
|
||||
}
|
||||
$orderSn = "bzj" . date('YmdHis') . uniqid();
|
||||
Db::name('margin_order')->insert([
|
||||
'uid' => $user['uid'],
|
||||
'mer_id' => $merchant['mer_id'],
|
||||
'order_sn' => $orderSn,
|
||||
'total_price' => $margin,
|
||||
'pay_type' => 1,
|
||||
'create_time' => date('Y-m-d H:i:s')
|
||||
]);
|
||||
$param = [
|
||||
"status" => 0,
|
||||
"is_del" => 0,
|
||||
"mer_id" => $merchant['mer_id'],
|
||||
"pay_type" => 1,
|
||||
"attach" => "margin",
|
||||
"order_info" => '{"is_margin":1,"margin":"' . $margin . '"}',
|
||||
"pay_price" => $margin,
|
||||
"order_sn" => $orderSn,
|
||||
"body" => $merchant['mer_name'] . ' - ' . $margin,
|
||||
];
|
||||
$payType = 'weixinApp';
|
||||
$service = new PayService($payType, $param);
|
||||
$payInfo = $service->pay(User::where(['uid' => $user['uid']])->find());
|
||||
return app('json')->success($payInfo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -40,6 +40,11 @@ Route::group('api/', function () {
|
||||
})->prefix('api.store.order.StoreOrder');
|
||||
});
|
||||
|
||||
//用户缴纳押金
|
||||
Route::post('user/margin', 'api.Auth/doMargin');
|
||||
Route::get('user/margin/list', 'api.Auth/marginList');
|
||||
|
||||
|
||||
//退出登录
|
||||
Route::post('logout', 'api.Auth/logout');
|
||||
//用户信息
|
||||
|
Loading…
x
Reference in New Issue
Block a user