|
| xqd
@@ -27,11 +27,11 @@ class UserController extends Controller
|
|
|
|
|
|
$record = UserVip::where('user_id',$user['id'])
|
|
|
->where('status',1)
|
|
|
- ->first()
|
|
|
- ->toArray();
|
|
|
+ ->first();
|
|
|
if(empty($record)){
|
|
|
return out();
|
|
|
}
|
|
|
+ $record = $record->toArray();
|
|
|
|
|
|
return out([
|
|
|
'order_fee' => $record['order_fee'],
|
|
| xqd
@@ -74,7 +74,6 @@ class UserController extends Controller
|
|
|
$user = auth('api')->user();
|
|
|
$shareConfig = Setting::first()->toArray();
|
|
|
|
|
|
- $orderId = get_order_id($user['id']);
|
|
|
\DB::beginTransaction();
|
|
|
$app = Factory::payment(config('wechat.payment.default'));
|
|
|
$jssdk = $app->jssdk;
|
|
| xqd
@@ -83,16 +82,21 @@ class UserController extends Controller
|
|
|
|
|
|
$order = UserVip::where('user_id', $user['id'])->first();
|
|
|
if(empty($order) || empty($order->prepay_id)){
|
|
|
- $order = UserVip::create([
|
|
|
- 'order_id' => $orderId,
|
|
|
- 'user_id' => $user['id'],
|
|
|
- 'order_fee' => $shareConfig['member_price']
|
|
|
- ]);
|
|
|
+ $orderId = get_order_id($user['id']);
|
|
|
+ if(empty($order)){
|
|
|
+ $order = UserVip::create([
|
|
|
+ 'order_id' => $orderId,
|
|
|
+ 'user_id' => $user['id'],
|
|
|
+ 'order_fee' => $shareConfig['member_price']
|
|
|
+ ]);
|
|
|
+ }else{
|
|
|
+ $order->order_id = $orderId;
|
|
|
+ }
|
|
|
$payment = $app->order->unify([
|
|
|
- 'body' => '三哥桥梁-会员充值',
|
|
|
+ 'body' => '三哥桥梁-购买会员',
|
|
|
'out_trade_no' => $orderId,
|
|
|
'total_fee' => $shareConfig['member_price']*100, // 分
|
|
|
- 'notify_url' => 'https://pay.weixin.qq.com/wxpay/pay.action', // 支付结果通知网址,如果不设置则会使用配置里的默认地址
|
|
|
+ 'notify_url' => config('wechat.payment.default.notify_url'), // 支付结果通知网址,如果不设置则会使用配置里的默认地址
|
|
|
'trade_type' => 'JSAPI', // 请对应换成你的支付方式对应的值类型
|
|
|
'openid' => $user['openid'],
|
|
|
]);
|
|
| xqd
@@ -124,10 +128,16 @@ class UserController extends Controller
|
|
|
public function query()
|
|
|
{
|
|
|
$user = auth('api')->user();
|
|
|
- $order = UserVip::where('user_id', $user['id'])->first()->toArray();
|
|
|
- return out($order);
|
|
|
+ $order = UserVip::where('user_id', $user['id'])->first();
|
|
|
+ if(!$order){
|
|
|
+ return out(2);
|
|
|
+ }
|
|
|
+ $order = $order->toArray();
|
|
|
+
|
|
|
+ return out($order['status']);
|
|
|
}
|
|
|
|
|
|
+ // 推广人数
|
|
|
public function shares()
|
|
|
{
|
|
|
$user = auth('api')->user();
|