全部
常见问题
产品动态
精选推荐

微信扫码核销问题

管理 管理 编辑 删除

问题说明:微信扫核销码权限判断处理

修改文件:app\controller\api\admin\order\StoreOrder

修改方法:order_verific()

0596d202410161648427335.png

public function order_verific(Request $request, WriteOffOrderServices $writeOffOrderServices, StoreOrderCartInfoServices $orderCartInfo, StoreOrderServices $orderServices)
    {
        [$code, $auth] = $request->postMore([
            ['code', ''],
            ['auth', 0],
        ], true);
        if (!$code) return app('json')->fail('Lack of write-off code');
        $uid = $request->uid();
        /** @var StoreServiceServices $storeService */
        $storeService = app()->make(StoreServiceServices::class);
        $userService = $storeService->checkoutIsService(['uid' => $uid, 'status' => 1, 'account_status' => 1]); //客服权限是否存在
        if ($auth == 1 && !$userService) return app('json')->fail('您没有客服权限!');
        /** @var DeliveryServiceServices $deliveryService */
        $deliveryService = app()->make(DeliveryServiceServices::class);
        $deliveryUser = $deliveryService->checkoutIsService($uid); // 检查用户是否是配送员
        if ($auth == 2 && !$deliveryUser) return app('json')->fail('您不是配送员!');
        //验证店员
        /** @var SystemStoreStaffServices $storeStaffServices */
        $storeStaffServices = app()->make(SystemStoreStaffServices::class);
        $where = ['uid' => $uid, 'is_del' => 0, 'status' => 1, 'verify_status' => 1];
        $info = $storeStaffServices->getOne($where);
        if($auth == 4 && !$info) return app('json')->fail('您不是店员!');
        if ($auth == 3) {
            if ($userService) {
                $auth = 1;
            } else if ($info) {
                $auth = 4;
            } else if ($deliveryUser) {
                $auth = 2;
            } else {
                return app('json')->fail('您没有任何权限!');
            }
        }
        /** @var UserServices $userServices */
        $userServices = app()->make(UserServices::class);
        $userInfo = $userServices->getOne(['bar_code' => $code]);
        if ($userInfo) {
            $userInfo = $userInfo->toArray();
            $is_order_code = 0;
        } else {
            $orderInfo = $orderServices->getOne(['verify_code' => $code, 'is_del' => 0]);
            if ($orderInfo) {
                $is_order_code = 1;
            } else {
                return app('json')->fail('暂未获取到订单信息,请先确认传入的码是否正确');
            }
        }
        $product_type = 0;
        if ($is_order_code == 1) {
            $orderInfo = $writeOffOrderServices->writeoffOrderInfo($uid, $code, $auth);
            if ($orderInfo && isset($orderInfo['product_type'])) {
                $product_type = $orderInfo['product_type'];
            }
            $data = [$orderInfo];
        } else {
            $data = $writeOffOrderServices->userUnWriteoffOrder($uid, $code, $auth);
            if (count($data) == 1) {
                $is_order_code = 1;
                $orderInfo = $data[0];
                if ($orderInfo && isset($orderInfo['product_type'])) {
                    $product_type = $orderInfo['product_type'];
                }
            }
        }
        $res = [];
        if ($data) {
            /** @var StoreOrderServices $orderServices */
            $orderServices = app()->make(StoreOrderServices::class);
            $res = $orderServices->tidyOrderList($data, false);
            foreach ($res as &$orderInfo) {
                $orderInfo['image'] = '';
                if (isset($orderInfo['cart_id'][0])) {
                    $cartInfo = $orderCartInfo->getOne(['oid' => $orderInfo['id'], 'cart_id' => $orderInfo['cart_id'][0]], 'cart_info');
                    if ($cartInfo) $orderInfo['image'] = $cartInfo['cart_info']['productInfo']['image'] ?? '';
                }
            }
        }
        return app('json')->success(['data' => $res, 'is_order_code' => $is_order_code, 'product_type' => $product_type, 'auth' => $auth]);
    }


修改文件:app\controller\api\store\order\StoreOrder

修改方法:order_verific()

33cf0202410161650242733.png

