1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183 |
- <?php
- namespace addons\unishop\controller;
- use addons\unishop\extend\Hashids;
- use addons\unishop\model\Area;
- use addons\unishop\model\Config;
- use addons\unishop\model\Evaluate;
- use addons\unishop\model\Product;
- use app\admin\model\unishop\Coupon as CouponModel;
- use addons\unishop\model\DeliveryRule as DeliveryRuleModel;
- use addons\unishop\model\OrderRefund;
- use app\admin\model\unishop\OrderRefundProduct;
- use think\Db;
- use think\Exception;
- use addons\unishop\model\Address as AddressModel;
- use think\Hook;
- use think\Loader;
- use addons\epay\library\Service;
- class Order extends Base
- {
-
- protected $frequently = ['getorders','detail'];
- protected $noNeedLogin = ['count'];
-
- public function create()
- {
- $productId = input('id', 0);
- try {
- $user_id = $this->auth->id;
-
-
- $number = input('number',1,'intval');
- $number = intval($number);
- $productId = \addons\unishop\extend\Hashids::decodeHex($productId);
- $product = (new Product)->where(['id' => $productId, 'switch' => Product::SWITCH_ON, 'deletetime' => null])->find();
-
- $spec = input('spec', '');
- $productData[0] = $product->getDataOnCreateOrder($spec,$number);
-
- if (empty($productData) || !$productData) {
- $this->error(__('Product not exist'));
- }
-
-
-
-
-
- $order_price = '0';
- foreach ($productData as &$product) {
- $product['image'] = Config::getImagesFullUrl($product['image']);
- $product['sales_price'] = round($product['sales_price'], 2);
- $product['market_price'] = round($product['market_price'], 2);
- $order_price = bcadd($order_price,$product['total_price'],2);
- }
- $coupon = Db::name('unishop_coupon_user')->alias('cu')
- ->field(['cu.id','c.title','c.least','c.value','c.starttime','c.endtime'])
- ->join('unishop_coupon c','cu.coupon_id = c.id','LEFT')
- ->where('cu.user_id',$this->auth->id)
- ->where('cu.status',0)
- ->where('c.deletetime',NULL)
- ->where('c.switch',1)
- ->where('c.starttime','<',time())
- ->where('c.endtime','>',time())
- ->where('c.least','>=',$order_price)
- ->select();
- $this->success('', [
- 'product' => $productData,
- 'coupon' => $coupon,
- 'order_price' => $order_price,
- 'total_price' => $order_price
- ]);
- } catch (Exception $e) {
- $this->error($e->getMessage(), false);
- }
- }
-
- public function submit()
- {
- $data = input();
- try {
- $validate = Loader::validate('\\addons\\unishop\\validate\\Order');
- if (!$validate->check($data, [], 'submit')) {
- throw new Exception($validate->getError());
- }
- Db::startTrans();
-
- if (empty(Hook::get('create_order_before'))) {
- Hook::add('create_order_before', 'addons\\unishop\\behavior\\Order');
- }
-
- if (empty(Hook::get('create_order_after'))) {
- Hook::add('create_order_after', 'addons\\unishop\\behavior\\Order');
- }
- $orderModel = new \addons\unishop\model\Order();
- $result = $orderModel->createOrder($this->auth->id, $data);
- Db::commit();
- } catch (Exception $e) {
- Db::rollback();
- $this->error($e->getMessage(), false);
- }
- $this->success('', $result);
- }
-
- public function getDelivery()
- {
- $cityId = input('city_id', 0);
- $delivery = (new DeliveryRuleModel())->getDelivetyByArea($cityId);
- $this->success('', $delivery['list']);
- }
-
- public function getOrders()
- {
-
- $type = input('type', 0);
- $page = input('page', 1);
- $pagesize = input('pagesize', 10);
- try {
- $orderModel = new \addons\unishop\model\Order();
- $result = $orderModel->getOrdersByType($this->auth->id, $type, $page, $pagesize);
- } catch (Exception $e) {
- $this->error($e->getMessage());
- }
- $this->success('', $result);
- }
-
- public function cancel()
- {
- $order_id = input('order_id', 0);
- $order_id = \addons\unishop\extend\Hashids::decodeHex($order_id);
- $orderModel = new \addons\unishop\model\Order();
- $order = $orderModel->where(['id' => $order_id, 'user_id' => $this->auth->id])->find();
- if (!$order) {
- $this->error(__('Order not exist'));
- }
- switch ($order['status']) {
- case \addons\unishop\model\Order::STATUS_REFUND:
- $this->error('此订单已退款,无法取消');
- break;
- case \addons\unishop\model\Order::STATUS_CANCEL:
- $this->error('此订单已取消, 无需再取消');
- break;
- }
- if ($order['have_paid'] != \addons\unishop\model\Order::PAID_NO) {
- $this->error('此订单已支付,无法取消');
- }
- if ($order['have_received'] != \addons\unishop\model\Order::RECEIVED_NO) {
- $this->error('此订单已核销,无法取消');
- }
- if ($order['status'] == \addons\unishop\model\Order::STATUS_NORMAL && $order['have_paid'] == \addons\unishop\model\Order::PAID_NO) {
- $order->status = \addons\unishop\model\Order::STATUS_CANCEL;
- $order->canceltime = time();
- $order->save();
- $this->success('取消成功', true);
- }
- }
-
- public function payed_cancel()
- {
- $order_id = input('order_id', 0);
- $order_id = \addons\unishop\extend\Hashids::decodeHex($order_id);
- $orderModel = new \addons\unishop\model\Order();
- $order = $orderModel->where(['id' => $order_id, 'user_id' => $this->auth->id])->find();
- if (!$order) {
- $this->error(__('Order not exist'));
- }
- switch ($order['status']) {
- case \addons\unishop\model\Order::STATUS_REFUND:
- $this->error('此订单已退款,无法取消');
- break;
- case \addons\unishop\model\Order::STATUS_CANCEL:
- $this->error('此订单已取消, 无需再取消');
- break;
- }
- if ($order['have_paid'] == \addons\unishop\model\Order::PAID_NO) {
- $this->error('未支付订单,直接取消即可');
- }
- if ($order['have_received'] != \addons\unishop\model\Order::RECEIVED_NO) {
- $this->error('此订单已核销,无法退订');
- }
- Db::startTrans();
- if ($order['status'] == \addons\unishop\model\Order::STATUS_NORMAL && $order['have_received'] == \addons\unishop\model\Order::RECEIVED_NO) {
- $refund_amount = $order['total_price'];
- $refund_status = 3;
-
- $params = [
- 'refund_status' => $refund_status,
- 'updatetime' => time(),
- 'refund_amount' => $refund_amount,
- 'status' => \addons\unishop\model\Order::STATUS_CANCEL,
- 'canceltime' => time(),
- ];
- if($refund_status == 3) {
- $params['had_refund'] = time();
- }
- $result = Db::name('unishop_order')->where(['id' => $order_id])->update($params);
- if (!$result) {
- Db::rollback();
- $this->error('取消失败');
- }
-
- if($refund_status == 3 && $refund_amount > 0){
- $order = Db::name('unishop_order')->where('id',$order_id)->find();
- if($order['pay_type'] == 3){
- $refund_result = $this->old_refund($order,$refund_amount);
- if($refund_result !== true){
- Db::rollback();
- $this->error($refund_result);
- }
- }
- }
- }
- Db::commit();
- $this->success('退订成功', true);
- }
-
- public function old_refund($order, $refund_price)
- {
- return true;
- $table = 'unishop_order';
- $remark = '订单退款';
- if($order['pay_type'] == 3){
- $order['pay_type'] = 'wechat';
- }
- if($order['pay_type'] == 4){
- $order['pay_type'] = 'alipay';
- }
-
- $refund_data = [
- 'order_id' => $order['id'],
- 'out_refund_no'=> createUniqueNo('R'),
- 'pay_fee' => $order['total_price'],
- 'refund_price' => $refund_price,
- 'pay_type' => $order['pay_type'],
- 'status' => 0,
- 'createtime' => time(),
- 'updatetime' => time(),
- 'table' => $table,
- 'table_id' => $order['id'],
- ];
- $refund_log_id = Db::name('pay_order_refund_log')->insertGetId($refund_data);
- if(!$refund_log_id){
- return '退款失败';
- }
- if ($order['pay_type'] == 'wechat' || $order['pay_type'] == 'alipay') {
-
-
- $order_data = [
- 'out_trade_no' => $order['pay_out_trade_no']
- ];
- if ($order['pay_type'] == 'wechat') {
- $total_fee = $order['total_price'] * 100;
- $refund_fee = $refund_price * 100;
- $order_data = array_merge($order_data, [
- 'out_refund_no' => $refund_data['out_refund_no'],
- 'total_fee' => $total_fee,
- 'refund_fee' => $refund_fee,
- 'refund_desc' => $remark,
- ]);
- } else {
- $order_data = array_merge($order_data, [
- 'out_request_no' => $refund_data['out_refund_no'],
- 'refund_amount' => $refund_price,
- ]);
- }
-
- if ($order['pay_type'] == 'wechat') {
- $wxpay = new \app\common\library\Wxpay;
- $result = $wxpay->WxPayRefund($order_data);
-
- if ($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS') {
- Db::name('pay_order_refund_log')->where('id',$refund_log_id)->update(['status'=>1]);
- return true;
- } else {
- return $result['return_msg'];
- }
- } else {
- $result = Service::submitRefund($order['total_price'],$refund_price,$order['pay_out_trade_no'],$refund_data['out_refund_no'],$order['pay_type'],$remark,'');
- if($result['code'] == '10000'){
- Db::name('pay_order_refund_log')->where('id',$refund_log_id)->update(['status'=>1]);
- return true;
- }else{
- return $result['msg'];
- }
-
-
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- return true;
- }
-
- public function delete()
- {
- $order_id = input('order_id', 0);
- $order_id = \addons\unishop\extend\Hashids::decodeHex($order_id);
- $orderModel = new \addons\unishop\model\Order();
- $order = $orderModel->where(['id' => $order_id, 'user_id' => $this->auth->id])->find();
- if (!$order) {
- $this->error(__('Order not exist'));
- }
- if ($order['status'] == \addons\unishop\model\Order::STATUS_NORMAL) {
- $this->error('只能删除已取消或已退货的订单');
- }
- if ($order['status'] == \addons\unishop\model\Order::STATUS_REFUND && $order['refund_status'] == \addons\unishop\model\Order::REFUND_STATUS_APPLY) {
- $this->error('订单退款中,不可删除订单');
- }
- $order->delete();
- $this->success('删除成功', true);
- }
-
- public function received()
- {
- $order_id = input('order_id', 0);
- $order_id = \addons\unishop\extend\Hashids::decodeHex($order_id);
- $orderModel = new \addons\unishop\model\Order();
- $order = $orderModel->where(['id' => $order_id, 'user_id' => $this->auth->id])->find();
- if (!$order) {
- $this->error(__('Order not exist'));
- }
- if ($order->have_delivered == 0) {
- $this->error('未发货,不能确认收货');
- }
- $order->have_received = time();
- $order->save();
- $this->success('已确认收货', true);
- }
-
- public function comment()
- {
- $rate = input('rate', 5);
- $anonymous = input('anonymous', 0);
- $comment = input('comment');
- $order_id = input('order_id', 0);
- $order_id = \addons\unishop\extend\Hashids::decodeHex($order_id);
- $product_id = input('product_id');
- $product_id = \addons\unishop\extend\Hashids::decodeHex($product_id);
- $orderProductModel = new \addons\unishop\model\OrderProduct();
- $orderProduct = $orderProductModel->where(['product_id' => $product_id, 'order_id' => $order_id, 'user_id' => $this->auth->id])->find();
- $orderModel = new \addons\unishop\model\Order();
- $order = $orderModel->where(['id' => $order_id, 'user_id' => $this->auth->id])->find();
- if (!$orderProduct || !$order) {
- $this->error(__('Order not exist'));
- }
- if ($order->have_received == $orderModel::RECEIVED_NO) {
- $this->error(__('未收货,不可评价'));
- }
- $result = false;
- try {
- $evaluate = new Evaluate();
- $evaluate->user_id = $this->auth->id;
- $evaluate->order_id = $order_id;
- $evaluate->product_id = $product_id;
- $evaluate->rate = $rate;
- $evaluate->anonymous = $anonymous;
- $evaluate->comment = $comment;
- $evaluate->spec = $orderProduct->spec;
- $result = $evaluate->save();
- if ($result) {
- $order->have_commented = time();
- $order->save();
- }
- } catch (Exception $e) {
- $this->error($e->getMessage());
- }
- if ($result !== false) {
- $this->success(__('Thanks for the evaluation'));
- } else {
- $this->error(__('Evaluation failure'));
- }
- }
-
- public function count()
- {
- if (!$this->auth->isLogin()) {
- $this->error('');
- }
- $order = new \addons\unishop\model\Order();
- $list = $order
- ->where([
- 'user_id' => $this->auth->id,
- ])
- ->where('status', '<>', \addons\unishop\model\Order::STATUS_CANCEL)
- ->where(function ($query) {
- $query
- ->whereOr([
- 'have_paid' => \addons\unishop\model\Order::PAID_NO,
- 'have_delivered' => \addons\unishop\model\Order::DELIVERED_NO,
- 'have_received' => \addons\unishop\model\Order::RECEIVED_NO,
- 'have_commented' => \addons\unishop\model\Order::COMMENTED_NO
- ])
- ->whereOr('refund_status', '>', \addons\unishop\model\Order::REFUND_STATUS_NONE);
- })
- ->field('have_paid,have_delivered,have_received,have_commented,refund_status,had_refund')
- ->select();
- $data = [
- 'unpaid' => 0,
- 'undelivered' => 0,
- 'unreceived' => 0,
- 'uncomment' => 0,
- 'refund' => 0
- ];
- foreach ($list as $item) {
- switch (true) {
- case $item['have_paid'] > 0 && $item['have_delivered'] > 0 && $item['have_received'] > 0 && $item['have_commented'] == 0 && $item['refund_status'] == 0:
- $data['uncomment']++;
- break;
- case $item['have_paid'] > 0 && $item['have_delivered'] > 0 && $item['have_received'] == 0 && $item['have_commented'] == 0 && $item['refund_status'] == 0:
- $data['unreceived']++;
- break;
- case $item['have_paid'] > 0 && $item['have_delivered'] == 0 && $item['have_received'] == 0 && $item['have_commented'] == 0 && $item['refund_status'] == 0:
- $data['undelivered']++;
- break;
- case $item['have_paid'] == 0 && $item['have_delivered'] == 0 && $item['have_received'] == 0 && $item['have_commented'] == 0 && $item['refund_status'] == 0:
- $data['unpaid']++;
- break;
- case $item['refund_status'] > 0 && $item['had_refund'] == 0 && $item['refund_status'] != 3:
- $data['refund']++;
- break;
- }
- }
- $this->success('', $data);
- }
-
- public function detail()
- {
- $order_id = input('order_id', 0);
- $order_id = \addons\unishop\extend\Hashids::decodeHex($order_id);
- try {
- $orderModel = new \addons\unishop\model\Order();
- $order = $orderModel
- ->with([
- 'products' => function ($query) {
- $query->field('id,order_id,image,number,price,spec,title,product_id');
- },
-
- ])
- ->where(['id' => $order_id, 'user_id' => $this->auth->id])->find();
- if ($order) {
- $order = $order->append(['state', 'paidtime', 'deliveredtime', 'receivedtime', 'commentedtime', 'pay_type_text', 'refund_status_text'])->toArray();
-
-
-
-
-
- foreach ($order['products'] as &$product) {
- $product['image'] = Config::getImagesFullUrl($product['image']);
-
- }
- unset($order['extend']);
- unset($order['pay_out_trade_no']);
-
- $week_data = [
- 0 => '周日',
- 1 => '周一',
- 2 => '周二',
- 3 => '周三',
- 4 => '周四',
- 5 => '周五',
- 6 => '周六',
- 7 => '周日',
- ];
- $order['bookdate'] = date('Y-m-d H:i',$order['booktime']) .' '. $week_data[date('w',$order['booktime'])];
-
- $order['order_refund_rule'] = config('site.order_refund_rule');
-
- $qrcode_string = 'order_hexiao_no|' . $order['out_trade_no'];
- $order['order_hexiao_qrcode'] = httpurllocal($this->inviteimage($qrcode_string));
- }
- } catch (Exception $e) {
- $this->error($e->getMessage());
- }
- $this->success('', $order);
- }
-
- private function inviteimage($introcode) {
- $params['text'] = $introcode;
- $qrcode_service = \addons\qrcode\library\Service::qrcode($params);
- $qrcodePath = ROOT_PATH . 'public/uploads/qrcode/';
- if (!is_dir($qrcodePath)) {
- @mkdir($qrcodePath);
- }
- if (is_really_writable($qrcodePath)) {
- $filename = md5(implode('', $params)) . '.png';
- $filePath = $qrcodePath . $filename;
- $qrcode_service->writeFile($filePath);
- }
- return '/uploads/qrcode/' . $filename;
- }
-
- public function refundInfo()
- {
- $order_id = input('order_id');
- $order_id = \addons\unishop\extend\Hashids::decodeHex($order_id);
- $orderModel = new \addons\unishop\model\Order();
- $order = $orderModel
- ->with([
- 'products' => function ($query) {
- $query->field('id,order_id,image,number,price,spec,title,product_id,(1) as choose');
- },
- 'refund',
- 'refundProducts'
- ])
- ->field('id,status,total_price,delivery_price,have_commented,have_delivered,have_paid,have_received,refund_status')
- ->where(['id' => $order_id, 'user_id' => $this->auth->id])->find();
- if (!$order) {
- $this->error(__('Order not exist'));
- }
- $order = $order->append(['refund_status_text'])->toArray();
- foreach ($order['products'] as &$product) {
- $product['image'] = Config::getImagesFullUrl($product['image']);
- $product['choose'] = 0;
-
- if ($order['status'] == \addons\unishop\model\Order::STATUS_REFUND) {
- foreach ($order['refund_products'] as $refundProduct) {
- if ($product['order_product_id'] == $refundProduct['order_product_id']) {
- $product['choose'] = 1;
- }
- }
- }
- }
- unset($order['refund_products']);
- $this->success('', $order);
- }
-
- public function refund()
- {
- $order_id = input('order_id');
- $order_id = Hashids::decodeHex($order_id);
- $orderModel = new \addons\unishop\model\Order();
- $order = $orderModel->where(['id' => $order_id, 'user_id' => $this->auth->id])->find();
- if (!$order) {
- $this->error(__('Order not exist'));
- }
- if ($order['have_paid'] == 0) {
- $this->error(__('订单未支付,可直接取消,无需申请售后'));
- }
- $amount = input('amount', 0);
- $serviceType = input('service_type');
- $receivingStatus = input('receiving_status');
- $reasonType = input('reason_type');
- $refundExplain = input('refund_explain');
- $orderProductId = input('order_product_id');
- if (!$orderProductId) {
- $this->error(__('Please select goods'));
- }
- if (!in_array($receivingStatus, [OrderRefund::UNRECEIVED, OrderRefund::RECEIVED])) {
- $this->error(__('Please select goods status'));
- }
- if (!in_array($serviceType, [OrderRefund::TYPE_REFUND_NORETURN, OrderRefund::TYPE_REFUND_RETURN, OrderRefund::TYPE_EXCHANGE])) {
- $this->error(__('Please select service type'));
- }
- if (in_array($serviceType, [OrderRefund::TYPE_REFUND_NORETURN, OrderRefund::TYPE_REFUND_RETURN]) && $order['total_price'] > 0) {
- if (!$amount) {
- $this->error(__('Please fill in the refund amount'));
- }
- }
- try {
- Db::startTrans();
- $orderRefund = new OrderRefund();
- $orderRefund->user_id = $this->auth->id;
- $orderRefund->order_id = $order_id;
- $orderRefund->receiving_status = $receivingStatus;
- $orderRefund->service_type = $serviceType;
- $orderRefund->reason_type = $reasonType;
- $orderRefund->amount = $amount;
- $orderRefund->refund_explain = $refundExplain;
- $orderRefund->save();
- $productIdArr = explode(',', $orderProductId);
- $refundProduct = [];
- foreach ($productIdArr as $orderProductId) {
- $tmp['order_product_id'] = $orderProductId;
- $tmp['order_id'] = $order_id;
- $tmp['user_id'] = $this->auth->id;
- $tmp['refund_id'] = $orderRefund['id'];
- $tmp['createtime'] = time();
- $refundProduct[] = $tmp;
- }
- (new OrderRefundProduct)->insertAll($refundProduct);
- $order->status = \addons\unishop\model\Order::STATUS_REFUND;
- $order->refund_status = \addons\unishop\model\Order::REFUND_STATUS_APPLY;
- $order->save();
- Db::commit();
- } catch (Exception $e) {
- Db::rollback();
- $this->error($e->getMessage());
- }
- $this->success('已申请', 1);
- }
-
- public function refundDelivery()
- {
- $orderId = input('order_id');
- $expressNumber = input('express_number');
- if (!$expressNumber) {
- $this->error(__('Please fill in the express number'));
- }
- $orderId = Hashids::decodeHex($orderId);
- $orderModel = new \addons\unishop\model\Order();
- $order = $orderModel
- ->where(['id' => $orderId, 'user_id' => $this->auth->id])
- ->with(['refund'])->find();
- if (!$order || !$order->refund) {
- $this->error(__('Order not exist'));
- }
- try {
- Db::startTrans();
- $order->refund->express_number = $expressNumber;
- $order->refund_status = \addons\unishop\model\Order::REFUND_STATUS_APPLY;
- if ($order->refund->save() && $order->save()) {
- Db::commit();
- } else {
- throw new Exception(__('Operation failed'));
- }
- } catch (Exception $e) {
- Db::rollback();
- $this->success($e->getMessage());
- }
- $this->success('', 1);
- }
-
- public function express() {
- $params = input();
- if (!class_exists(\addons\expressquery\library\Expressquery::class)) {
- $this->error('请先安装插件《物流信息接口》', []);
- }
- $info = get_addon_info('expressquery');
- if ($info['state'] == 0) {
- $this->error('请开启插件《物流信息接口》', []);
- }
- $expModle = new \addons\expressquery\library\Expressquery();
- $list = $expModle->getExpressList($params['express'], $params['expresssn']);
- if ($list['code'] == 0) {
- $this->error($list['msg']);
- }
- $expressInfo = Db::name('expressquery')->where(['express' => $params['express']])->find();
- $this->success('', [
- 'message' => $list['data'] ?? [],
- 'company' => $expressInfo['name'] ?? '快递单号'
- ]);
- }
-
- public function show_hexiao_qrcode(){
- }
-
- public function tuiding(){}
- }
|