| 
					
				 | 
			
			
				@@ -91,12 +91,20 @@ class Sell 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         (
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             array('value' => 1, 'name' => '待支付'),
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             array('value' => 2, 'name' => '待处理'),
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            array('value' => 3, 'name' => '待自提'),
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            array('value' => 3, 'name' => '配送中'),
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            array('value' => '6,7,8', 'name' => '退款'),
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            array('value' => 4, 'name' => '已完成'),
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            array('value' => 5, 'name' => '已取消'),
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         );
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if ($method == 1) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $result['search']['status'][] = array('value' => 3, 'name' => '待自提');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } elseif ($method == 2) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $result['search']['status'][] = array('value' => 3, 'name' => '配送中');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $result['search']['status'][] = array('value' => 3, 'name' => '待自提');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $result['search']['status'][] = array('value' => 3, 'name' => '配送中');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $result['search']['status'][] = array('value' => '6,7,8', 'name' => '退款');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $result['search']['status'][] = array('value' => 4, 'name' => '已完成');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $result['search']['status'][] = array('value' => 5, 'name' => '已取消');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $result['search']['method'] = array
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         (
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             array('value' => 1, 'name' => '自提'),
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -379,6 +387,7 @@ class Sell 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $data['coupon_cash'] = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if ($type == 1 && isset($data['uid']) && $data['uid'] > 0) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            # 默认选择优惠券
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if ($data['price'] <= 0) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 Dever::alert('付款价格错误');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -387,14 +396,13 @@ class Sell 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if ($coupon) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 foreach ($coupon as $k => $v) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    if ($v['shop_id'] != $data['shop']['id']) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        # 查找该券是否符合当前店铺
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        if ($data['shop']['coupon_city'] == 2) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $coupon_info = Dever::db('goods/coupon')->find($v['coupon_id']);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if ($coupon_info) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if ($v['shop_id'] != $data['shop']['id'] && $coupon_info['method'] == 3) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            # 门店专属券 不能给别的门店用
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             continue;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    $coupon_info = Dever::db('goods/coupon')->find($v['coupon_id']);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    if ($coupon_info && ($coupon_info['method'] == $data['method'] || $coupon_info['method'] == 3)) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         $kou = false;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         if ($coupon_info['type'] == 1) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             # 满减券
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -424,6 +432,7 @@ class Sell 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if ($user_coupon_id && isset($data['uid']) && $data['uid'] > 0) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            # 用户自己使用优惠券
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if ($data['price'] <= 0) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 Dever::alert('付款价格错误');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -436,8 +445,13 @@ class Sell 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 Dever::alert('优惠券已过期');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $goods_coupon = Dever::db('goods/coupon')->find($coupon['coupon_id']);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!$goods_coupon) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Dever::alert('优惠券不可用');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if ($coupon['shop_id'] != $data['shop']['id']) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if ($data['shop']['coupon_city'] == 2) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if ($goods_coupon['method'] == 3) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     Dever::alert('优惠券不可用');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } else {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     $coupon_info = Dever::db('shop/coupon')->find(array('shop_id' => $coupon['shop_id'], 'coupon_id' => $coupon['coupon_id'], 'city' => $coupon['city']));
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -447,18 +461,15 @@ class Sell 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            $goods_coupon = Dever::db('goods/coupon')->find($coupon['coupon_id']);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if ($goods_coupon['type'] == 2 && $data['price'] < $goods_coupon['total_cash']) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 Dever::alert('优惠券不可用');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if ($goods_coupon['method'] != $data['method'] && $goods_coupon['method'] != 3) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                Dever::alert('优惠券不可用');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             $data['user_coupon_id'] = $user_coupon_id;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             $data['coupon_id'] = $goods_coupon['id'];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             $data['coupon_cash'] = $goods_coupon['cash'];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } elseif ($coupon_id && $type == 3) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            # 店里直接给用优惠券
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if ($data['price'] <= 0) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 Dever::alert('付款价格错误');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -468,10 +479,11 @@ class Sell 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             $goods_coupon = Dever::db('goods/coupon')->find($coupon_info['coupon_id']);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if ($goods_coupon['type'] == 2 && $data['price'] < $goods_coupon['total_cash']) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!$goods_coupon) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 Dever::alert('优惠券不可用');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if ($goods_coupon['method'] != $data['method'] && $goods_coupon['method'] != 3) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if ($goods_coupon['type'] == 2 && $data['price'] < $goods_coupon['total_cash']) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 Dever::alert('优惠券不可用');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 |