记录一次优惠券生成-去重
方法一
/**
* 生成批量礼品消费券
*/
public function giftCardAddOp() {
//接收get值
$num = $_GET['gift_num'];
$branch_prefix = $_GET['city_name'];
if ($_GET) {
$this->add_gift_card($branch_prefix, $num);
}
showMessage('礼品码生成成功!','index.php?act=order&op=giftCardCode');
}
/**
* 处理插入
*$branch_prefix
*$num
*$sum
*
*/
private function add_gift_card($branch_prefix, $num ,$sum='0'){
// 计数
$n = 0;
$promotion_codes = array();//这个数组用来接收生成的优惠码
for ($i=0; $i < (($sum >0) ? $sum : $num); $i++) {
$charid = strtoupper(md5(uniqid(mt_rand(), true)));
$uuid = substr($charid, 8, 8);
$company = '爱之依';
$promotion_codes[$i] =