update: coupon generate

This commit is contained in:
Tokumeikoi 2020-10-24 23:26:59 +08:00
parent 1a94a48cf4
commit 4901cbfea5

View File

@ -110,12 +110,13 @@ class CouponController extends Controller
DB::commit();
$data = "名称,类型,金额或比例,开始时间,结束时间,可用次数,可用于订阅,券码,生成时间\r\n";
foreach($coupons as $coupon) {
$type = ['金额', '比例'][$coupon['type']];
$type = ['', '金额', '比例'][$coupon['type']];
$value = $coupon['type'] === 1 ? ($coupon['value'] / 100) : $coupon['value'];
$startTime = date('Y-m-d H:i:s', $coupon['started_at']);
$endTime = date('Y-m-d H:i:s', $coupon['ended_at']);
$limitUse = $coupon['limit_use'] ?? '不限制';
$createTime = date('Y-m-d H:i:s', $coupon['created_at']);
$data .= "{$coupon['name']},{$type},{$coupon['value']},{$startTime},{$endTime},{$limitUse},{$coupon['limit_plan_ids']},{$coupon['code']},{$createTime}\r\n";
$data .= "{$coupon['name']},{$type},{$value},{$startTime},{$endTime},{$limitUse},{$coupon['limit_plan_ids']},{$coupon['code']},{$createTime}\r\n";
}
echo $data;
}