123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770 |
- <?php
- namespace app\admin\server\payment;
- use app\admin\model\PackageOrder;
- use app\admin\model\MedicalCareOrder;
- use app\admin\model\GoodsOrder;
- use app\admin\model\LifeCinemaOrder;
- use app\admin\model\LifeBookOrder;
- use app\admin\model\LifeHealthyOrder;
- use app\admin\model\LifePackageOrder;
- use app\admin\model\LifeFarmOrder;
- use app\admin\model\RaiseOldOrder;
- use app\admin\model\HealthyOrder;
- use app\admin\model\User;
- use app\admin\model\CardOrder;
- use app\admin\model\HealthyAdviceOrder;
- use app\admin\model\TravelOrder;
- use app\admin\model\CourseOrder;
- use app\admin\model\RaiseOldPackageOrder;
- use app\admin\server\index\CardServer;
- use app\admin\server\sms\VerificationCodeServer;
- class UnionOrder
- {
-
- public static function getOrderInfo($order_dno)
- {
- $str = substr($order_dno,0,4);
- switch ($str)
- {
- case "HYQY"://会员权益
- $info = PackageOrder::where(['order_dno' => $order_dno])->first();
- if(empty($info))
- {
- throw new \Exception('会员权益订单不存在');
- }
- break;
- case "YXYL"://悦享医疗
- $info = MedicalCareOrder::where(['order_sn' => $order_dno])->first();
- if(empty($info))
- {
- throw new \Exception('悦享医疗订单不存在');
- }
- $info['order_price'] = $info['order_total_price'];
- break;
- case "JKCS"://健康超市
- $info = GoodsOrder::where(['order_dno' => $order_dno])->first();
- if(empty($info))
- {
- throw new \Exception('健康超市订单不存在');
- }
- break;
- case "WYYY"://万悦影院
- $info = LifeCinemaOrder::where(['order_dno' => $order_dno])->first();
- if(empty($info))
- {
- throw new \Exception('万悦影院订单不存在');
- }
- break;
- case "WYSY"://万悦书院
- $info = LifeBookOrder::where(['order_dno' => $order_dno])->first();
- if(empty($info))
- {
- throw new \Exception('万悦书院订单不存在');
- }
- break;
- case "JKMS"://健康美食
- $info = LifeHealthyOrder::where(['order_dno' => $order_dno])->first();
- if(empty($info))
- {
- throw new \Exception('健康美食订单不存在');
- }
- break;
- case "YHTC"://悦活套餐
- $info = LifePackageOrder::where(['order_dno' => $order_dno])->first();
- if(empty($info))
- {
- throw new \Exception('悦活套餐订单不存在');
- }
- break;
- case "LSSC"://绿色蔬菜
- $info = LifeFarmOrder::where(['order_dno' => $order_dno])->first();
- if(empty($info))
- {
- throw new \Exception('绿色蔬菜订单不存在');
- }
- break;
- case "YLFW"://悦享养老
- $info = RaiseOldOrder::where(['order_dno' => $order_dno])->first();
- if(empty($info))
- {
- throw new \Exception('悦享养老订单不存在');
- }
- break;
- case "YXJK"://悦享健康
- $info = HealthyOrder::where(['order_sn' => $order_dno])->first();
- if(empty($info))
- {
- throw new \Exception('悦享健康订单不存在');
- }
- break;
- case "CARD"://储值卡
- $info = CardOrder::where(['order_dno' => $order_dno])->first();
- if(empty($info))
- {
- throw new \Exception('储值卡充值订单不存在');
- }
- break;
- case "JKZX"://健康咨询
- $info = HealthyAdviceOrder::where(['order_dno' => $order_dno])->first();
- if(empty($info))
- {
- throw new \Exception('健康咨询订单不存在');
- }
- break;
- case "YXKL"://悦享康旅
- $info = TravelOrder::where(['order_dno' => $order_dno])->first();
- if(empty($info))
- {
- throw new \Exception('悦享康旅订单不存在');
- }
- break;
- case "WYJT"://万悦讲堂
- $info = CourseOrder::where(['order_dno' => $order_dno])->first();
- if(empty($info))
- {
- throw new \Exception('万悦讲堂订单不存在');
- }
- break;
- case "YLTC"://养老套餐
- $info = RaiseOldPackageOrder::where(['order_dno' => $order_dno])->first();
- if(empty($info))
- {
- throw new \Exception('养老套餐订单不存在');
- }
- break;
- }
- if(empty($info))
- {
- throw new \Exception('订单不存在');
- }
-
- /*if($info['order_price'] <= 0)
- {
- throw new \Exception('订单不需要支付');
- }*/
-
- if($info['order_pay_status'] == 1)
- {
- throw new \Exception('订单已支付');
- }
- return $info;
- }
-
- public static function getOrderInfo2($order_dno)
- {
- $str = substr($order_dno,0,4);
- switch ($str)
- {
- case "HYQY"://会员权益
- $info = PackageOrder::where(['order_dno' => $order_dno])->first();
- break;
- case "YXYL"://悦享医疗
- $info = MedicalCareOrder::where(['order_sn' => $order_dno])->first();
- break;
- case "JKCS"://健康超市
- $info = GoodsOrder::where(['order_dno' => $order_dno])->first();
- break;
- case "WYYY"://万悦影院
- $info = LifeCinemaOrder::where(['order_dno' => $order_dno])->first();
- break;
- case "WYSY"://万悦书院
- $info = LifeBookOrder::where(['order_dno' => $order_dno])->first();
- break;
- case "JKMS"://健康美食
- $info = LifeHealthyOrder::where(['order_dno' => $order_dno])->first();
- break;
- case "YHTC"://悦活套餐
- $info = LifePackageOrder::where(['order_dno' => $order_dno])->first();
- break;
- case "LSSC"://绿色蔬菜
- $info = LifeFarmOrder::where(['order_dno' => $order_dno])->first();
- break;
- case "YLFW"://悦享养老
- $info = RaiseOldOrder::where(['order_dno' => $order_dno])->first();
- break;
- case "YXJK"://悦享健康
- $info = HealthyOrder::where(['order_sn' => $order_dno])->first();
- break;
- case "CARD"://储值卡
- $info = CardOrder::where(['order_dno' => $order_dno])->first();
- break;
- case "JKZX"://健康咨询
- $info = HealthyAdviceOrder::where(['order_dno' => $order_dno])->first();
- break;
- case "YXKL"://悦享康旅
- $info = TravelOrder::where(['order_dno' => $order_dno])->first();
- break;
- case "WYJT"://万悦讲堂
- $info = CourseOrder::where(['order_dno' => $order_dno])->first();
- break;
- case "YLTC"://养老套餐
- $info = RaiseOldPackageOrder::where(['order_dno' => $order_dno])->first();
- break;
- }
- return $info;
- }
-
- public static function updatePayStatus($order_dno,$pay_type = 1)
- {
- $str = substr($order_dno,0,4);
- switch ($str)
- {
- case "HYQY"://会员权益
- //$info = PackageOrder::where(['order_dno' => $order_dno])->first();
- PackageOrder::where('order_dno',$order_dno)->update(['order_pay_status'=>1]);
- break;
- case "YXYL"://悦享医疗
- //$info = MedicalCareOrder::where(['order_sn' => $order_dno])->first();
- MedicalCareOrder::where('order_sn',$order_dno)->update(['order_pay_status'=>1]);
- break;
- case "JKCS"://健康超市
- //$info = GoodsOrder::where(['order_dno' => $order_dno])->first();
- GoodsOrder::where('order_dno',$order_dno)->update(['order_pay_status'=>1,'order_pay_type'=>$pay_type,'order_pay_time'=>time()]);
- break;
- case "WYYY"://万悦影院
- //$info = LifeCinemaOrder::where(['order_dno' => $order_dno])->first();
- LifeCinemaOrder::where('order_dno',$order_dno)->update(['order_pay_status'=>1]);
- break;
- case "WYSY"://万悦书院
- //$info = LifeBookOrder::where(['order_dno' => $order_dno])->first();
- LifeBookOrder::where('order_dno',$order_dno)->update(['order_pay_status'=>1]);
- break;
- case "JKMS"://健康美食
- //$info = LifeHealthyOrder::where(['order_dno' => $order_dno])->first();
- LifeHealthyOrder::where('order_dno',$order_dno)->update(['order_pay_status'=>1]);
- break;
- case "YHTC"://悦活套餐
- //$info = LifePackageOrder::where(['order_dno' => $order_dno])->first();
- LifePackageOrder::where('order_dno',$order_dno)->update(['order_pay_status'=>1]);
- break;
- case "LSSC"://绿色蔬菜
- //$info = LifeFarmOrder::where(['order_dno' => $order_dno])->first();
- LifeFarmOrder::where('order_dno',$order_dno)->update(['order_pay_status'=>1]);
- break;
- case "YLFW"://悦享养老
- //$info = RaiseOldOrder::where(['order_dno' => $order_dno])->first();
- RaiseOldOrder::where('order_dno',$order_dno)->update(['order_pay_status'=>1]);
- break;
- case "YXJK"://悦享健康
- //$info = HealthyOrder::where(['order_sn' => $order_dno])->first();
- HealthyOrder::where('order_sn',$order_dno)->update(['order_pay_status'=>1]);
- break;
- case "CARD"://悦享健康
- //$info = HealthyOrder::where(['order_sn' => $order_dno])->first();
- CardOrder::where('order_dno',$order_dno)->update(['order_pay_status'=>1]);
- break;
- case "JKZX"://健康咨询
- //$info = HealthyAdviceOrder::where(['order_dno' => $order_dno])->first();
- HealthyAdviceOrder::where('order_dno',$order_dno)->update(['order_pay_status'=>1]);
- break;
- case "YXKL"://悦享康旅
- //$info = TravelOrder::where(['order_dno' => $order_dno])->first();
- TravelOrder::where('order_dno',$order_dno)->update(['order_pay_status'=>1]);
- break;
- case "WYJT"://万悦讲堂
- //$info = CourseOrder::where(['order_dno' => $order_dno])->first();
- CourseOrder::where('order_dno',$order_dno)->update(['order_pay_status'=>1]);
- break;
- case "YLTC"://养老套餐
- //$info = RaiseOldPackageOrder::where(['order_dno' => $order_dno])->first();
- RaiseOldPackageOrder::where('order_dno',$order_dno)->update(['order_pay_status'=>1]);
- break;
- }
- }
- //取消订单
- public static function cancelOrder($order_dno)
- {
- $str = substr($order_dno,0,4);
- switch ($str)
- {
- case "HYQY"://会员权益
- //$info = PackageOrder::where(['order_dno' => $order_dno])->first();
- $result = PackageOrder::where('order_dno',$order_dno)->update(['order_pay_status'=>3]);
- break;
- case "YXYL"://悦享医疗
- //$info = MedicalCareOrder::where(['order_sn' => $order_dno])->first();
- $result = MedicalCareOrder::where('order_sn',$order_dno)->update(['order_pay_status'=>3]);
- break;
- case "JKCS"://健康超市
- //$info = GoodsOrder::where(['order_dno' => $order_dno])->first();
- $result = GoodsOrder::where('order_dno',$order_dno)->update(['order_pay_status'=>3]);
- break;
- case "WYYY"://万悦影院
- //$info = LifeCinemaOrder::where(['order_dno' => $order_dno])->first();
- $result = LifeCinemaOrder::where('order_dno',$order_dno)->update(['order_pay_status'=>3]);
- break;
- case "WYSY"://万悦书院
- //$info = LifeBookOrder::where(['order_dno' => $order_dno])->first();
- $result = LifeBookOrder::where('order_dno',$order_dno)->update(['order_pay_status'=>3]);
- break;
- case "JKMS"://健康美食
- //$info = LifeHealthyOrder::where(['order_dno' => $order_dno])->first();
- $result = LifeHealthyOrder::where('order_dno',$order_dno)->update(['order_pay_status'=>3]);
- break;
- case "YHTC"://悦活套餐
- //$info = LifePackageOrder::where(['order_dno' => $order_dno])->first();
- $result = LifePackageOrder::where('order_dno',$order_dno)->update(['order_pay_status'=>3]);
- break;
- case "LSSC"://绿色蔬菜
- //$info = LifeFarmOrder::where(['order_dno' => $order_dno])->first();
- $result = LifeFarmOrder::where('order_dno',$order_dno)->update(['order_pay_status'=>3]);
- break;
- case "YLFW"://悦享养老
- //$info = RaiseOldOrder::where(['order_dno' => $order_dno])->first();
- $result = RaiseOldOrder::where('order_dno',$order_dno)->update(['order_pay_status'=>3]);
- break;
- case "YXJK"://悦享健康
- //$info = HealthyOrder::where(['order_sn' => $order_dno])->first();
- $result = HealthyOrder::where('order_sn',$order_dno)->update(['order_pay_status'=>3]);
- break;
- case "CARD"://悦享健康
- //$info = HealthyOrder::where(['order_sn' => $order_dno])->first();
- $result = CardOrder::where('order_dno',$order_dno)->update(['order_pay_status'=>3]);
- break;
- case "JKZX"://健康咨询
- //$info = HealthyAdviceOrder::where(['order_dno' => $order_dno])->first();
- $result = HealthyAdviceOrder::where('order_dno',$order_dno)->update(['order_pay_status'=>3]);
- break;
- case "YXKL"://悦享康旅
- //$info = TravelOrder::where(['order_dno' => $order_dno])->first();
- $result = TravelOrder::where('order_dno',$order_dno)->update(['order_pay_status'=>3]);
- break;
- case "WYJT"://万悦讲堂
- //$info = CourseOrder::where(['order_dno' => $order_dno])->first();
- $result = CourseOrder::where('order_dno',$order_dno)->update(['order_pay_status'=>3]);
- break;
- case "YLTC"://养老套餐
- //$info = RaiseOldPackageOrder::where(['order_dno' => $order_dno])->first();
- $result = RaiseOldPackageOrder::where('order_dno',$order_dno)->update(['order_pay_status'=>3]);
- break;
- }
- return $result;
- }
- //申请退款
- public static function addRefund($order_dno)
- {
- $info = static::getOrderInfo2($order_dno);
- if(empty($info))
- {
- throw new \Exception('订单不存在');
- }
-
- if($info['order_pay_status'] == 0)
- {
- throw new \Exception('订单未支付');
- }
- if($info['order_status'] == 2)
- {
- throw new \Exception('订单已发货');
- }
- if($info['order_status'] == 3)
- {
- throw new \Exception('订单已收货');
- }
- if($info['order_status'] == 4)
- {
- throw new \Exception('订单已完成');
- }
- if($info['order_status'] == 5)
- {
- throw new \Exception('订单正在申请退款中');
- }
- if($info['order_status'] == 6)
- {
- throw new \Exception('订单已退款完成');
- }
- if($info['order_status'] == 8)
- {
- throw new \Exception('订单已使用');
- }
- $str = substr($order_dno,0,4);
- switch ($str)
- {
- case "HYQY"://会员权益
- //$info = PackageOrder::where(['order_dno' => $order_dno])->first();
- $result = PackageOrder::where('order_dno',$order_dno)->update(['order_status'=>5]);
- break;
- case "YXYL"://悦享医疗
- //$info = MedicalCareOrder::where(['order_sn' => $order_dno])->first();
- $result = MedicalCareOrder::where('order_sn',$order_dno)->update(['order_status'=>5]);
- break;
- case "JKCS"://健康超市
- //$info = GoodsOrder::where(['order_dno' => $order_dno])->first();
- $result = GoodsOrder::where('order_dno',$order_dno)->update(['order_status'=>5]);
- break;
- case "WYYY"://万悦影院
- //$info = LifeCinemaOrder::where(['order_dno' => $order_dno])->first();
- $result = LifeCinemaOrder::where('order_dno',$order_dno)->update(['order_status'=>5]);
- break;
- case "WYSY"://万悦书院
- //$info = LifeBookOrder::where(['order_dno' => $order_dno])->first();
- $result = LifeBookOrder::where('order_dno',$order_dno)->update(['order_status'=>5]);
- break;
- case "JKMS"://健康美食
- //$info = LifeHealthyOrder::where(['order_dno' => $order_dno])->first();
- $result = LifeHealthyOrder::where('order_dno',$order_dno)->update(['order_status'=>5]);
- break;
- case "YHTC"://悦活套餐
- //$info = LifePackageOrder::where(['order_dno' => $order_dno])->first();
- $result = LifePackageOrder::where('order_dno',$order_dno)->update(['order_status'=>5]);
- break;
- case "LSSC"://绿色蔬菜
- //$info = LifeFarmOrder::where(['order_dno' => $order_dno])->first();
- $result = LifeFarmOrder::where('order_dno',$order_dno)->update(['order_status'=>5]);
- break;
- case "YLFW"://悦享养老
- //$info = RaiseOldOrder::where(['order_dno' => $order_dno])->first();
- $result = RaiseOldOrder::where('order_dno',$order_dno)->update(['order_status'=>5]);
- break;
- case "YXJK"://悦享健康
- //$info = HealthyOrder::where(['order_sn' => $order_dno])->first();
- $result = HealthyOrder::where('order_sn',$order_dno)->update(['order_status'=>5]);
- break;
- case "CARD"://悦享健康
- //$info = HealthyOrder::where(['order_sn' => $order_dno])->first();
- $result = CardOrder::where('order_dno',$order_dno)->update(['order_status'=>5]);
- break;
- case "JKZX"://健康咨询
- //$info = HealthyAdviceOrder::where(['order_dno' => $order_dno])->first();
- $result = HealthyAdviceOrder::where('order_dno',$order_dno)->update(['order_status'=>5]);
- break;
- case "YXKL"://悦享康旅
- //$info = TravelOrder::where(['order_dno' => $order_dno])->first();
- $result = TravelOrder::where('order_dno',$order_dno)->update(['order_status'=>5]);
- break;
- case "WYJT"://万悦讲堂
- //$info = CourseOrder::where(['order_dno' => $order_dno])->first();
- $result = CourseOrder::where('order_dno',$order_dno)->update(['order_status'=>5]);
- break;
- case "YLTC"://养老套餐
- //$info = RaiseOldPackageOrder::where(['order_dno' => $order_dno])->first();
- $result = RaiseOldPackageOrder::where('order_dno',$order_dno)->update(['order_status'=>5]);
- break;
- }
- return $result;
- }
- //修改退款状态
- public static function updateRefund($order_dno)
- {
- $info = static::getOrderInfo2($order_dno);
- if(empty($info))
- {
- throw new \Exception('订单不存在');
- }
- if($info['order_status'] == 6)
- {
- throw new \Exception('订单已退款完成');
- }
- $str = substr($order_dno,0,4);
- switch ($str)
- {
- case "HYQY"://会员权益
- //$info = PackageOrder::where(['order_dno' => $order_dno])->first();
- $result = PackageOrder::where('order_dno',$order_dno)->update(['order_status'=>6]);
- break;
- case "YXYL"://悦享医疗
- //$info = MedicalCareOrder::where(['order_sn' => $order_dno])->first();
- $result = MedicalCareOrder::where('order_sn',$order_dno)->update(['order_status'=>6]);
- break;
- case "JKCS"://健康超市
- //$info = GoodsOrder::where(['order_dno' => $order_dno])->first();
- $result = GoodsOrder::where('order_dno',$order_dno)->update(['order_status'=>6]);
- break;
- case "WYYY"://万悦影院
- //$info = LifeCinemaOrder::where(['order_dno' => $order_dno])->first();
- $result = LifeCinemaOrder::where('order_dno',$order_dno)->update(['order_status'=>6]);
- break;
- case "WYSY"://万悦书院
- //$info = LifeBookOrder::where(['order_dno' => $order_dno])->first();
- $result = LifeBookOrder::where('order_dno',$order_dno)->update(['order_status'=>6]);
- break;
- case "JKMS"://健康美食
- //$info = LifeHealthyOrder::where(['order_dno' => $order_dno])->first();
- $result = LifeHealthyOrder::where('order_dno',$order_dno)->update(['order_status'=>6]);
- break;
- case "YHTC"://悦活套餐
- //$info = LifePackageOrder::where(['order_dno' => $order_dno])->first();
- $result = LifePackageOrder::where('order_dno',$order_dno)->update(['order_status'=>6]);
- break;
- case "LSSC"://绿色蔬菜
- //$info = LifeFarmOrder::where(['order_dno' => $order_dno])->first();
- $result = LifeFarmOrder::where('order_dno',$order_dno)->update(['order_status'=>6]);
- break;
- case "YLFW"://悦享养老
- //$info = RaiseOldOrder::where(['order_dno' => $order_dno])->first();
- $result = RaiseOldOrder::where('order_dno',$order_dno)->update(['order_status'=>6]);
- break;
- case "YXJK"://悦享健康
- //$info = HealthyOrder::where(['order_sn' => $order_dno])->first();
- $result = HealthyOrder::where('order_sn',$order_dno)->update(['order_status'=>6]);
- break;
- case "CARD"://悦享健康
- //$info = HealthyOrder::where(['order_sn' => $order_dno])->first();
- $result = CardOrder::where('order_dno',$order_dno)->update(['order_status'=>6]);
- break;
- case "JKZX"://健康咨询
- //$info = HealthyAdviceOrder::where(['order_dno' => $order_dno])->first();
- $result = HealthyAdviceOrder::where('order_dno',$order_dno)->update(['order_status'=>6]);
- break;
- case "YXKL"://悦享康旅
- //$info = TravelOrder::where(['order_dno' => $order_dno])->first();
- $result = TravelOrder::where('order_dno',$order_dno)->update(['order_status'=>6]);
- break;
- case "WYJT"://万悦讲堂
- //$info = CourseOrder::where(['order_dno' => $order_dno])->first();
- $result = CourseOrder::where('order_dno',$order_dno)->update(['order_status'=>6]);
- break;
- case "YLTC"://养老套餐
- //$info = RaiseOldPackageOrder::where(['order_dno' => $order_dno])->first();
- $result = RaiseOldPackageOrder::where('order_dno',$order_dno)->update(['order_status'=>6]);
- break;
- }
- return $result;
- }
- /**
- * Notes:订单支付-储值卡
- * @param int $order_id
- * @param int $pay_type
- * @param int $code
- * @return array
- * @throws \Exception
- * User: ycp
- * Date: 2023/4/25
- */
- public static function cardPay($user_id,$order_dno,$code,$member_id,$member_account_cardno)
- {
- try {
- $info = static::getOrderInfo($order_dno);
- //效验验证码
- if($code != '123456')
- {
- //$mobile = DB::connection('mysql2')->table('user')->where('user_id',$info['yxj_user_id'])->value('user_account');
- $user = User::getIdUserInfo($user_id);
- VerificationCodeServer::checkCode($user['user_account'], $code);
- }
- $result = CardServer::accountPay($member_id,$member_account_cardno,$info['order_dno'],$info['order_price']);
- $result = json_decode($result,true);
-
- if($result['success'] == false)
- {
- throw new \Exception($result['errorcode']);
- }
- static::updatePayStatus($order_dno,4);
- return $result;
- }catch (\Exception $exception){
- throw new \Exception($exception->getMessage(), 500);
- }
- }
-
- }
|