public function order_verific(Request $request, WriteOffOrderServices $writeOffOrderServices, StoreOrderCartInfoServices $orderCartInfo, StoreOrderServices $orderServices)
	{
		[$code, $auth] = $request->postMore([
			['code', ''],
			['auth', 0],
		], true);
		if (!$code) return app('json')->fail('Lack of write-off code');
		$uid = $request->uid();
		/** @var StoreServiceServices $storeService */
		$storeService = app()->make(StoreServiceServices::class);
		$userService = $storeService->checkoutIsService(['uid' => $uid, 'status' => 1, 'account_status' => 1]); //客服权限是否存在
		if ($auth == 2 && !$userService) return app('json')->fail('您没有客服权限!');
		/** @var DeliveryServiceServices $deliveryService */
		$deliveryService = app()->make(DeliveryServiceServices::class);
		$deliveryUser = $deliveryService->checkoutIsService($uid); // 检查用户是否是配送员
		if ($auth == 2 && !$deliveryUser) return app('json')->fail('您不是配送员!');
        //验证店员
        /** @var SystemStoreStaffServices $storeStaffServices */
        $storeStaffServices = app()->make(SystemStoreStaffServices::class);
        $where = ['uid' => $uid, 'is_del' => 0, 'status' => 1, 'verify_status' => 1];
        $info = $storeStaffServices->getOne($where);
        if($auth == 4 && !$info) return app('json')->fail('您不是店员!');
		if ($auth == 3) {
            if ($userService) {
                $auth = 1;
            } else if ($info) {
                $auth = 4;
            } else if ($deliveryUser) {
                $auth = 2;
            } else {
                return app('json')->fail('您没有任何权限!');
            }
		}
		/** @var UserServices $userServices */
		$userServices = app()->make(UserServices::class);
		$userInfo = $userServices->getOne(['bar_code' => $code]);
		if ($userInfo) {
			$userInfo = $userInfo->toArray();
			$is_order_code = 0;
		} else {
			$orderInfo = $orderServices->getOne(['verify_code' => $code, 'is_del' => 0]);
			if ($orderInfo) {
				$is_order_code = 1;
			} else {
				return app('json')->fail('暂未获取到订单信息,请先确认传入的码是否正确');
			}
		}
		$product_type = 0;
		if ($is_order_code == 1) {
			$orderInfo = [];
			try {
				$orderInfo = $writeOffOrderServices->writeoffOrderInfo($uid, $code, $auth);
			} catch (\Throwable $e) {
			}
			if ($orderInfo && isset($orderInfo['product_type'])) {
				$product_type = $orderInfo['product_type'];
			}
			$data = [$orderInfo];
		} else {
			$data = [];
			try {
				$data = $writeOffOrderServices->userUnWriteoffOrder($uid, $code, $auth);
			} catch (\Throwable $e) {
			}
			if (count($data) == 1) {
				$is_order_code = 1;
				$orderInfo = $data[0];
				if ($orderInfo && isset($orderInfo['product_type'])) {
					$product_type = $orderInfo['product_type'];
				}
			}
		}
		$res = [];
		if ($data) {
			/** @var StoreOrderServices $orderServices */
			$orderServices = app()->make(StoreOrderServices::class);
			$res = $orderServices->tidyOrderList($data, false);
			foreach ($res as &$orderInfo) {
				$orderInfo['image'] = '';
				if (isset($orderInfo['cart_id'][0])) {
					$cartInfo = $orderCartInfo->getOne(['oid' => $orderInfo['id'], 'cart_id' => $orderInfo['cart_id'][0]], 'cart_info');
					if ($cartInfo) $orderInfo['image'] = $cartInfo['cart_info']['productInfo']['image'] ?? '';
				}
			}
		}
		return app('json')->success(['data' => $res, 'is_order_code' => $is_order_code, 'product_type' => $product_type, 'auth' => $auth]);
	}


请登录后查看

全 最后编辑于2024-10-16 16:51:28

快捷回复
回复({{post_count}}) {{!is_user ? '我的回复' :'全部回复'}}
排序 默认正序 回复倒序 点赞倒序

{{item.user_info.nickname ? item.user_info.nickname : item.user_name}}

作者 管理员 企业

{{item.floor}}# 同步到gitee 已同步到gitee {{item.is_suggest==1? '取消推荐': '推荐'}}
沙发 板凳 地板 {{item.floor}}#
{{item.user_info.title}}
附件

{{itemf.name}}

{{item.created_at}}  {{item.ip_address}}
{{item.like_count}}
{{item.showReply ? '取消回复' : '回复'}}
删除
回复
回复

{{itemc.user_info.nickname}}

{{itemc.user_name}}

作者 管理员 企业

回复 {{itemc.comment_user_info.nickname}}

附件

{{itemf.name}}

{{itemc.created_at}}   {{itemc.ip_address}}
{{itemc.like_count}}
{{itemc.showReply ? '取消回复' : '回复'}}
删除
回复
回复
查看更多
回复
回复
252
{{like_count}}
{{collect_count}}
添加回复 ({{post_count}})

相关推荐

快速安全登录

使用微信扫码登录
{{item.label}} {{item.label}} {{item.label}} 板块推荐 常见问题 产品动态 精选推荐 首页头条 首页动态 首页推荐
加精
取 消 确 定
回复
回复
问题:
问题自动获取的帖子内容,不准确时需要手动修改. [获取答案]
答案:
提交
bug 需求 取 消 确 定

微信登录/注册

切换手机号登录

{{ bind_phone ? '绑定手机' : '手机登录'}}

{{codeText}}
切换微信登录/注册
暂不绑定
CRMEB客服

CRMEB咨询热线 咨询热线

400-8888-794

微信扫码咨询

CRMEB开源商城下载 源码下载 CRMEB帮助文档 帮助文档
返回顶部 返回顶部
CRMEB客服