|
@@ -66,6 +66,7 @@ class RechargeController extends AdminController {
|
|
|
$rows = CommonFn::getRowsFromCursor($recharge);
|
|
|
|
|
|
$parsedRows = Recharge::model()->parse($rows);
|
|
|
+
|
|
|
echo CommonFn::composeDatagridData($parsedRows, $total);
|
|
|
}
|
|
|
//添加充值卡信息
|
|
@@ -74,19 +75,61 @@ class RechargeController extends AdminController {
|
|
|
$cash_back = intval(Yii::app()->request->getParam('cash_back', 0));
|
|
|
$status = intval(Yii::app()->request->getParam('status', 0));
|
|
|
$desc = Yii::app()->request->getParam('desc', '');
|
|
|
+ $coupons = array();
|
|
|
+ $select_fun = Yii::app()->request->getParam('add_select_fun', '');
|
|
|
$flag = empty($denomination);
|
|
|
- $flag = $flag || $status == -1;
|
|
|
+ $flag = $flag || $status == -1 ;
|
|
|
if ($flag) {
|
|
|
CommonFn::requestAjax(false, '请检查数据完整性', array());
|
|
|
exit;
|
|
|
}
|
|
|
+ $coupons_obj = array();
|
|
|
+ //判断 返现 代金券
|
|
|
+ if ($select_fun == 'coupon') {
|
|
|
+ //数组分割处理
|
|
|
+ $coupons = explode("<br />",nl2br(trim(Yii::app()->request->getParam('text_coupons'))));
|
|
|
+
|
|
|
+ foreach ($coupons as $key => $coupon) {
|
|
|
+ $coupon = rtrim(trim($coupon),',');
|
|
|
+ foreach ($coupons as $k => $v) {
|
|
|
+ if ($key != $k) {
|
|
|
+ $v = rtrim(trim($v),',');
|
|
|
+ if ($v == $coupon) {
|
|
|
+ CommonFn::requestAjax(false, '代金券id重复');
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $coupon = new MongoId($coupon);
|
|
|
+ $coupon_obj = Coupon::get($coupon);
|
|
|
+
|
|
|
+ if (!$coupon_obj) {
|
|
|
+ CommonFn::requestAjax(false, '代金券不存在');
|
|
|
+ break;
|
|
|
+ } else {
|
|
|
+ $coupons_obj[$key] = $coupon;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else{
|
|
|
+ //返现
|
|
|
+ $cash_back = intval(Yii::app()->request->getParam('cash_back', ''));
|
|
|
+ if ($cash_back <= 0 ){
|
|
|
+ CommonFn::requestAjax(false, '返现金额不能为0');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
$recharge = new Recharge();
|
|
|
$recharge->denomination = intval($denomination);//充值面额
|
|
|
$recharge->cash_back = intval($cash_back);//返现金额
|
|
|
+ $recharge->coupons = $coupons_obj;
|
|
|
$recharge->desc = $desc;//描述
|
|
|
$recharge->status = intval($status);//状态
|
|
|
|
|
|
- $addRecharge_arr = array('denomination','cash_back','status','desc');
|
|
|
+ $addRecharge_arr = array('denomination','cash_back','status','desc','coupons');
|
|
|
$success = $recharge->save(true, $addRecharge_arr);
|
|
|
|
|
|
CommonFn::requestAjax($success, '', array());
|
|
@@ -97,11 +140,11 @@ class RechargeController extends AdminController {
|
|
|
public function actionEdit() {
|
|
|
$denomination = intval(Yii::app()->request->getParam('denomination',''));//面额
|
|
|
$desc = Yii::app()->request->getParam('desc', '');//描述
|
|
|
- $status = Yii::app()->request->getParam('status', '');
|
|
|
+ $status = intval(Yii::app()->request->getParam('status', '0'));
|
|
|
$id = Yii::app()->request->getParam('id', '');
|
|
|
$coupons = array();//代金券
|
|
|
$select_fun = Yii::app()->request->getParam('select_fun', '');
|
|
|
-
|
|
|
+ $coupons_obj = array();
|
|
|
//指定状态
|
|
|
if ($status == 100) {
|
|
|
CommonFn::requestAjax(false, '必须指定状态!');
|
|
@@ -110,10 +153,13 @@ class RechargeController extends AdminController {
|
|
|
if (!isset($denomination)) {
|
|
|
CommonFn::requestAjax(false, '必须填写面额!');
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
$cash_back = 0;
|
|
|
if ($select_fun == 'coupon') {
|
|
|
//数组分割处理
|
|
|
- $coupons = explode("<br />",nl2br(trim(Yii::app()->request->getParam('coupons'))));
|
|
|
+ $coupons = explode("<br />",nl2br(trim(Yii::app()->request->getParam('text_coupons'))));
|
|
|
|
|
|
foreach ($coupons as $key => $coupon) {
|
|
|
$coupon = rtrim(trim($coupon),',');
|
|
@@ -133,18 +179,23 @@ class RechargeController extends AdminController {
|
|
|
if (!$coupon_obj) {
|
|
|
CommonFn::requestAjax(false, '代金券不存在');
|
|
|
break;
|
|
|
+ } else {
|
|
|
+ $coupons_obj[$key] = $coupon;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} else{
|
|
|
//返现
|
|
|
$cash_back = intval(Yii::app()->request->getParam('cash_back', ''));
|
|
|
+ if ($cash_back <= 0 ){
|
|
|
+ CommonFn::requestAjax(false, '返现金额不能为0');
|
|
|
+ }
|
|
|
}
|
|
|
$criteria = new EMongoCriteria();
|
|
|
$criteria->_id = new MongoId($id);
|
|
|
$recharge = Recharge::model()->find($criteria);
|
|
|
|
|
|
- $recharge->coupons = $coupons;
|
|
|
+ $recharge->coupons = $coupons_obj;
|
|
|
$recharge->cash_back = $cash_back;
|
|
|
$recharge->desc = $desc;
|
|
|
$recharge->denomination = $denomination;
|