登录和支付

This commit is contained in:
liu 2024-06-04 15:26:45 +08:00
parent 9680835324
commit 96fcaf5021
3 changed files with 11 additions and 20 deletions

View File

@ -31,7 +31,8 @@ class UserController extends BaseApiController
if ($result === false) { if ($result === false) {
return $this->fail(UserLogic::getError()); return $this->fail(UserLogic::getError());
} }
return $this->success('绑定成功', [], 1, 1); $data = UserLogic::info($this->userId);
return $this->success('绑定成功', $data, 1, 1);
} }

View File

@ -25,7 +25,7 @@ use app\common\service\{
}; };
use app\common\model\user\{User, UserAuth}; use app\common\model\user\{User, UserAuth};
use app\common\service\wechat\WeChatMnpService; use app\common\service\wechat\WeChatMnpService;
use think\facade\Db;
use Webman\Config; use Webman\Config;
/** /**
@ -221,7 +221,7 @@ class LoginLogic extends BaseLogic
*/ */
public static function mnpLogin(array $params) public static function mnpLogin(array $params)
{ {
Db::startTrans(); // Db::startTrans();
try { try {
//通过code获取微信 openid //通过code获取微信 openid
$response = (new WeChatMnpService())->getMnpResByCode($params['code']); $response = (new WeChatMnpService())->getMnpResByCode($params['code']);
@ -229,21 +229,11 @@ class LoginLogic extends BaseLogic
$userInfo = $userServer->getResopnseByUserInfo()->authUserLogin()->getUserInfo(); $userInfo = $userServer->getResopnseByUserInfo()->authUserLogin()->getUserInfo();
// 更新登录信息 // 更新登录信息
self::updateLoginInfo($userInfo['id']); self::updateLoginInfo($userInfo['id']);
//判断是不是员工
// $userInfo['is_staff'] = 0;
// $userInfo['store_id'] = 0;
// if(isset($userInfo['mobile']) && $userInfo['mobile']){
// $check = SystemStoreStaff::where('phone',$userInfo['mobile'])->find()??[];
// if ($check){
// $userInfo['is_staff'] = 1;
// $userInfo['store_id'] = $check['store_id'];
// }
// }
Db::commit(); // Db::commit();
return $userInfo; return $userInfo;
} catch (\Exception $e) { } catch (\Exception $e) {
Db::rollback(); // Db::rollback();
self::$error = $e->getMessage(); self::$error = $e->getMessage();
return false; return false;
} }

View File

@ -34,9 +34,9 @@ class PaymentLogic extends BaseLogic
public static function pay($payWay, $from, $order, $terminal, $redirectUrl) public static function pay($payWay, $from, $order, $terminal, $redirectUrl)
{ {
// 支付编号-仅为微信支付预置(同一商户号下不同客户端支付需使用唯一订单号) // 支付编号-仅为微信支付预置(同一商户号下不同客户端支付需使用唯一订单号)
$paySn = $order['number']; $paySn = $order['order_id'];
if ($order['actual'] == 0) { if ($order['pay_price'] == 0) {
PayNotifyLogic::handle($from, $order['number']); PayNotifyLogic::handle($from, $order['order_id']);
return ['pay_way' => PayEnum::BALANCE_PAY]; return ['pay_way' => PayEnum::BALANCE_PAY];
} }
switch ($payWay) { switch ($payWay) {
@ -46,11 +46,11 @@ class PaymentLogic extends BaseLogic
'out_trade_no' => $paySn, 'out_trade_no' => $paySn,
'description' => '商品', 'description' => '商品',
'amount' => [ 'amount' => [
'total' => intval($order['actual'] * 100), 'total' => intval($order['pay_price'] * 100),
'currency' => 'CNY', 'currency' => 'CNY',
], ],
"payer" => [ "payer" => [
"openid" => $auth['openid'] ?? 0 "openid" => $auth['openid'] ?? 'onoIP7c1qgjfIr2ce7GJAAmVGcL0'
], ],
'attach' => $from 'attach' => $from
]; ];