1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- /**
- * Created by PhpStorm.
- * User: z-yang
- * Date: 2019/7/27
- * Time: 18:01
- */
- namespace App\Modules\User\Services;
- use App\Modules\User\Models\UserMonthOrder;
- use App\Modules\User\Models\UserMonthSign;
- use GuzzleHttp\Client;
- class UserMonthService
- {
- public static function createSign(int $uid, int $plan_id, string $change_type,string $openid)
- {
- $model = new UserMonthSign();
- $info = $model->where('uid', $uid)->where('plan_id', $plan_id)->first();
- if ($info) {
- $info->change_type = $change_type;
- $info->save();
- } else {
- $model->uid = $uid;
- $model->plan_id = $plan_id;
- $model->change_type = $change_type;
- $model->openid = $openid;
- $model->save();
- }
- return;
- }
- public static function isSignMonth($openid){
- $model = new UserMonthSign();
- return $model->where('openid',$openid)->where('change_type','ADD')->select('id')->first();
- }
- public static function getLastOrder(int $uid){
- $model = new UserMonthOrder();
- return $model->where('uid',$uid)->orderBy('id','desc')->first();
- }
- public static function createLOrder(int $uid, int $plan_id, int $total_fee, string $trade_no,string $out_trade_no)
- {
- $model = new UserMonthOrder();
- $model->uid = $uid;
- $model->plan_id = $plan_id;
- $model->total_fee = $total_fee;
- $model->trade_no = $trade_no;
- $model->out_trade_no = $out_trade_no;
- $model->save();
- return;
- }
- public static function getOrderByOrder($trade_no,$out_trade_no){
- $model = new UserMonthOrder();
- $info = $model->where('trade_no',$trade_no)->first();
- return $info;
- }
- public static function checkOrderStatus(int $user_id,int $plan_id,string $app_id,string $key,string $app_secret){
- $pay_year = date('Y');
- $pay_month = date('m');
- $sign = _sign(compact('app_id','app_secret','user_id','plan_id','pay_year','pay_month'),$key.$key);
- $client = new Client();
- $url = 'http://pap.manyuedu.org/checkPay.php';
- $client->request('post',$url,['form_params'=>
- compact('user_id','app_secret','app_id','plan_id','pay_year','pay_month','sign')])
- ->getBody()->getContents();
- }
- }
|