rabin 3 سال پیش
والد
کامیت
4c6a5a616c
5فایلهای تغییر یافته به همراه80 افزوده شده و 15 حذف شده
  1. 1 1
      app/card/database/info_goods.php
  2. 11 0
      app/card/src/Api.php
  3. 52 10
      app/shop/lib/Sell.php
  4. 10 3
      app/shop/src/My.php
  5. 6 1
      service/agent/lib/Manage.php

+ 1 - 1
app/card/database/info_goods.php

@@ -93,7 +93,7 @@ return array
             ),
             'order' => array('type' => 'desc', 'id' => 'desc'),
             'type' => 'all',
-            'col' => '*',
+            'col' => '*|goods_id|',
         ),
     ),
 );

+ 11 - 0
app/card/src/Api.php

@@ -251,6 +251,16 @@ class Api extends Core
                         $this->data['card'][$k]['minfo'] = '限' . $shop['name'] . '可用';
                     }
                 }
+
+                $this->data['card'][$k]['cinfo'] = '';
+                if ($v['info']['category']) {
+                    $this->data['card'][$k]['cinfo'] = '限部分要求商品可用';
+                } else {
+                    $goods = Dever::db('card/info_goods')->find(array('card_id' => $v['info']['id']));
+                    if ($goods) {
+                        $this->data['card'][$k]['cinfo'] = '限部分要求商品可用';
+                    }
+                }
             }
         }
 
@@ -260,6 +270,7 @@ class Api extends Core
     # 查看可用的礼品卡
     public function use_card()
     {
+        $goods_id = Dever::input('goods_id');
         $config = Dever::db('main/sell_config')->find();
         $this->data['card_name'] = $config['card_name'];
 

+ 52 - 10
app/shop/lib/Sell.php

@@ -519,8 +519,8 @@ class Sell
                 # 验证这个礼品卡属于自己
                 $check = Dever::db('card/code')->find($card);
                 if ($check['dh_uid'] == $data['uid']) {
+                    $card_info = Dever::db('card/info')->find($check['card_id']);
                     if (!$check['total_cash']) {
-                        $card_info = Dever::db('card/info')->find($check['card_id']);
                         $check['total_cash'] = $card_info['value'];
                     }
                     if (!$check['use_cash']) {
@@ -529,18 +529,53 @@ class Sell
                     $card_cash = $check['total_cash'] - $check['use_cash'];
 
                     if ($card_cash > 0) {
-                        $data['card'] = array();
-                        $data['card']['id'] = $check['id'];
-                        $data['card']['card'] = $check['card'];
-                        if ($card_cash >= $data['price']) {
-                            $data['card']['cash'] = $data['price'];
-                            $data['price'] = 0;
+                        $card_goods = array();
+                        $check = false;
+                        $goods = Dever::db('card/info_goods')->getData(array('card_id' => $card_info['id']));
+                        if ($goods || $card_info['category']) {
+                            $check = true;
+                        }
+
+                        if ($check) {
+                            $price = 0;
+                            $card_info['category'] = explode(',', $card_info['category']);
+                            if ($goods) {
+                                $goods = array_keys($goods);
+                            }
+                            # 检测当前商品是否符合该卡的限制
+                            foreach ($data['list'] as $k => $v) {
+                                if ($goods) {
+                                    if (in_array($v['id'], $goods)) {
+                                        $price += ($v['price'] * $v['num']);
+                                        $card_goods[] = $v;
+                                    }
+                                } elseif ($card_info['category']) {
+                                    if (in_array($v['top_category_id'], $card_info['category'])) {
+                                        $price += ($v['price'] * $v['num']);
+                                        $card_goods[] = $v;
+                                    }
+                                }
+                            }
                         } else {
-                            $data['card']['cash'] = $card_cash;
-                            $data['price'] -= $data['card']['cash'];
+                            $price = $data['price'];
                         }
 
-                        $data['card']['cash'] = round($data['card']['cash'], 2);
+                        if ($card_info['min'] > 0 && $price < $card_info['min']) {
+                            # 不满足限额
+                        } else {
+                            $data['card'] = array();
+                            $data['card']['goods'] = $card_goods;
+                            $data['card']['id'] = $check['id'];
+                            $data['card']['card'] = $check['card'];
+                            if ($card_cash >= $price) {
+                                $data['card']['cash'] = $price;
+                                $data['price'] = 0;
+                            } else {
+                                $data['card']['cash'] = $card_cash;
+                                $data['price'] -= $data['card']['cash'];
+                            }
+                            $data['card']['cash'] = round($data['card']['cash'], 2);
+                        }
                     }
                 }
             } elseif ($wallet && $wallet > 0) {
@@ -736,6 +771,9 @@ class Sell
             if ($data['shop']['free_ps_cash'] && $data['shop']['free_ps_cash'] > 0 && $data['price'] >= $data['shop']['free_ps_cash']) {
                 $data['ps_cash'] = 0;
             }
+            if (!$data['ps_cash']) {
+                $data['ps_cash'] = 0;
+            }
         }
 
         $data['oprice'] = $data['price'];
@@ -766,6 +804,10 @@ class Sell
                 $ps_cash = 0;
             }
 
+            if (!$ps_cash) {
+                $ps_cash = 0;
+            }
+
             $order_data['ps_cash'] = $ps_cash;
             $price += $order_data['ps_cash'];
         }

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

