From a08e722b340037df14d63e71f68f4dc23fa0c1eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E6=A1=83?= <1098598843@qq.com> Date: Sat, 18 Feb 2023 10:26:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BB=A3=E8=B4=AD=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/order/StoreOrderRepository.php | 41 +++++++++++++++++++ app/controller/api/enter/EnterCompany.php | 18 ++++++++ route/api.php | 2 + 3 files changed, 61 insertions(+) diff --git a/app/common/repositories/store/order/StoreOrderRepository.php b/app/common/repositories/store/order/StoreOrderRepository.php index fc865bfc..937237ac 100644 --- a/app/common/repositories/store/order/StoreOrderRepository.php +++ b/app/common/repositories/store/order/StoreOrderRepository.php @@ -1585,6 +1585,47 @@ class StoreOrderRepository extends BaseRepository return compact( 'count','list'); } + /**代购订单使用 + * @param array $where + * @param $page + * @param $limit + * @return array + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException + * @author xaboy + * @day 2020/6/10 + */ + public function getList2(array $where, $page, $limit,$cart_id_str) + { + $query = $this->dao->search($where)->where('StoreOrder.is_del', 0)->where( 'cart_id','exp', 'REGEXP \''."(^|,)(".$cart_id_str.")(,|$)".'\''); + $count = $query->count(); + $list = $query->with([ + 'orderProduct', + 'presellOrder', + 'merchant' => function ($query) { + return $query->field('mer_id,mer_name'); + }, + 'community', + 'receipt' => function ($query) { + return $query->field('order_id,order_receipt_id'); + }, + ])->page($page, $limit)->order('pay_time DESC')->append(['refund_status'])->select(); + + foreach ($list as $order) { + if ($order->activity_type == 2) { + if ($order->presellOrder) { + $order->presellOrder->append(['activeStatus']); + $order->presell_price = bcadd($order->pay_price, $order->presellOrder->pay_price, 2); + } else { + $order->presell_price = $order->pay_price; + } + } + } + + return compact( 'count','list'); + } + public function userList($uid, $page, $limit) { $query = $this->dao->search([ diff --git a/app/controller/api/enter/EnterCompany.php b/app/controller/api/enter/EnterCompany.php index 8e987313..311b30f7 100644 --- a/app/controller/api/enter/EnterCompany.php +++ b/app/controller/api/enter/EnterCompany.php @@ -19,6 +19,7 @@ use think\App; use think\facade\Db; use app\common\model\user\User; use app\validate\api\EnterCompanyValidate; +use app\common\repositories\store\order\StoreOrderRepository; use function GuzzleHttp\json_decode; @@ -73,5 +74,22 @@ class EnterCompany extends BaseController return app('json')->success($list); } + // 获取代购订单 + public function get_list($page=1,$limit=10) + { + $uid = $this->request->uid(); + $where = ['uid' => $this->request->uid()]; + $cart_id = Db::table('eb_store_cart') + ->where('uid', '=', $uid) + ->where('is_dg', '=', 1) + ->where('is_pay', '=', 1) + ->where('is_fail', '=', 0) + ->where('is_del', '=', 0) + ->column('cart_id'); + $cart_id_str = implode('|',$cart_id); + $list = app()->make(StoreOrderRepository::class)->getList2($where,$page,$limit,$cart_id_str); + return app('json')->success($list); + } + } diff --git a/route/api.php b/route/api.php index 7e898f05..6af442eb 100644 --- a/route/api.php +++ b/route/api.php @@ -356,6 +356,8 @@ Route::group('api/', function () { Route::post('entercompany', 'api.enter.EnterCompany/add'); // 获取已录入公司 Route::get('enter/list', 'api.enter.EnterCompany/list'); + // 获取代购订单 + Route::get('enter/get_list', 'api.enter.EnterCompany/get_list'); })->middleware(UserTokenMiddleware::class, true); //非强制登录