Browse Source

代金券

DengTao 8 years ago
parent
commit
8f6b3b30e3

+ 13 - 6
www/protected/controllers/RechargeController.php

@@ -100,17 +100,24 @@ class RechargeController extends AdminController {
                     }
                 }
 
-                $coupon = new MongoId($coupon);
-                $coupon_obj = Coupon::get($coupon);
 
-                if (!$coupon_obj) {
-                    CommonFn::requestAjax(false, '代金券不存在');
-                    break;
+                if (CommonFn::isMongoId($coupon)) {
+                    $coupon = new MongoId($coupon);
+                    $coupon_obj = Coupon::get($coupon);
+
+                    if (!$coupon_obj) {
+                        CommonFn::requestAjax(false, '代金券不存在');
+                        break;
+                    } else {
+                        $coupons_obj[$key] = $coupon;
+                    }
                 } else {
-                    $coupons_obj[$key] = $coupon;
+                    CommonFn::requestAjax(false, '代金券输入错误');
+                    break;
                 }
             }
 
+
         } else{
             //返现
             $cash_back = intval(Yii::app()->request->getParam('cash_back', ''));

+ 10 - 2
www/protected/views/recharge/index.php

@@ -151,7 +151,7 @@
                             <span>选择方式: </span>
                         </div>
                         <div class="box_flex f_content">
-                            <input type="radio" name="add_select_fun" id="add_cash_back" checked="checked" value="cash_back" />返现金额
+                            <input type="radio" name="add_select_fun" id="add_cash_back" checked="true" value="cash_back" />返现金额
                             <span id="id_str"></span>
                             <input type="radio" name="add_select_fun" id="add_coupon"  value="coupon" />使用代金券
                         </div>
@@ -494,7 +494,16 @@
             }
         }
     });
+    $('#edit_coupon').change(function(){
 
+        $('#cash').hide();
+        $('#coupons').show();
+    });
+    $('#edit_cash_back').change(function(){
+
+        $('#cash').show();
+        $('#coupons').hide();
+    });
     $('#add_coupon').change(function(){
 
         $('#add_cash').hide();
@@ -502,7 +511,6 @@
     });
     $('#add_cash_back').change(function(){
 
-
         $('#add_cash').show();
         $('#add_coupons').hide();
     });