|
@@ -77,6 +77,7 @@ class JCouponController extends AdminController
|
|
|
public function actionAdd()
|
|
|
{
|
|
|
$num = (int)Yii::app()->request->getParam('num','');
|
|
|
+ $coding_num = (int)Yii::app()->request->getParam('coding_num','');
|
|
|
$gift_id = Yii::app()->request->getParam('gift_id','');
|
|
|
$channel = Yii::app()->request->getParam('bus_id','');
|
|
|
$expire_time = Yii::app()->request->getParam('expire_time_str','');
|
|
@@ -87,10 +88,18 @@ class JCouponController extends AdminController
|
|
|
if (empty($gift)) {
|
|
|
CommonFn::requestAjax(false,'礼包不存在');exit;
|
|
|
}
|
|
|
-
|
|
|
+ $c = new EMongoCriteria();
|
|
|
+ $c->coding_num('==',$coding_num);
|
|
|
+ $j = JCoupon::model()->findAll($c);
|
|
|
+ if (count($j) > 0) {
|
|
|
+ CommonFn::requestAjax(false,'起始值重复');exit;
|
|
|
+ }
|
|
|
+ $total = 100000;
|
|
|
for($i=0; $i<$num; $i++) {
|
|
|
$coupon = new JCoupon();
|
|
|
$coupon->gift_id = $gift_id;
|
|
|
+ $coupon->coding_num = $coding_num;
|
|
|
+
|
|
|
$flag = true;
|
|
|
while($flag) {
|
|
|
$pwd = $coupon->generateRandomString(8);
|
|
@@ -99,16 +108,32 @@ class JCouponController extends AdminController
|
|
|
$flag = false;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ $total++;
|
|
|
$coupon->pwd = $pwd;
|
|
|
+ $coupon->coupon_coding = $gift->gift_num.substr(date('Y'),2).date('m').'0'.substr($total,1);
|
|
|
$coupon->channel = $channel;
|
|
|
$coupon->status = 0;
|
|
|
$coupon->expire_time = $expire_time;
|
|
|
$coupon->save();
|
|
|
+ $coding_num++;
|
|
|
}
|
|
|
|
|
|
CommonFn::requestAjax(true,'生成成功');exit;
|
|
|
}
|
|
|
|
|
|
+ public function actionOutputExcel()
|
|
|
+ {
|
|
|
+ $start_num = (int)Yii::app()->request->getParam('start_num','');
|
|
|
+ $total = (int)Yii::app()->request->getParam('total','');
|
|
|
+
|
|
|
+ $criteria = new EMongoCriteria();
|
|
|
+ $criteria->coding_num('>=',(int)$start_num);
|
|
|
+ $criteria->coding_num('<',(int)($start_num+$total));
|
|
|
+ $cursor = JCoupon::model()->findAll($criteria);
|
|
|
+ $rows = CommonFn::getRowsFromCursor($cursor);
|
|
|
+ $parsedRows = JCoupon::model()->parse($rows);
|
|
|
+ $res=Service::factory('JCouponService')->push($parsedRows);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|