@@ -32,7 +32,7 @@ class My extends Core
 		$bind = Dever::db('agent/user_bind')->find(array('uid' => $this->uid));
 		if ($bind && $bind['status'] == 2 && $bind['mid']) {
 			$this->data['bind_status'] = $bind['status'];
-			$this->data['agent'] = Dever::load('agent/lib/member')->getInfo($bind['mid']);
+			$this->data['agent'][] = Dever::load('agent/lib/member')->getInfo($bind['mid']);
 		} elseif ($bind && $bind['status'] != 2) {
 			$this->data['bind_status'] = $bind['status'];
 		} else {
@@ -258,8 +258,10 @@ class My extends Core
 	# 绑定代理商
 	public function bind()
 	{
-		$data['type'] = Dever::input('type', 1);
 		$data['mobile'] = Dever::input('mobile');
+		$data['idcard'] = Dever::input('idcard');
+		/*
+		$data['type'] = Dever::input('type', 1);
         $data['name'] = Dever::input('name');
         $data['idcard'] = Dever::input('idcard');
         $data['idcard_front'] = Dever::input('idcard_front');
@@ -271,6 +273,7 @@ class My extends Core
         if (!$data['name']) {
             Dever::alert('姓名不能为空');
         }
+        */
         if (!$data['mobile']) {
             Dever::alert('手机号不能为空');
         }
@@ -283,11 +286,14 @@ class My extends Core
         if ($member['status'] != 2) {
             Dever::alert('代理商还未审核通过或已被禁用');
         }
+
+        
         $data['mid'] = $member['id'];
+        
         if (!$data['idcard']) {
             Dever::alert('身份证号不能为空');
         }
-
+        /*
         if (!$data['idcard_front']) {
             Dever::alert('身份证正面不能为空');
         }
@@ -306,6 +312,7 @@ class My extends Core
                 Dever::alert('营业执照号码不能为空');
             }
         }
+        */
 
 		$info = Dever::db('agent/user_bind')->find(array('uid' => $this->uid));
 

+ 6 - 1
service/agent/lib/Manage.php

@@ -626,6 +626,11 @@ class Manage
             
         } elseif ($v['type'] == 3) {
             $prize = Dever::db('setting/prize')->find($v['type_id']);
+            $v['num'] = $v['num'] * $t;
+            $role = Dever::db('setting/role')->find($order['role']);
+            if ($role && $role['max_me_num'] && $role['max_me_num'] < $v['num']) {
+                $v['num'] = $role['max_me_num'];
+            }
             $price = $prize['price'];
             $cash = $prize['price']*$v['num'];
             $name = $prize['name'];
@@ -719,7 +724,7 @@ class Manage
                         $prize['type_id'] = $prize_info['id'];
                         $prize['sku_id'] = -1;
                         $prize['num'] = $prize_info['num'];
-                        $this->addGoods($parent_order, $prize);
+                        $this->addGoods($parent_order, $prize, 1);
                     }
                 }
                 if (isset($t['parent_goods_id'])) {