Browse Source

各处修改

lizhen_gitee 2 months ago
parent
commit
21c358f60b

+ 228 - 0
application/api/controller/Hexiao.php

@@ -0,0 +1,228 @@
+<?php
+
+namespace app\api\controller;
+
+use app\common\controller\Api;
+use think\Db;
+/**
+ * 核销
+ */
+class Hexiao extends Api
+{
+    protected $noNeedLogin = [];
+    protected $noNeedRight = ['*'];
+
+
+    //订单详情
+    //code:order_hexiao_no|2024090466d7c9d5abb1c1
+    //order_no:2024090466d7c9d5abb1c1
+    public function order_info()
+    {
+        if($this->auth->is_hexiao != 1){$this->error('没有核销权限');}
+
+        $code = input('code','');
+        if(strpos($code,'order_hexiao_no|') !== 0){
+            $this->error('识别不到的订单');
+        }
+
+        $order_no = substr($code,16);
+
+        $order_info = Db::name('unishop_order')->where('out_trade_no',$order_no)->find();
+        if(empty($order_info)){
+            $this->error('不存在的订单');
+        }
+        if($order_info['status'] != 1){
+            $this->error('非正常的订单');
+        }
+        if($order_info['have_paid'] == 0){
+            $this->error('未支付的订单');
+        }
+        if($order_info['have_received'] != 0){
+            $this->error('该订单已核销');
+        }
+
+        //下面是从unishop/order.php  detail方法里拿过来的
+        $order_id = $order_info['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');
+                    },
+
+            ])
+            ->where(['id' => $order_id])->find();
+
+        if ($order) {
+            $order = $order->append(['state', 'paidtime'])->toArray();
+
+
+            foreach ($order['products'] as &$product) {
+                $product['image'] = cdnurl($product['image']);
+            }
+
+            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));*/
+
+        }
+
+        //追加退改规则
+        $this->success(1,$order);
+    }
+
+    //完成核销动作
+    public function hexiao(){
+        if($this->auth->is_hexiao != 1){$this->error('没有核销权限');}
+
+        $code = input('code','');
+        if(strpos($code,'order_hexiao_no|') !== 0){
+            $this->error('识别不到的订单');
+        }
+
+        $out_trade_no = substr($code,16);
+
+        Db::startTrans();
+        $order = Db::name('unishop_order')->where(['out_trade_no' => $out_trade_no])->lock(true)->find();
+
+        if (!$order) {
+            Db::rollback();
+            $this->error('不存在的订单');
+        }
+
+        if($order['status'] != 1){
+            Db::rollback();
+            $this->error('非正常的订单');
+        }
+        if($order['have_paid'] == 0){
+            Db::rollback();
+            $this->error('未支付的订单');
+        }
+        if($order['have_received'] != 0){
+            Db::rollback();
+            $this->error('该订单已核销');
+        }
+
+
+        $update = [
+            'have_received' => time(),
+            'hexiao_uid'    => $this->auth->id,
+        ];
+        $order_rs = Db::name('unishop_order')->where('id',$order['id'])->update($update);
+        if($order_rs === false){
+            Db::rollback();
+            $this->error('核销失败');
+        }
+
+        //给核销人结算
+        $bili = config('site.unishop_order_hexiaomoney_bili');
+
+        $money = bcdiv(bcmul($order['total_price'],$bili,2),100,2);
+
+        if($money > 0){
+            $rs_wallet = model('Wallet')->lockChangeAccountRemain($this->auth->id,'hexiaomoney',$money,10,'核销订单:'.$out_trade_no,'unishop_order',$order['id']);
+            if($rs_wallet['status']===false)
+            {
+                Db::rollback();
+                $this->error($rs_wallet['msg']);
+            }
+        }
+
+
+        Db::commit();
+        $this->success('核销成功');
+    }
+
+    //核销记录
+    public function order_list(){
+        if($this->auth->group_id != 3){$this->error('你是不是来错地方了?');}
+
+        $orderModel = new \addons\unishop\model\Order();
+
+        $condition = [
+            'hexiao_uid' => $this->auth->id,
+            'status'     => 1,
+            'have_paid'         => ['gt',0],
+            'have_delivered'    => ['gt',0],
+            'have_received'     => ['gt',0],
+        ];
+        $result = $orderModel
+            ->with([
+                'products' => function($query) {
+                        $query->field('id,title,image,number,price,spec,order_id,product_id');
+                    },
+
+            ])
+            ->where($condition)
+            ->order(['have_received' => 'desc'])
+            ->autopage()
+            ->select();
+
+        //预约日期
+        $week_data = [
+            0 => '周日',
+            1 => '周一',
+            2 => '周二',
+            3 => '周三',
+            4 => '周四',
+            5 => '周五',
+            6 => '周六',
+            7 => '周日',
+        ];
+
+        foreach ($result as &$item) {
+            $item->append(['order_id','state']);
+            $item = $item->toArray();
+
+            unset($item['pay_out_trade_no']);
+
+            /*$evaluate = array_column($item['evaluate'], 'product_id');
+            $refundProducts = array_column($item['refund_products'], 'order_product_id');
+            unset($item['evaluate']);
+            unset($item['refund_products']);*/
+
+            foreach ($item['products'] as &$product) {
+                $product['image'] = cdnurl($product['image']);
+                // 是否已评论
+                /*if (in_array($product['id'], $evaluate)) {
+                    $product['evaluate'] = true;
+                } else {
+                    $product['evaluate'] = false;
+                }*/
+
+                // 是否退货
+                /*if ($item['refund_status'] == self::REFUND_STATUS_AGREE && in_array($product['order_product_id'], $refundProducts)) {
+                    $product['refund'] = true;
+                } else {
+                    $product['refund'] = false;
+                }*/
+            }
+
+
+            $item['bookdate'] = date('Y-m-d H:i',$item['booktime']) .' '. $week_data[date('w',$item['booktime'])];
+
+        }
+
+        $this->success(1,$result);
+
+
+    }
+}

