dever 3 år sedan
förälder
incheckning
6d3fe63cff
4 ändrade filer med 27 tillägg och 6 borttagningar
  1. 17 5
      app/mshop/lib/Buy.php
  2. 8 0
      app/mshop/lib/Core.php
  3. 1 1
      app/mshop/src/Buy.php
  4. 1 0
      app/shop/database/info.php

+ 17 - 5
app/mshop/lib/Buy.php

@@ -253,8 +253,19 @@ class Buy
     }
 
     # 发起支付
-    public function action($type, $type_id, $name, $num, $goods, $price, $info, $refer = '')
+    public function action($uid, $type, $type_id, $name, $num, $goods, $price, $info, $refer = '')
     {
+        $openid = false;
+        if ($uid > 0) {
+            $wechat = Dever::db('passport/wechat')->one(array('uid' => $uid, 'type' => 1, 'system_id' => 2));
+
+            if (!$wechat) {
+                Dever::alert('错误的用户信息');
+            }
+
+            $openid = $wechat['openid'];
+        }
+
         $order_data['type'] = $type;
         $order_data['type_id'] = $type_id;
         $order_data['name'] = $name;
@@ -303,8 +314,9 @@ class Buy
             'project_id' => 2,
             'channel_id' => 1,
             'system_source' => 5,
-            'uid' => -1,
+            'uid' => $uid,
             'name' => $order_data['name'],
+            'openid' => $openid,
             'cash' => $price,
             'product_id' => $id,
             'order_id' => $order_data['order_num'],
@@ -316,9 +328,9 @@ class Buy
             $param['receipt'] = $receipt;
         }
 
-        //$result = Dever::load('pay/api.pay', $param);
-        $result['type'] = 'test';
-        $result['order'] = '';
+        $result = Dever::load('pay/api.pay', $param);
+        //$result['type'] = 'test';
+        //$result['order'] = '';
 
         $result['order_num'] = $order_data['order_num'];
         $result['order_id'] = $id;

+ 8 - 0
app/mshop/lib/Core.php

@@ -8,6 +8,8 @@ class Core
 {
     public function __construct()
     {
+        $this->passport_uid = Dever::load('passport/user')->check(false, 'passport_signature');
+
         $this->uid = Dever::load('passport/user')->check(false);
         if ($this->uid <= 0) {
             $this->uid = 1;
@@ -31,6 +33,12 @@ class Core
             Dever::alert('您没有权限管理该门店');
         }
 
+        if ($shop['uid'] > 0) {
+            $this->passport_uid = $shop['uid'];
+        } elseif ($shop['uid'] <= 0 && $this->passport_uid > 0) {
+            Dever::db('shop/member')->update(array('where_id' => $shop['id'], 'set_uid' => $this->passport_uid));
+        }
+
         $this->shop = Dever::db('shop/info')->getOne($this->shop_id);
 
         if (!$this->shop) {

+ 1 - 1
app/mshop/src/Buy.php

@@ -108,7 +108,7 @@ class Buy extends Core
 
         $this->goods();
 
-        $pay = Dever::load('mshop/lib/buy')->set(1,1)->action(1, $this->shop_id, $this->data['name'], $this->data['num'], $this->data['list'], $this->data['price'], $info, $refer);
+        $pay = Dever::load('mshop/lib/buy')->set(1,1)->action($this->passport_uid, 1, $this->shop_id, $this->data['name'], $this->data['num'], $this->data['list'], $this->data['price'], $info, $refer);
         return $pay;
     }
 

+ 1 - 0
app/shop/database/info.php

@@ -76,6 +76,7 @@ return array
     'act' => $act,
     'config_col' => $col,
     'check' => 'sid',
+    'config_type' => $type,
 
     'end' => array
     (