|
@@ -339,6 +339,7 @@ class WholeController extends Curd
|
|
|
$premises = $express->order_express_company;
|
|
|
}
|
|
|
$sheetAmount = 0;
|
|
|
+ $coupons = [];
|
|
|
foreach ($orderSheet as &$item) {
|
|
|
$sheetAmount += $item['order_sheet_amount'];
|
|
|
$item['goods']['goods_cover'] = getenv('STORAGE_DOMAIN') . $item['goods']['goods_cover'];
|
|
@@ -367,8 +368,32 @@ class WholeController extends Curd
|
|
|
];
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
$item['goods']['components'] = $goodsArr;
|
|
|
+
|
|
|
+ $goodsModel = Goods::where('goods_id', $item['goods']['goods_id'])->select('goods_attribute_json')->first();
|
|
|
+ if (!empty($goodsModel) && !empty($goodsModel->goods_attribute_json)) {
|
|
|
+ $goodsAttributeJson = json_decode($goodsModel->goods_attribute_json, true);
|
|
|
+ if (!empty($goodsAttributeJson['coupon'])) {
|
|
|
+ foreach ($goodsAttributeJson['coupon'] as $key => $coupon) {
|
|
|
+ $couponCount = CouponDetail::where('join_detail_coupon_id', $key)
|
|
|
+ ->whereJsonContains('coupon_detail_extend_json->order_id', $item['join_sheet_order_id'])
|
|
|
+ ->count();
|
|
|
+ $couponUsedCount = CouponDetail::where('join_detail_coupon_id', $key)
|
|
|
+ ->where('coupon_detail_status', 'USED')
|
|
|
+ ->whereJsonContains('coupon_detail_extend_json->order_id', $item['join_sheet_order_id'])
|
|
|
+ ->count();
|
|
|
+ $couponUnUsedCount = CouponDetail::where('join_detail_coupon_id', $key)
|
|
|
+ ->whereIn('coupon_detail_status', ['ACTIVED', 'WAITING'])
|
|
|
+ ->whereJsonContains('coupon_detail_extend_json->order_id', $item['join_sheet_order_id'])
|
|
|
+ ->count();
|
|
|
+ $coupon['total'] = $couponCount;
|
|
|
+ $coupon['used'] = $couponUsedCount;
|
|
|
+ $coupon['unused'] = $couponUnUsedCount;
|
|
|
+ $coupon['invalid'] = $couponCount - $couponUsedCount - $couponUnUsedCount;
|
|
|
+ $coupons[] = $coupon;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
if (!empty($item['sku'])) {
|
|
|
if (!empty($item['sku']['goods_sku_specs_json'])) {
|
|
@@ -575,6 +600,7 @@ class WholeController extends Curd
|
|
|
|
|
|
$order->premises = $order->premises ?? $premises;
|
|
|
$data = [
|
|
|
+ 'coupons' => $coupons,
|
|
|
'order' => $order,
|
|
|
'refund' => json_decode(json_encode($refund)),
|
|
|
'sheet' => json_decode(json_encode($orderSheet)),
|