Beispiel #1
0
/**
 * 公共函数
 */
function createCoupon($did, $oid)
{
    $model = M("Coupon");
    $coupon_no = $did . rand(10000, 99999);
    if ($model->where("coupon_no='{$coupon_no}'")->count()) {
        //重复 调用递归
        return createCoupon($did, $oid);
    } else {
        $coupon['coupon_no'] = $coupon_no;
        $coupon['coupon_code'] = getRandStr(5, 1);
        $coupon['did'] = $did;
        $coupon['oid'] = $oid;
        $coupon['status'] = 1;
        $model->add($coupon);
        return;
    }
}
Beispiel #2
0
 protected function saveCoupon($detail)
 {
     $coupon = array();
     for ($i = 0; $i < $detail['count']; $i++) {
         createCoupon($detail['did'], $detail['oid']);
     }
 }