|
@@ -2,12 +2,19 @@
|
|
|
|
|
|
namespace app\admin\controller\member;
|
|
|
|
|
|
+use app\admin\service\goods\GoodsService;
|
|
|
+use app\admin\service\order\OrderService;
|
|
|
use app\controller\Curd;
|
|
|
use app\model\Card;
|
|
|
+use app\model\Goods;
|
|
|
use app\model\Member;
|
|
|
use app\model\MemberAccount;
|
|
|
use app\model\MemberAccountList;
|
|
|
use app\model\MemberBenefit;
|
|
|
+use app\model\Order;
|
|
|
+use app\model\OrderSheet;
|
|
|
+use app\model\PayDetail;
|
|
|
+use app\model\SysCategory;
|
|
|
use support\Db;
|
|
|
use support\exception\BusinessException;
|
|
|
use support\Log;
|
|
@@ -265,7 +272,7 @@ class AccountController extends Curd
|
|
|
'member_account_list_status' => 'ACTIVED',
|
|
|
'member_account_list_attr' => 'IN',
|
|
|
'member_account_list_classify' => 'CARD',
|
|
|
- 'member_account_list_category' => '绑定储值卡',
|
|
|
+ 'member_account_list_category' => '绑卡',
|
|
|
'member_account_list_datetime' => date('Y-m-d H:i:s'),
|
|
|
'member_account_list_amount' => $card->main->card_main_amount,
|
|
|
'member_account_list_addtimes' => time()
|
|
@@ -280,4 +287,94 @@ class AccountController extends Curd
|
|
|
return json_fail("绑定失败");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Desc 导出储值卡账户消费记录
|
|
|
+ * @Author Gorden
|
|
|
+ * @Date 2024/12/3 10:07
|
|
|
+ *
|
|
|
+ * @param Request $request
|
|
|
+ * @return \support\Response
|
|
|
+ */
|
|
|
+ public function exportCardConsumeList(Request $request)
|
|
|
+ {
|
|
|
+ $memberId = $request->get('member_id', '');
|
|
|
+ $accountNbr = $request->get('account_nbr', '');
|
|
|
+
|
|
|
+ $account = MemberAccount::where('join_account_member_id', $memberId)
|
|
|
+ ->where('member_account_nbr', $accountNbr)
|
|
|
+ ->where('member_account_classify', 'CARD')
|
|
|
+ ->first();
|
|
|
+ if (!$account) {
|
|
|
+ return json_fail('暂无数据');
|
|
|
+ }
|
|
|
+ $balance = $account->member_account_surplus + $account->member_account_added;
|
|
|
+
|
|
|
+ $info = PayDetail::where('pay_prepayid', $accountNbr)
|
|
|
+ ->where('pay_status', 'SUCCESS')
|
|
|
+ ->orderByDesc('pay_addtimes')
|
|
|
+ ->get()
|
|
|
+ ->toArray();
|
|
|
+ $data = [];
|
|
|
+ foreach ($info as $key => $item) {
|
|
|
+ unset($item['pay_json_request']);
|
|
|
+ $categoryIds = [];
|
|
|
+ if (!empty($item['join_pay_order_id'])) {
|
|
|
+ $orderIds = Order::where('order_groupby', $item['join_pay_order_id'])->pluck('order_id')->toArray();
|
|
|
+ $goodsIds = OrderSheet::whereIn('join_sheet_order_id', $orderIds)->pluck('join_sheet_goods_id')->toArray();
|
|
|
+ $categoryIds = Goods::whereIn('goods_id', $goodsIds)->pluck('join_goods_category_id')->toArray();
|
|
|
+ }
|
|
|
+
|
|
|
+ $categoryName = [];
|
|
|
+ foreach ($categoryIds as $id) {
|
|
|
+ $category = SysCategory::where('category_id', $id)->first();
|
|
|
+ if (!empty($category->category_super_path)) {
|
|
|
+ $path = explode('#', $category->category_super_path);
|
|
|
+ $ids = array_filter($path);
|
|
|
+ $categoryName[] = SysCategory::where('category_id', current($ids))->value('category_name');
|
|
|
+ } else {
|
|
|
+ $categoryName[] = $category->category_name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $item['goods_category'] = implode(',', array_unique($categoryName));
|
|
|
+ if (in_array($item['pay_category'], ['RECHARGE', 'REFUND'])) {
|
|
|
+ $item['balance_type'] = 'add';
|
|
|
+ } else {
|
|
|
+ $item['balance_type'] = 'cut';
|
|
|
+ }
|
|
|
+ $balance = $balance + $item['pay_amount'];
|
|
|
+ $payCategory = '消费';
|
|
|
+ if ($item['pay_category'] == 'REFUND') {
|
|
|
+ $payCategory = '退款';
|
|
|
+ }
|
|
|
+ $data[] = [
|
|
|
+ 'goods_category' => $item['goods_category'],
|
|
|
+ 'join_pay_order_id' => $item['join_pay_order_id'],
|
|
|
+ 'balance' => number_format($balance, 2, '.', ''),
|
|
|
+ 'balance_type' => $item['balance_type'],
|
|
|
+ 'pay_amount' => ($item['balance_type'] == 'add' ? '+' : '-') . $item['pay_amount'],
|
|
|
+ 'pay_category' => $payCategory,
|
|
|
+ 'pay_addtimes' => $item['pay_addtimes']
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ // 绑定记录
|
|
|
+ $memberAccountLists = MemberAccountList::where('join_list_member_account_nbr', $accountNbr)
|
|
|
+ ->where('member_account_list_attr', 'IN')
|
|
|
+ ->select('member_account_list_amount', 'member_account_list_datetime', 'member_account_list_attr', 'join_list_member_account_nbr', 'member_account_list_addtimes')
|
|
|
+ ->get()
|
|
|
+ ->toArray();
|
|
|
+ foreach ($memberAccountLists as $item) {
|
|
|
+ $data[] = [
|
|
|
+ 'goods_category' => '--',
|
|
|
+ 'join_pay_order_id' => '--',
|
|
|
+ 'balance' => $item['member_account_list_amount'],
|
|
|
+ 'pay_amount' => '+' . $item['member_account_list_amount'],
|
|
|
+ 'pay_category' => '绑定',
|
|
|
+ 'pay_addtimes' => $item['member_account_list_addtimes'],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ return json_success('success', $data);
|
|
|
+ }
|
|
|
}
|