|
@@ -869,21 +869,114 @@ class MemberController
|
|
|
if (count($sheets) > 1) {
|
|
|
$deng = '等';
|
|
|
}
|
|
|
- $data[] = [
|
|
|
- 'order_classify' => $row['order_classify'],
|
|
|
- 'order_id' => $row['order_id'],
|
|
|
- 'goods_name' => !empty($sheets[0]) && !empty($sheets[0]['goods']) ? ($sheets[0]['goods']['goods_name'] . $deng) : '',
|
|
|
- 'order_amount_total' => $row['order_amount_total'],
|
|
|
- 'order_amount_pay' => $row['order_amount_pay'],
|
|
|
- 'pay_paytimes' => !empty($row['payDetail'][0]) ? $row['payDetail'][0]['pay_paytimes'] : "",
|
|
|
- 'order_addtimes' => $row['order_addtimes'],
|
|
|
- ];
|
|
|
+ foreach ($row['pay_detail'] as $item) {
|
|
|
+ if (!empty($item['join_pay_object_json'])) {
|
|
|
+ $payObjectJson = json_decode($item['join_pay_object_json'], true);
|
|
|
+ if ($payObjectJson['order_id'] != $row['order_id']) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $data[] = [
|
|
|
+ 'order_classify' => $row['order_classify'],
|
|
|
+ 'order_id' => $row['order_id'],
|
|
|
+ 'goods_name' => !empty($sheets[0]) && !empty($sheets[0]['goods']) ? ($sheets[0]['goods']['goods_name'] . $deng) : '',
|
|
|
+ 'order_amount_total' => $row['order_amount_total'],
|
|
|
+ 'order_amount_pay' => $row['order_amount_pay'],
|
|
|
+ 'pay_paytimes' => $item['pay_paytimes'] ?? "",
|
|
|
+ 'order_addtimes' => $row['order_addtimes'],
|
|
|
+ 'pay_amount' => $item['pay_amount']
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
$rows = $data;
|
|
|
|
|
|
return json_success('', compact('rows', 'page', 'pageSize', 'total'));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @Desc 消费导出
|
|
|
+ * @Author Gorden
|
|
|
+ * @Date 2024/10/15 17:36
|
|
|
+ *
|
|
|
+ * @param Request $request
|
|
|
+ * @return \support\Response
|
|
|
+ */
|
|
|
+ public function exportConsumptionList(Request $request)
|
|
|
+ {
|
|
|
+ $memberId = $request->post('member_id');
|
|
|
+ $orderIds = $request->post('order_id', []);
|
|
|
+ if (!$memberId) {
|
|
|
+ return json_fail('参数异常');
|
|
|
+ }
|
|
|
+ $member = Member::where('member_id', $memberId)->first();
|
|
|
+ $firstRechargeTime = 0;
|
|
|
+ if (!empty($member->member_extend_json)) {
|
|
|
+ $memberExtendJson = json_decode($member->member_extend_json, true);
|
|
|
+ if (isset($memberExtendJson['snap'])) {
|
|
|
+ foreach ($memberExtendJson['snap'] as $key => $value) {
|
|
|
+ $firstRechargeTime = strtotime($key);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (empty($orderIds)) {
|
|
|
+ $payDetailIds = PayDetail::where('pay_addtimes', '>', $firstRechargeTime)
|
|
|
+ ->where('pay_prepayid', $memberId . '-CASH')
|
|
|
+ ->where('pay_status', 'SUCCESS')
|
|
|
+ ->pluck('join_pay_order_id')
|
|
|
+ ->toArray();
|
|
|
+ } else {
|
|
|
+ $payDetailIds = Order::whereIn('order_id', $orderIds)->pluck('order_groupby')->toArray();
|
|
|
+ }
|
|
|
+
|
|
|
+ $rows = Order::with([
|
|
|
+ 'payDetail' => function ($query) {
|
|
|
+ $query->where('pay_prepayid', 'like', '%CASH%');
|
|
|
+ }
|
|
|
+ ])->whereIn('order_groupby', $payDetailIds)
|
|
|
+ ->where('order_addtimes', '>', $firstRechargeTime)
|
|
|
+ ->orderBy('order_addtimes', 'DESC')
|
|
|
+ ->get()
|
|
|
+ ->toArray();
|
|
|
+
|
|
|
+ $data = [];
|
|
|
+ foreach ($rows as $row) {
|
|
|
+ $sheets = OrderSheet::with([
|
|
|
+ 'goods' => function ($query) {
|
|
|
+ $query->select('goods_id', 'goods_name');
|
|
|
+ }
|
|
|
+ ])->where('join_sheet_order_id', $row['order_id'])
|
|
|
+ ->get()
|
|
|
+ ->toArray();
|
|
|
+ $deng = "";
|
|
|
+ if (count($sheets) > 1) {
|
|
|
+ $deng = '等';
|
|
|
+ }
|
|
|
+ foreach ($row['pay_detail'] as $item) {
|
|
|
+ if (!empty($item['join_pay_object_json'])) {
|
|
|
+ $payObjectJson = json_decode($item['join_pay_object_json'], true);
|
|
|
+ if ($payObjectJson['order_id'] != $row['order_id']) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $data[] = [
|
|
|
+ 'order_classify' => OrderService::$orderClassify[$row['order_classify']],
|
|
|
+ 'order_id' => $row['order_id'],
|
|
|
+ 'goods_name' => !empty($sheets[0]) && !empty($sheets[0]['goods']) ? ($sheets[0]['goods']['goods_name'] . $deng) : '',
|
|
|
+ 'order_amount_total' => $row['order_amount_total'],
|
|
|
+ 'order_amount_pay' => $row['order_amount_pay'],
|
|
|
+ 'pay_paytimes' => $item['pay_paytimes'] ?? "",
|
|
|
+ 'order_addtimes' => $row['order_addtimes'],
|
|
|
+ 'pay_amount' => $item['pay_amount']
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return json_success('success', $data);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @Desc 获取权益使用记录
|
|
|
* @Author Gorden
|
|
@@ -977,15 +1070,15 @@ class MemberController
|
|
|
$data[] = [
|
|
|
'discountAmount' => '优惠合计:¥' . sprintf('%.2f', $dicountAmount)
|
|
|
];
|
|
|
- $data[] = [
|
|
|
- 'order_classify' => '申请人:' . $applyUsername,
|
|
|
- ];
|
|
|
- $data[] = [
|
|
|
- 'order_classify' => '电话:' . $applyMobile,
|
|
|
- ];
|
|
|
- $data[] = [
|
|
|
- 'order_classify' => '退款金额:' . $applyAmount,
|
|
|
- ];
|
|
|
+// $data[] = [
|
|
|
+// 'order_classify' => '申请人:' . $applyUsername,
|
|
|
+// ];
|
|
|
+// $data[] = [
|
|
|
+// 'order_classify' => '电话:' . $applyMobile,
|
|
|
+// ];
|
|
|
+// $data[] = [
|
|
|
+// 'order_classify' => '退款金额:' . $applyAmount,
|
|
|
+// ];
|
|
|
|
|
|
// 产生退款记录
|
|
|
$this->refundOrder($memberId, $returnApplayData);
|