Commit e2fa1c48 by yink

fix(结算账户): 修复商家角色结算账户查询和删除逻辑

- 修正变量名拼写错误($useObj->role_id 改为 $userObj->role_id)
- 商家角色现在直接返回企业用户信息而非查询member_id
- 禁止商家在前台删除结算账户,需后台操作
- 优化订单列表查询逻辑,增加空值判断和排序
- 修复订单状态显示问题,增加默认值处理
parent ebe2fd7a
......@@ -151,10 +151,28 @@ public function myCard(Request $request)
{
$userObj = $request->user();
$member_type = $request->member_type ?? 0;
$role_id = $useObj->role_id ?? '';
$role_id = $userObj->role_id ?? '';
if ($role_id == 1) { //商家
$mid = $userObj->merchant_id;
$member_id = HfCompanyMember::where(['merchant_id' => $mid, 'status' => 'succeeded'])->value('member_id');
$accountObj = HfCompanyMember::where(['merchant_id' => $mid])->first();
//直接返回企业用户信息
if ($accountObj) {
$account_params = array(
'card_id' => $accountObj->name ?? '',
'card_name' => $accountObj->cont_name ?? '',
'tel_no' => $accountObj->cont_phone ?? '',
'bank_code' => '',
'bank_name' => '',
);
return $this->JsonResponse($account_params);
} else {
Log::add('myCard', ['msg' => '没有查询到绑卡信息!']);
return $this->JsonResponse([], '该商户后台数据错误,请联系管理员!', 201);
}
} else {
$mid = $userObj->id;
$member_id = $userObj->member_id;
......@@ -248,10 +266,12 @@ public function deleteAccount(Request $request)
{
$userObj = $request->user();
$member_type = $request->member_type ?? 0;
$role_id = $useObj->role_id ?? '';
$role_id = $userObj->role_id ?? '';
if ($role_id == 1) { //商家
$mid = $userObj->merchant_id;
$member_id = HfCompanyMember::where(['merchant_id' => $mid, 'status' => 'succeeded'])->value('member_id');
//商家不允许删除和添加,请去后台操作审核
Log::add('deleteAccount', ['msg' => '商家不允许删除和添加,请去后台操作审核!']);
return $this->JsonResponse('', '商家不允许删除和添加银行卡,请去后台申请管理员操作!', 201);
} else {
$mid = $userObj->id;
$member_id = $userObj->member_id;
......@@ -260,6 +280,7 @@ public function deleteAccount(Request $request)
return $this->JsonResponse('', '参数错误', 201);
}
$accountObj = HfSettleAccount::where(['member_type' => $member_type, 'mid' => $mid])->first();
$account_params = array(
'app_id' => env('HUIFU_APPID'),
......
......@@ -60,7 +60,7 @@ public function getUserList(Request $request)
//我的用户-订单列表(展示近10天)
public function getOrderList(Request $request)
{
$mer_id = 4; //$request->user()->merchant_id;
$mer_id = $request->user()->merchant_id;
$user_id = $request->user_id ?? 0;
if (!$user_id) {
return $this->JsonResponse('', '参数错误', 201);
......@@ -70,27 +70,34 @@ public function getOrderList(Request $request)
$list = DB::table("order_divide_record as odr")
->select(DB::raw('odr.order_id, o.order_status,o.created_at'))
->leftJoin('li_order_info as o', 'odr.order_id', '=', 'o.id')
//->whereDate('odr.created_at', '>', $daysAgo)
->whereDate('odr.created_at', '>', $daysAgo)
->where(['odr.sh_type' => 3, 'odr.um_id' => $mer_id, 'odr.user_id' => $user_id])
->orderBy('odr.created_at', 'DESC') // 添加时间倒序排序
->limit(100)
->get()
->toArray();
foreach ($list as $key => $item) {
$ogRows = DB::table('li_order_goods')->where('order_id', $item->order_id)
->select(DB::raw('goods_name,goods_number,goods_price,goods_img,goods_attr'))
->get()
->toArray();
$order_goods = [];
foreach ($ogRows as $key => $valObj) {
$tmp = [];
$tmp['goods_name'] = $valObj->goods_name;
$tmp['goods_number'] = $valObj->goods_number;
$tmp['goods_attr'] = $valObj->goods_attr;
$tmp['goods_price'] = $valObj->goods_price;
$tmp['goods_img'] = $valObj->goods_img ? togetherFilePath($valObj->goods_img) : '';
array_push($order_goods, $tmp);
if ($item->order_id) { // 确保订单ID存在
$ogRows = DB::table('li_order_goods')
->where('order_id', $item->order_id)
->select(DB::raw('goods_name,goods_number,goods_price,goods_img,goods_attr'))
->get()
->toArray();
foreach ($ogRows as $valObj) {
$order_goods[] = [
'goods_name' => $valObj->goods_name,
'goods_number' => $valObj->goods_number,
'goods_attr' => $valObj->goods_attr,
'goods_price' => $valObj->goods_price,
'goods_img' => $valObj->goods_img ? togetherFilePath($valObj->goods_img) : '',
];
}
}
$list[$key]->status_txt = OrderInfo::STATUS_OPTIONS[$list[$key]->order_status];
$list[$key]->status_txt = $item->order_status ? (OrderInfo::STATUS_OPTIONS[$item->order_status] ?? '未知状态') : '订单不存在';
$list[$key]->og = $order_goods;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment