dever 3 years ago
parent
commit
7d915d6b38

+ 3 - 3
app/goods/database/info.php

@@ -138,7 +138,7 @@ $config = array
             'desc'      => '分类',
             'match'     => 'is_string',
             'search'    => 'linkage',
-            'update'    => Dever::input('where_id') ? false : 'linkage',
+            'update'    => 'linkage',
             'option'    => Dever::url('api.get', 'category'),
             //'list'        => 'Dever::load("category/api.string", "{category}")',
         ),
@@ -214,7 +214,7 @@ $config = array
             'default'   => '1',
             'desc'      => '价格类型',
             'match'     => 'is_numeric',
-            'update'    => Dever::input('where_id') ? false : 'radio',
+            'update'    => 'radio',
             'option'    => $price_type,
             'control'   => 'price_type',
         ),
@@ -269,7 +269,7 @@ $config = array
             'desc'      => '套餐商品配置',
             'match'     => 'is_string',
             'show'      => 'price_type=3,4',
-            'update'    => Dever::input('where_id') ? false : array
+            'update'    => array
             (
                 array
                 (

+ 4 - 1
app/mshop/lib/Buy.php

@@ -218,7 +218,10 @@ class Buy
             $param['receipt'] = $receipt;
         }
 
-        $result = Dever::load('pay/api.pay', $param);
+        //$result = Dever::load('pay/api.pay', $param);
+        $result['type'] = 'test';
+        $result['order'] = '';
+
         $result['order_num'] = $order_data['order_num'];
         $result['order_id'] = $id;
         return $result;

+ 12 - 13
app/mshop/src/Data.php

@@ -104,7 +104,7 @@ class Data extends Core
 
         $info = Dever::db('shop/sell_order')->find(array('code' => $code, 'id' => $order_id));
 
-        if ($info && $info['shop_id'] == $this->shop_id && $infn['status'] <= 3) {
+        if ($info && $info['shop_id'] == $this->shop_id && $info['status'] <= 3) {
 
             $state = Dever::db('shop/sell_order')->update(array('where_id' => $info['id'], 'status' => 4, 'operdate' => time()));
 
@@ -183,7 +183,7 @@ class Data extends Core
     # 获取店铺的优惠券
     public function getCoupon()
     {
-        $this->data = Dever::db('shop/coupon')->getAllPage(array('shop_id' => $this->shop_id));
+        $this->data = Dever::db('shop/coupon')->getAllPage(array('shop_id' => $this->shop_id, 'method' => 3));
 
         if ($this->data) {
             $time = time();
@@ -196,19 +196,18 @@ class Data extends Core
                     $shop = Dever::db('shop/info')->getOne(array('id' => $v1['shop_id'], 'city' => $v['city'], 'coupon_city' => 1));
                     if ($shop) {
                         $this->data[$k]['shop'][] = $shop;
-
-                        if ($k1 > 0) {
-                            $city = Dever::db('area/city')->find($v['city']);
-                            $this->data[$k]['shop_name'] = $city['name'] . '多店通用';
-                        } else {
-                            $this->data[$k]['shop_name'] = $shop['name'];
-                        }
                     }
                 }
 
-                if (!$this->data[$k]['shop']) {
-                    $shop = Dever::db('shop/info')->getOne($v['shop_id']);
-                    $this->data[$k]['shop'][] = $shop;
+                $shop = Dever::db('shop/info')->getOne($v['shop_id']);
+                if ($this->data[$k]['info']['method'] == 1) {
+                    $this->data[$k]['shop_name'] = '平台通用';
+                } elseif ($this->data[$k]['info']['method'] == 2) {
+                    $this->data[$k]['shop_name'] = $shop['name'];
+                    if (count($this->data[$k]['shop']) > 1) {
+                        $this->data[$k]['shop_name'] .= '多店通用';
+                    }
+                } elseif ($this->data[$k]['info']['method'] == 3) {
                     $this->data[$k]['shop_name'] = $shop['name'];
                 }
             }
@@ -233,7 +232,7 @@ class Data extends Core
         if ($info['uid'] && $info['uid'] > 0) {
             foreach ($coupon as $k => $v) {
                 $num = isset($coupon_num[$k]) ? $coupon_num[$k] : 1;
-                Dever::load('shop/lib/coupon')->getOne($info['uid'], $this->shop, $v, $num, false);
+                Dever::load('shop/lib/coupon')->getOne($info['uid'], $this->shop, $v, 1, $num, false);
             }
         }
 

+ 3 - 0
app/shop/database/coupon.php

@@ -176,6 +176,7 @@ return array
             'option' => array
             (
                 'shop_id' => 'yes',
+                'method' => 'yes',
                 'state' => 1,
             ),
             'type' => 'all',
@@ -192,6 +193,7 @@ return array
                 'id' => 'yes',
                 'shop_id' => 'yes',
                 'coupon_id' => 'yes',
+                'method' => 'yes',
                 'state' => 1,
             ),
             'type' => 'all',
@@ -207,6 +209,7 @@ return array
                 'id' => 'yes',
                 'shop_id' => 'yes',
                 'coupon_id' => 'yes',
+                'method' => 'yes',
                 'state' => 1,
             ),
             'type' => 'one',

+ 19 - 15
app/shop/lib/Coupon.php

@@ -54,14 +54,6 @@ class Coupon
         if (!$shop_coupon_id) {
             return false;
         }
-        if ($act) {
-            $data = Dever::db('shop/coupon_act')->getOne(array('shop_id' => $shop['id'], 'act_id' => $act_id, 'shop_coupon_id' => $shop_coupon_id));
-
-            if (!$data) {
-                return false;
-            }
-        }
-        
 
         $data = Dever::db('shop/coupon')->getOne($shop_coupon_id);
 
@@ -72,16 +64,27 @@ class Coupon
         if ($data['total'] <= 0) {
             return false;
         }
+        if ($num > $data['total']) {
+            $num = $data['total'];
+        }
 
-        $user = Dever::db('shop/user_coupon')->find(array('uid' => $uid, 'shop_coupon_id' => $data['id'], 'status' => 1));
+        if ($act) {
+            $data = Dever::db('shop/coupon_act')->getOne(array('shop_id' => $shop['id'], 'act_id' => $act_id, 'shop_coupon_id' => $shop_coupon_id));
 
-        if ($user) {
-            return false;
-        }
+            if (!$data) {
+                return false;
+            }
 
-        $state = Dever::load('shop/lib/share')->getOne($uid, $shop['id'], 1);
-        if (!$state) {
-            return false;
+            $state = Dever::load('shop/lib/share')->getOne($uid, $shop['id'], 1);
+            if (!$state) {
+                return false;
+            }
+
+            $user = Dever::db('shop/user_coupon')->find(array('uid' => $uid, 'shop_coupon_id' => $data['id'], 'status' => 1));
+
+            if ($user) {
+                return false;
+            }
         }
 
         $state = Dever::load('shop/lib/coupon.take_commit', $uid, $shop, $data, $num);
@@ -104,6 +107,7 @@ class Coupon
             $data['shop_coupon_id'] = $shop_coupon['id'];
             $data['edate'] = time() + ($shop_coupon['day'] * 86400);
             //$data['cash'] = $cash;
+            $data['t'] = $i;
             $id = Dever::db('shop/user_coupon')->insert($data);
             if ($id) {
                 $add_num += 1;

+ 3 - 1
app/shop/lib/Sell.php

@@ -724,7 +724,9 @@ class Sell
             $param['receipt'] = $receipt;
         }
 
-        $result = Dever::load('pay/api.pay', $param);
+        //$result = Dever::load('pay/api.pay', $param);
+        $result['type'] = 'test';
+        $result['order'] = '';
         if ($cart) {
             # 来自购物车,要清空一下
             $this->dropCart($cart, $uid, $goods, $shop['id']);

+ 12 - 10
app/shop/src/My.php

@@ -45,25 +45,27 @@ class My extends Core
 				$this->data[$k]['edate'] = date('Y-m-d', $v['edate']);
 				$this->data[$k]['info'] = Dever::db('goods/coupon')->find($v['coupon_id']);
 				$this->data[$k]['shop'] = array();
+
+				$city = Dever::db('area/city')->find($v['city']);
+
 				$coupon = Dever::db('shop/coupon')->select(array('coupon_id' => $v['coupon_id'], 'city' => $v['city']));
 
 				foreach ($coupon as $k1 => $v1) {
 					$shop = Dever::db('shop/info')->getOne(array('id' => $v1['shop_id'], 'city' => $v['city'], 'coupon_city' => 1));
 					if ($shop) {
 						$this->data[$k]['shop'][] = $shop;
-
-						if ($k1 > 0) {
-							$city = Dever::db('area/city')->find($v['city']);
-							$this->data[$k]['shop_name'] = $city['name'] . '多店通用';
-						} else {
-							$this->data[$k]['shop_name'] = $shop['name'];
-						}
 					}
 				}
 
-				if (!$this->data[$k]['shop']) {
-					$shop = Dever::db('shop/info')->getOne($v['shop_id']);
-					$this->data[$k]['shop'][] = $shop;
+				$shop = Dever::db('shop/info')->getOne($v['shop_id']);
+				if ($this->data[$k]['info']['method'] == 1) {
+					$this->data[$k]['shop_name'] = '平台通用';
+				} elseif ($this->data[$k]['info']['method'] == 2) {
+					$this->data[$k]['shop_name'] = $shop['name'];
+					if (count($this->data[$k]['shop']) > 1) {
+						$this->data[$k]['shop_name'] .= '多店通用';
+					}
+				} elseif ($this->data[$k]['info']['method'] == 3) {
 					$this->data[$k]['shop_name'] = $shop['name'];
 				}
 			}