我提出以下询问:
$data = mysql_fetch_array(mysql_query("SELECT
c.`id` AS cid,
p.`id` AS pid,p.`email`
FROM `coupons` AS c
LEFT JOIN `coupons_partners` AS cp ON cp.`cid` = c.`id`
LEFT JOIN `partners` AS p ON p.`id` = cp.`pid`
LEFT JOIN `bills` AS b ON b.`pid` = p.`id`
WHERE
(
CURRENT_DATE() BETWEEN c.`expires` AND ADDDATE(c.`expires`, INTERVAL 1 MONTH)
)
OR
(
CURRENT_DATE() NOT BETWEEN c.`expires` AND ADDDATE(c.`expires`, INTERVAL 1 MONTH)
AND
CURRENT_DATE() BETWEEN b.`date` AND ADDDATE(b.`date`, INTERVAL 1 MONTH)
)
ORDER BY b.`id` DESC"));
It s kinda messy. I want to do a cronjob and create bills automatically. They should only be created after 1 month a coupon expires (c.expires
is DATETIME
) or if the LAST bill (b.date
) was created 1 month ago.
The thing also is that I don t want to create any bill if the coupon didn t started yet. And this is possible, because I create coupons that ll start in maybe 3 months. So I guess the "Between-Solution" doesn t fit here?
我试图把它说得当,但现在我会感谢任何帮助。
如果有人能帮助我,我会高兴和感谢。
最佳方面,
* A/63/150。