예제 #1
0
/**
 * 返回优惠券可抵用金额
 */
function get_fcoupon_fee($code, $total)
{
    $lowfee = get_fcoupon_lowpayment($code);
    //优惠券最低消费金额
    if ($lowfee < $total) {
        $codeid = M("fcoupon")->where("code='{$code}' and status='1'")->getField('id');
        //获取优惠券主键id
        $fee = get_coupon_price($codeid);
        //获取优惠券等值金额
        //获取会员uid
        $uid = D("member")->uid();
        $usercouponid = M("usercoupon")->where("couponid='{$codeid}' and status='1' and uid='{$uid}'")->getField('id');
        //获取用户可用优惠券主键id
        if ($usercouponid) {
            $deccode = $fee;
            M("usercoupon")->where("couponid='{$codeid}' and uid='{$uid}'")->setField('status', 2);
            //设置优惠券已用
        } else {
            $deccode = 0;
        }
    } else {
        $deccode = 0;
    }
}
예제 #2
0
/**
 * 返回优惠券可抵用金额
 */
function get_fcoupon_fee($code, $total)
{
    $lowfee = get_fcoupon_lowpayment($code);
    //优惠券最低消费金额
    if ($lowfee < $total) {
        $info = M("fcoupon")->where("code='{$code}' and status='1'")->find();
        //获取优惠券主键id
        $fee = $info["price"];
        //获取优惠券金额
        $codeid = $info["id"];
        $usercouponid = M("usercoupon")->where("couponid='{$codeid}' and status='1'")->getField('id');
        //获取用户可用优惠券主键id
        if ($usercouponid) {
            $deccode = $fee;
            $uid = D("member")->uid();
            M("usercoupon")->where("couponid='{$codeid}' and uid='{$uid}' ")->setField('status', 2);
            //设置优惠券已用
        } else {
            $deccode = 0;
        }
    } else {
        $deccode = 0;
    }
    return $deccode;
}