+ 11 - 0
application/api/controller/Userintro.php

@@ -118,6 +118,17 @@ class Userintro extends Api
     }
 
 
+    //我邀请的人列表
+    public function myintro_list(){
+        if($this->auth->group_id != 2){$this->error('你是不是来错地方了?');}
+
+        $list = Db::name('user')->field('id,nickname,avatar,createtime')->where('intro_uid',$this->auth->id)->autopage()->select();
+        $list = list_domain_image($list,['avatar']);
+
+        $this->success('success',$list);
+    }
+
+
 
 
 }

+ 0 - 5
application/api/controller/Userwallet.php

@@ -17,9 +17,6 @@ class Userwallet extends Api
     public function my_wallet(){
         $wallet = Db::name('user_wallet')->where(['user_id' => $this->auth->id])->find();
 
-        $wallet['user_alipay'] = Db::name('user_alipay')->where(['user_id' => $this->auth->id])->find();
-        $wallet['user_bank']   = Db::name('user_bank')->where(['user_id' => $this->auth->id])->find();
-        $wallet['user_wechat'] = Db::name('user_wechat')->where(['user_id' => $this->auth->id])->find();
         $this->success('success',$wallet);
     }
 
@@ -51,10 +48,8 @@ class Userwallet extends Api
     private function list_appen_logtext($list){
         if(!empty($list)){
             $conf = config('wallet.logtype');
-            $conf_en = config('wallet.logtype_en');
             foreach($list as $key => $val){
                 $list[$key]['log_text'] = isset($conf[$val['log_type']]) ? $conf[$val['log_type']] : '';
-                $list[$key]['log_text_en'] = isset($conf_en[$val['log_type']]) ? $conf_en[$val['log_type']] : '';
             }
         }
         return $list;

+ 17 - 0
application/common.php

@@ -1016,4 +1016,21 @@ if(!function_exists('birthtime_to_age')) {
 
         return $age;
     }
+}
+
+if (!function_exists('httpurllocal')) {
+    /**
+     * 判断当前url是否为全路径,并返回全路径
+     */
+    function httpurllocal($path) {
+        if(!$path) return $path;
+        $host = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"];
+        // 获取当前域名
+        if(strpos($path,'http://') === false && strpos($path,'https://') === false) {
+            $url = $host.$path;
+        } else {
+            $url = $path;
+        }
+        return $url;
+    }
 }

+ 2 - 0
application/config.php

@@ -369,6 +369,8 @@ return [
     'newconfiggroup' =>    [
         'siteconfig' => '全站配置',
         'takecash' => '提现配置',
+        'hexiao' => '核销配置',
+        'fenxiao' => '分销配置',
     ],
 
     //腾讯cos

+ 3 - 0
application/extra/site.php

@@ -27,6 +27,8 @@ return array (
     'dictionary' => '字典配置',
     'siteconfig' => '全站配置',
     'takecash' => '提现配置',
+    'hexiao' => '核销配置',
+    'fenxiao' => '分销配置',
   ),
   'mail_type' => '1',
   'mail_smtp_host' => 'smtp.qq.com',
@@ -48,4 +50,5 @@ return array (
   'max_takecash_money' => '10000',
   'takecash_plat_bili' => '1',
   'user_default_avatar' => '/uploads/20240522/47eb7f0430d48a73346b1630692e20ae.png',
+  'unishop_order_hexiaomoney_bili' => '10',
 );