| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627 | 
							- <?php
 
- namespace App\Services\Person;
 
- use Aix\Pay\Data\PayOrder;
 
- use App\Exceptions\ResponseException;
 
- use App\Models\Category;
 
- use App\Models\MemberInfo;
 
- use App\Models\MembersHandsel;
 
- use App\Models\MembersPoint;
 
- use App\Models\Order;
 
- use App\Models\Payment;
 
- use App\Models\PersonalServiceStick;
 
- use App\Models\PersonalServiceStickLog;
 
- use App\Models\PersonalServiceTag;
 
- use App\Models\PersonalServiceTagLog;
 
- use App\Models\PersonServiceTagCategory;
 
- use App\Models\Resume;
 
- use App\Models\Tpl;
 
- use App\Repositories\MemberPointRepository;
 
- use App\Repositories\ResumeRepository;
 
- use App\Repositories\TaskLogRepository;
 
- use App\Repositories\TaskRepository;
 
- use App\Services\Common\PayService;
 
- use SimpleSoftwareIO\QrCode\Facades\QrCode;
 
- class MemberPointService
 
- {
 
-     /**
 
-      * @var MemberPointRepository
 
-      */
 
-     protected $MemberPointRepository;
 
-     protected $TaskLogRepository;
 
-     protected $TaskRepository;
 
-     protected $PayService;
 
-     protected $resumeRepository;
 
-     /**
 
-      * MemberPointService constructor.
 
-      * @param MemberPointRepository $MemberPointRepository
 
-      * @param TaskLogRepository $TaskLogRepository
 
-      * @param TaskRepository $TaskRepository
 
-      * @param PayService $PayService
 
-      * @param ResumeRepository $resumeRepository
 
-      */
 
-     public function __construct(MemberPointRepository $MemberPointRepository, TaskLogRepository $TaskLogRepository, TaskRepository $TaskRepository, PayService $PayService, ResumeRepository $resumeRepository)
 
-     {
 
-         $this->MemberPointRepository = $MemberPointRepository;
 
-         $this->TaskLogRepository = $TaskLogRepository;
 
-         $this->TaskRepository = $TaskRepository;
 
-         $this->PayService = $PayService;
 
-         $this->resumeRepository = $resumeRepository;
 
-     }
 
-     public function getPointsById($user)
 
-     {
 
-         $content = $this->MemberPointRepository->getPointsById($user->id, $user->utype);
 
-         $points = $this->TaskLogRepository->getTodayPoints($user->id, $user->utype);
 
-         $todayPoints = $points ? $points : 0;
 
-         $onPoints = $this->TaskLogRepository->getSinglePoints($user->id, $user->utype);
 
-         $dayPoints = $this->TaskLogRepository->getDayPoints($user->id, $user->utype);
 
-         $arrAll = $this->TaskRepository->getAllPoints($user->utype);
 
-         $allPoints = 0;
 
-         foreach ($arrAll as $key => $val) {
 
-             if ($val->once==1) {
 
-                 $allPoints+=$val->points;
 
-             } else {
 
-                 $allPoints+=(abs($val->times))*($val->points);
 
-             }
 
-         }
 
-         $lastPoints = (int)$allPoints-$onPoints-$dayPoints > 0 ? (int)$allPoints-$onPoints-$dayPoints : 0;
 
-         $member = MemberInfo::where(['uid'=>$user->id])->first();
 
-         $memhanselGet = MembersHandsel::where([
 
-             'uid'=>$user->id,
 
-             'utype'=>$user->utype,
 
-             'operate'=>1,
 
-         ])->orderBy('id', 'desc')->paginate(10);
 
-         $memhanselPo = MembersHandsel::where([
 
-             'uid'=>$user->id,
 
-             'utype'=>$user->utype,
 
-             'operate'=>2,
 
-         ])->orderBy('id', 'desc')->paginate(10);
 
-         $pointGet = MembersHandsel::where([
 
-             'uid'=>$user->id,
 
-             'utype'=>$user->utype,
 
-             'operate'=>1,
 
-         ])->sum('points');
 
-         $pointPo = MembersHandsel::where([
 
-             'uid'=>$user->id,
 
-             'utype'=>$user->utype,
 
-             'operate'=>2,
 
-         ])->sum('points');
 
-         return [
 
-             'content' =>$content,
 
-             'points'=>$todayPoints,
 
-             'lastPoints'=>$lastPoints,
 
-             'member'=>$member,
 
-             'memhanselGet'=>$memhanselGet,
 
-             'memhanselPo'=>$memhanselPo,
 
-             'pointGet'=>$pointGet,
 
-             'pointPo'=>$pointPo
 
-         ];
 
-     }
 
-     /**根据uid 和utype获取points
 
-      * @param $uid
 
-      * @param $utype
 
-      * @return mixed
 
-      */
 
-     public function getPoints($uid, $utype)
 
-     {
 
-         return $this->MemberPointRepository->getPointsById($uid, $utype);
 
-     }
 
-     /**积分操作
 
-      * @param $uid
 
-      * @param $utype
 
-      * @param $i_type
 
-      * @param $points
 
-      * @return mixed
 
-      */
 
-     public function reportDeal($uid, $utype, $i_type, $points)
 
-     {
 
-         return $this->MemberPointRepository->reportDeal($uid, $utype, $i_type, $points);
 
-     }
 
-     /**
 
-      * 获取任务状态。
 
-      */
 
-     public function getTask($user, $type=0)
 
-     {
 
-         $task = $this->MemberPointRepository->getTaskById($user->id, $user->utype);
 
-         foreach ($task as $key => $val) {
 
-             if ($key=='task_logs') {
 
-                 $task_id = [];
 
-                 $task_id_w = [];
 
-                 foreach ($val as $k => $v) {
 
-                     if ($v['once']!=1) {
 
-                         $task_id[] = $v['task_id'];
 
-                     } else {
 
-                         $task_id_w[] = $v['task_id'];
 
-                     }
 
-                 }
 
-             }
 
-         }
 
-         $count = [];
 
-         $task_id = array_unique($task_id);
 
-         foreach ($task_id as $k => $v) {
 
-             $count[$v] = $this->TaskLogRepository->getTaskLogCount($user->id, $v, $user->utype);
 
-         }
 
-         $task_info = $this->TaskRepository->getTaskById(array_keys($count));
 
-         $finshTask = [];  //已完成任务。
 
-         foreach ($count as $k1 => $v1) {
 
-             foreach ($task_info as $key1 => $val1) {
 
-                 if ($k1==$val1->id) {
 
-                     if ($val1->times!=-1) {
 
-                         if ($v1==$val1->times) {
 
-                             $finshTask[$k1]['id']=$val1->id;
 
-                             $finshTask[$k1]['title']=$val1->title;
 
-                             $finshTask[$k1]['points']=$val1->points;
 
-                             $finshTask[$k1]['type']='日常任务';
 
-                             $finshTask[$k1]['status']='已完成';
 
-                             $finshTask[$k1]['t_alias']=$val1->t_alias;
 
-                             $finshTask[$k1]['count']='(*'.$v1.')';
 
-                         }
 
-                     }
 
-                 }
 
-             }
 
-         }
 
-         $task_info_w = $this->TaskRepository->getTaskById(($task_id_w));
 
-         foreach ($task_info_w as $ke => $va) {
 
-             $finshTask[$va->id]['id'] = $va->id;
 
-             $finshTask[$va->id]['title'] = $va->title;
 
-             $finshTask[$va->id]['points'] = $va->points;
 
-             $finshTask[$va->id]['type'] = '一次性任务';
 
-             $finshTask[$va->id]['status'] = '已完成';
 
-             $finshTask[$va->id]['t_alias'] = $va->t_alias;
 
-             $finshTask[$va->id]['count']='';
 
-         }
 
-         $task_ZZ=$this->TaskRepository->getTaskByUtype($user->utype);
 
-         $task_info_z = [];
 
-         foreach ($task_ZZ as $key => $val) {
 
-             if (!in_array($val->id, array_keys($finshTask))) {
 
-                   $task_info_z[$val->id]['id'] = $val->id;
 
-                   $task_info_z[$val->id]['title'] = $val->title;
 
-                   $task_info_z[$val->id]['points'] = $val->points;
 
-                 if ($val->once==1) {
 
-                        $task_info_z[$val->id]['count'] = '';
 
-                        $task_info_z[$val->id]['type'] = '一次性任务';
 
-                 } else {
 
-                         $task_info_z[$val->id]['type'] = '日常任务';
 
-                         $hjk = $this->TaskLogRepository->getTaskLogCount($user->id, $val->id, $user->utype);
 
-                         $times =$val->times;
 
-                     if (!$hjk) {
 
-                         if ($times==-1) {
 
-                             $task_info_z[$val->id]['count'] = '';
 
-                         } else {
 
-                             $task_info_z[$val->id]['count'] = '(*'.$val->times.')';
 
-                         }
 
-                     } else {
 
-                         if ($times==-1) {
 
-                             $task_info_z[$val->id]['count'] = '';
 
-                         } else {
 
-                             $lasT = $times-$hjk;
 
-                             $task_info_z[$val->id]['count'] = '(*'.$lasT.')';
 
-                         }
 
-                     }
 
-                 }
 
-                 $defultType = '';
 
-                 if ($type == 1) {
 
-                     if (get_subsite_id() > 0) {
 
-                         $defultType = '/jkq/mobile';
 
-                     } else {
 
-                         $defultType = '/mobile';
 
-                     }
 
-                 } elseif ($type == 2) {
 
-                     $defultType = '/jkq';
 
-                 }
 
-                 if ($val->id==1) {
 
-                     $task_info_z[$val->id]['status'] = '<a href="'.$defultType.'/auth/register" STYLE="text-decoration: none;">去完成</a>';
 
-                 } elseif ($val->id==2) {
 
-                     $task_info_z[$val->id]['status'] = '<a href="'.$defultType.'/person/memberInfo" STYLE="text-decoration: none;">去完成</a>';
 
-                 } elseif ($val->id==3) {
 
-                     $task_info_z[$val->id]['status'] = '<a href="'.$defultType.'/person/index" STYLE="text-decoration: none;">去完成</a>';
 
-                 } elseif ($val->id==4) {
 
-                     $task_info_z[$val->id]['status'] = '<a href="'.$defultType.'/content/jobs" STYLE="text-decoration: none;">去完成</a>';
 
-                 } elseif ($val->id==5) {
 
-                     $task_info_z[$val->id]['status'] = '<a href="'.$defultType.'/person/memberInfo/head" STYLE="text-decoration: none;">去完成</a>';
 
-                 } elseif ($val->id==6) {
 
-                     $task_info_z[$val->id]['status'] = '<a href="'.$defultType.'/person/resume" STYLE="text-decoration: none;">去完成</a>';
 
-                 } elseif ($val->id==7) {
 
-                     $task_info_z[$val->id]['status'] = '<a href="'.$defultType.'/person/memberInfo/memberSafe" STYLE="text-decoration: none;">去完成</a>';
 
-                 } elseif ($val->id==9) {
 
-                     $task_info_z[$val->id]['status'] = '<a href="'.$defultType.'/person/memberInfo/memberSafe" STYLE="text-decoration: none;">去完成</a>';
 
-                 } elseif ($val->id==11) {
 
-                     $task_info_z[$val->id]['status'] = '<a href="'.$defultType.'/person/resume" STYLE="text-decoration: none;">去完成</a>';
 
-                 } elseif ($val->id==12) {
 
-                     $task_info_z[$val->id]['status'] = '<a href="'.$defultType.'/person/resume" STYLE="text-decoration: none;">去完成</a>';
 
-                 } elseif ($val->id==13) {
 
-                     $task_info_z[$val->id]['status'] = '<a href="'.$defultType.'/content/jobs" STYLE="text-decoration: none;">去完成</a>';
 
-                 } elseif ($val->id==14) {
 
-                     $task_info_z[$val->id]['status'] = '<a href="###" class="invitation_reg" STYLE="text-decoration: none;">去完成</a>';
 
-                 } elseif ($val->id==15) {
 
-                     $task_info_z[$val->id]['status'] = '<a href="'.$defultType.'/person/memberInfo/memberSafe" STYLE="text-decoration: none;">去完成</a>';
 
-                 } else {
 
-                     $task_info_z[$val->id]['status'] = '<a href="" STYLE="text-decoration: none;">去完成</a>';
 
-                 }
 
-                 $task_info_z[$val->id]['t_alias'] = $val->t_alias;
 
-             }
 
-         }
 
-         $todayPoints = 0;
 
-         $rs=$this->TaskLogRepository->getTodayPoints($user->id, $user->utype);
 
-         if ($rs) {
 
-             $todayPoints =  $rs;
 
-         }
 
-         $onPoints = $this->TaskLogRepository->getSinglePoints($user->id, $user->utype);
 
-         $dayPoints = $this->TaskLogRepository->getDayPoints($user->id, $user->utype);
 
-         $arrAll = $this->TaskRepository->getAllPoints($user->utype);
 
-         $allPoints = 0;
 
-         foreach ($arrAll as $key => $val) {
 
-             if ($val->once==1) {
 
-                 $allPoints+=$val->points;
 
-             } else {
 
-                 $allPoints+=(abs($val->times))*($val->points);
 
-             }
 
-         }
 
-         $lastPoints = (int)$allPoints-$onPoints-$dayPoints > 0 ? (int)$allPoints-$onPoints-$dayPoints : 0;
 
-         $member = MemberInfo::where(['uid'=>$user->id])->first();
 
-          return[
 
-              'w_finsh'=>$task_info_z,
 
-              'finsh'=>$finshTask,
 
-              'content'=>$task,
 
-              'todayPoints'=>$todayPoints,
 
-              'lastPoints'=>$lastPoints,
 
-              'member'=>$member,
 
-              'wap_title'=>'我的任务'
 
-          ];
 
-     }
 
-     public function increment_add($type, $user)
 
-     {
 
-         $resume = $this->resumeRepository->getSuccessResume($user->id, getResumeStatus());
 
-         $points = MembersPoint::where(['uid'=>$user->id,'utype'=>$user->utype])->first();
 
-         $payment = Payment::select(['id','name','alias'])->get();
 
-         foreach ($payment as $key => $val) {
 
-             if (!config("aix.system.pay.{$val->alias}.is_on")) {
 
-                 unset($payment[$key]);
 
-             }
 
-         }
 
-         switch ($type) {
 
-             case 'stick':
 
-                 $info = PersonalServiceStick::select(['id','days','points'])->orderBy('list_order', 'desc')->get();
 
-                 $tpl_name = 'increment_add_stick';
 
-                 $wap_title = '简历置顶';
 
-                 break;
 
-             case 'tag':
 
-                 $tagCategory = Category::where(['alias'=>'AIX_personaltag'])->get();
 
-                 $tag = PersonalServiceTag::select(['id', 'days', 'points'])->orderBy('list_order', 'desc')->get();
 
-                 foreach ($resume as $key => $val) {
 
-                     $PersonalServiceTagLog = PersonalServiceTagLog::where(['resume_id'=>$val->id,'resume_uid'=>$user->id])->first();
 
-                     if ($PersonalServiceTagLog) {
 
-                         if ($PersonalServiceTagLog->endtime-time()>0) {
 
-                             $resume[$key]['tagLog'] = true;
 
-                         } else {
 
-                             $resume[$key]['tagLog'] = false;
 
-                         }
 
-                     } else {
 
-                         $resume[$key]['tagLog'] = false;
 
-                     }
 
-                 }
 
-                 $info = ['tagCategory'=>$tagCategory,'tag'=>$tag];
 
-                 $tpl_name = 'increment_add_tag';
 
-                 $wap_title = '醒目标签';
 
-                 break;
 
-             default:
 
-                 //如果没有可以预览的简历信息,则获取默认简历
 
-                 if ($resume->isEmpty()) {
 
-                     $def_resume = $this->resumeRepository->getPersonInfo($user->id);
 
-                     if ($def_resume->toArray()) {
 
-                         $resume[0] = $def_resume;
 
-                     } else {
 
-                         $resume = [];
 
-                     }
 
-                 }
 
-                 $tpl_name = 'increment_add_tpl';
 
-                 $info = Tpl::where(['tpl_type'=>2,'display'=>1])->get();
 
-                 $wap_title = '简历模板';
 
-                 break;
 
-         }
 
-         return ['tpl'=>$tpl_name,'resume'=>$resume,'info'=>$info,'points'=>$points,'payment'=>$payment,
 
-             'wap_title'=>$wap_title];
 
-     }
 
-     public function  pay($input, $user)
 
-     {
 
-         $order = new Order();
 
-         if ($input['payment_name']=='wechat') {
 
-             $order->payment_cn = '微信扫码';
 
-         } else {
 
-             $order->payment_cn = '支付宝';
 
-         }
 
-         if ($input['is_deductible']) {
 
-             $order->pay_type = 3;
 
-             $order->amount = $input['amountNum'];
 
-             $order->pay_amount = $input['amount'];
 
-             $order->pay_points = $input['deductible'];
 
-             $order->payment = $input['payment_name'];
 
-             $is_deductible = '使用积分抵现(抵扣积分:)'.$input['deductible'].'积分!支付金额:'.$input['amount'].'元';
 
-             if ($input['type']=='tag') {
 
-                 $categorys = Category::where('id', $input['tagid'])->first();
 
-                 $order->discount = isset($categorys->demand) ? $categorys->demand : '-';
 
-                 $order->description = "简历标签(简历ID:".$input['resume_id']."),天数:".$input['days']."天,需要积分:".$input['points'].'积分,'.$is_deductible;
 
-                 $order->service_name = '简历标签';
 
-                 $order->order_type = 4;
 
-             } else {
 
-                 $order->description = "简历置顶(简历ID:".$input['resume_id']."),天数:".$input['days']."天,需要积分:".$input['points'].'积分,'.$is_deductible;
 
-                 $order->service_name = '简历置顶';
 
-                 $order->order_type = 3;
 
-                 $order->discount = '置顶'.$input['days'].'天';
 
-             }
 
-         } else {
 
-             $order->pay_type = 2;
 
-             $order->amount = $input['amountNum'];
 
-             $order->pay_amount = $input['amount'];
 
-             $order->pay_points = 0;
 
-             $order->payment = $input['payment_name'];
 
-             $is_deductible = '未使用积分抵现!支付金额:'.$input['amount'].'元';
 
-             if ($input['type']=='tag') {
 
-                 $categorys = Category::where('id', $input['tagid'])->first();
 
-                 $order->discount = isset($categorys->demand) ? $categorys->demand : '-';
 
-                 $order->description = "简历标签(简历ID:".$input['resume_id']."),天数:".$input['days']."天,需要积分:".$input['points'].'积分,'.$is_deductible;
 
-                 $order->service_name = '简历标签';
 
-                 $order->order_type = 4;
 
-             } else {
 
-                 $order->description = "简历置顶(简历ID:".$input['resume_id']."),天数:".$input['days']."天,需要积分:".$input['points'].'积分,'.$is_deductible;
 
-                 $order->service_name = '简历置顶';
 
-                 $order->order_type = 3;
 
-                 $order->discount = '置顶'.$input['days'].'天';
 
-             }
 
-         }
 
-         $order->charge = json_encode($input);
 
-         $order->uid = $user->id;
 
-         $order->utype = $user->utype;
 
-         $order->save();
 
-         return ['order'=>$order,'input'=>$input];
 
-     }
 
-     public function updateOrder($tradeNo, $input, $order, $route)
 
-     {
 
-         if (is_weixin()) {
 
-             $type = 'official';
 
-         } else {
 
-             if (strpos($route->uri,'mobile')!== false) {
 
-                 $type = 'wap';
 
-             } else {
 
-                 if ($input['payment_name']=='wechat') {
 
-                     $type = 'scan';
 
-                 } else {
 
-                     $type = 'web';
 
-                 }
 
-             }
 
-         }
 
-       /*  $type = 'official';  //------------自定义默认值。*/
 
-         $payorder=new PayOrder();
 
-         $payorder->trade_no=$tradeNo;
 
-         if ($input['type']=='tag') {
 
-             $payorder->subject="简历标签";
 
-         } else {
 
-             $payorder->subject="简历置顶";
 
-         }
 
-         if ($input['is_deductible']) {
 
-             $is_deductible = '使用积分抵现(抵扣积分:)'.$input['deductible'].'积分!支付金额:'.$input['amount'].'元';
 
-         } else {
 
-             $is_deductible = '未使用积分抵现!支付金额:'.$input['amount'].'元';
 
-         }
 
-         if ($input['type']=='tag') {
 
-             $payorder->detail="简历标签(简历ID:".$input['resume_id']."),天数:".$input['days']."天,需要积分:".$input['points'].'积分,'.$is_deductible;
 
-         } else {
 
-             $payorder->detail="简历置顶(简历ID:".$input['resume_id']."),天数:".$input['days']."天,需要积分:".$input['points'].'积分,'.$is_deductible;
 
-         }
 
-         $payorder->price=$input['amount'];
 
-         $payorder->callback='App\Services\Common\OrderService.updateOrder';
 
-         if ($type == 'web') {
 
-             $payorder->return_url=route('person.order_list');
 
-         }
 
-         if ($type=='wap') {
 
-             if ($input['payment_name']=='wechat') {
 
-                 $payorder->return_url=route('mobile.common.orderWechat',['oid'=>$payorder->trade_no]);
 
-             } else {
 
-                 $payorder->return_url=route('mobile.person.order_list');
 
-             }
 
-         }
 
-         if ($type=='official') {
 
-             $payorder->openid = $this->PayService->getPayOpenid();
 
-            /* $payorder->openid = 'o6poWw3LbYDgCGXCeM-qf-DYV1mo';*/
 
-         }
 
-         $result=$this->PayService->pay($input['payment_name'], $type, $payorder);
 
-         $order->oid = $payorder->trade_no;
 
-         $order->save();
 
-         if ($input['payment_name']=='wechat') {
 
-             if ($type=='wap') {
 
-                 return [
 
-                     'code'=>'wechat',
 
-                     'tradeCode'=>$result,
 
-                     'type'=>$type
 
-                 ];
 
-             }elseif ($type=='official') {
 
-                 return [
 
-                     'code'=>'wechat',
 
-                     'tradeCode'=>$result,
 
-                     'type'=>$type
 
-                 ];
 
-             } else {
 
-                 return [
 
-                     'code'=>'wechat',
 
-                     'tradeCode'=>get_qrcode_html($result->code_url),
 
-                     'tradeNo'=>[
 
-                         'number'=>$payorder->trade_no,
 
-                     ],
 
-                     'type'=>$type
 
-                 ];
 
-             }
 
-         } else {
 
-             return [
 
-                 'code'=>'alipay',
 
-                 'tradeCode'=>$result,
 
-             ];
 
-         }
 
-     }
 
-     public function payStatus($tradeNo)
 
-     {
 
-         if (!$tradeNo) {
 
-             return false;
 
-         }
 
-         $order = Order::where('oid', $tradeNo)->first();
 
-         if ($order->is_pay==2) {
 
-             return true;
 
-         } else {
 
-             return false;
 
-         }
 
-     }
 
-     public function order_list($user, $all)
 
-     {
 
-         $param_array = array('status','settr');
 
-         $params= array();
 
-         if ($all) {
 
-             foreach ($all as $k => $v) {
 
-                 if (in_array($k, $param_array)) {
 
-                     $params[$k] = $v;
 
-                 }
 
-             }
 
-         }
 
-         $data[] = ['uid','=',$user->id];
 
-         $data[] = ['utype','=',$user->utype];
 
-         if (request()->status) {
 
-             $data[] = ['is_pay','=',request()->status];
 
-         }
 
-         if (request()->settr) {
 
-             $data[] = ['order_type','=',request()->settr];
 
-         }
 
-         return['order'=>Order::where($data)->orderBy('id', 'desc')->paginate(10),'params'=>$params];
 
-     }
 
-     public function order_detail($oid,$user)
 
-     {
 
-         $res = Order::where(['uid'=>$user->id,'utype'=>$user->utype])->get()->toArray();
 
-         $array_id = array_column($res,'oid');
 
-         if(!in_array($oid,$array_id)){
 
-             throw new ResponseException('订单不存在!');
 
-         }
 
-         $order = Order::where(['oid'=>$oid])->first();
 
-         $charge = json_decode($order->charge);
 
-         $order->charge_cn = '';
 
-         if ($charge) {
 
-             $order->charge_cn = isset(Resume::find($charge->resume_id)->title) ?
 
-                 Resume::find($charge->resume_id)->title : '';
 
-             $order->service_time = '';
 
-             if ($order->order_type==3) {
 
-                 if (isset(PersonalServiceStickLog::where(['resume_id'=>$charge->resume_id])->first()->endtime)) {
 
-                     $endtime = PersonalServiceStickLog::where(['resume_id'=>$charge->resume_id])->first()->endtime;
 
-                     if ($order->is_pay==2) {
 
-                         $order->service_time = $endtime;
 
-                     }
 
-                 }
 
-             }
 
-             if ($order->order_type==4) {
 
-                 if (isset(PersonalServiceTagLog::where(['resume_id'=>$charge->resume_id])->first()->endtime)) {
 
-                     $endtime = PersonalServiceTagLog::where(['resume_id'=>$charge->resume_id])->first()->endtime;
 
-                     if ($order->is_pay==2) {
 
-                         $order->service_time = $endtime;
 
-                     }
 
-                 }
 
-             }
 
-         }
 
-          return $order;
 
-     }
 
-     public function order_cancel($id,$user)
 
-     {
 
-         if (!$id) {
 
-             throw new ResponseException('订单不存在!');
 
-         }
 
-         $res = Order::where(['uid'=>$user->id,'utype'=>$user->utype])->get()->toArray();
 
-         $array_id = array_column($res,'id');
 
-         if(!in_array($id,$array_id)){
 
-             throw new ResponseException('订单不存在!');
 
-         }
 
-         return Order::where(['id'=>$id])->update(['is_pay'=>3]);
 
-     }
 
-     public function order_delete($id,$user)
 
-     {
 
-         if (!$id) {
 
-             throw new ResponseException('订单不存在!');
 
-         }
 
-         $res = Order::where(['uid'=>$user->id,'utype'=>$user->utype])->get()->toArray();
 
-         $array_id = array_column($res,'id');
 
-         if(!in_array($id,$array_id)){
 
-             throw new ResponseException('订单不存在!');
 
-         }
 
-         return Order::where(['id'=>$id])->delete();
 
-     }
 
-     public function payAgain($id, $route)
 
-     {
 
-         if (!$id) {
 
-             throw new ResponseException('订单不存在!');
 
-         }
 
-         $order = Order::where(['id'=>$id])->first();
 
-         if ($order) {
 
-             if (is_weixin()) {
 
-                 $type = 'wap';
 
-             } else {
 
-                 if (strpos($route->uri,'mobile')!== false) {
 
-                     $type = 'wap';
 
-                 } else {
 
-                     if ($order->payment=='wechat') {
 
-                         $type = 'scan';
 
-                     } else {
 
-                         $type = 'web';
 
-                     }
 
-                 }
 
-             }
 
-             $payorder = PayOrder::where(['trade_no'=>$order->oid])->first();
 
-             if ($type == 'web') {
 
-                 $payorder->return_url=route('person.order_list');
 
-             }
 
-             if ($type=='wap') {
 
-                 $payorder->return_url=route('mobile.person.order_list');
 
-             }
 
-             $result=$this->PayService->pay($order->payment, $type, $payorder);
 
-             
 
-             if ($order->payment=='wechat') {
 
-                 if ($type=='wap') {
 
-                     return [
 
-                         'code'=>'wechat',
 
-                         'tradeCode'=>$result,
 
-                         'type'=>$type
 
-                     ];
 
-                 } else {
 
-                     return [
 
-                         'code'=>'wechat',
 
-                         'tradeCode'=>get_qrcode_html($result->code_url),
 
-                         'tradeNo'=>[
 
-                             'number'=>$payorder->trade_no,
 
-                         ],
 
-                         'type'=>$type
 
-                     ];
 
-                 }
 
-             } else {
 
-                 return [
 
-                     'code'=>'alipay',
 
-                     'tradeCode'=>$result,
 
-                 ];
 
-             }
 
-         } else {
 
-             throw new ResponseException('订单不存在,数据异常!');
 
-         }
 
-     }
 
- }
 
 
  |