From 2b77a4c158a89b3da44d308e31cc9d1e2334db11 Mon Sep 17 00:00:00 2001 From: weigang Date: Wed, 9 Sep 2020 14:40:43 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E6=8F=90=E7=8E=B0=E6=B5=81=E6=B0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/v3/WithdrawController.php | 10 +++++++- app/Model/v3/FinancialRecord.php | 10 ++++++++ .../FinancialRecordService.php | 18 +++++++++++++ .../FinancialRecordServiceInterface.php | 25 ++++++++++++++++++- 4 files changed, 61 insertions(+), 2 deletions(-) diff --git a/app/Controller/v3/WithdrawController.php b/app/Controller/v3/WithdrawController.php index 4ccae31..207eb6a 100644 --- a/app/Controller/v3/WithdrawController.php +++ b/app/Controller/v3/WithdrawController.php @@ -157,7 +157,7 @@ class WithdrawController extends BaseController $withdraw->apply_cash = $money; $withdraw->save(); - // 扣除余额 + // 先扣除余额 $balance->balance = bcsub($balance->balance, $money, 2); $balance->save(); @@ -172,6 +172,14 @@ class WithdrawController extends BaseController '商户提现打款' ); // 更新打款金额,审核时间等 + $withdraw->check_time = time(); + $withdraw->real_cash = $money; + $withdraw->save(); + + // 打款成功,写流水 + if ($res === true) { + $this->financialService->storeWithdrawByWx($store->user_id, 0, $withdraw->real_cash); + } } Db::commit(); diff --git a/app/Model/v3/FinancialRecord.php b/app/Model/v3/FinancialRecord.php index e214652..3a24229 100644 --- a/app/Model/v3/FinancialRecord.php +++ b/app/Model/v3/FinancialRecord.php @@ -47,6 +47,7 @@ class FinancialRecord extends Model * 订单 * SOURCE_TYPE_ORDER / 1 */ + const SOURCE_TYPE_NONE = 0; const SOURCE_TYPE_ORDER = 1; /** @@ -60,9 +61,18 @@ class FinancialRecord extends Model const MONEY_TYPE_STORE_OL_ORDER_COMP = 6; // 商户线上订单完成收入 const MONEY_TYPE_STORE_OFL_ORDER_COMP = 7; // 商户线下订单完成收入 const MONEY_TYPE_USER_OL_ORDER_REFUND = 8; // 用户线上订单退款 + const MONEY_TYPE_MM_PLAT_NEW_USER = 9; // 市场经理发展新用户 + const MONEY_TYPE_MM_PLAT_NEW_STORE = 10; // 市场经理发展新商户 + const MONEY_TYPE_MP_PLAT_NEW_USER = 11; // 服务商发展新用户 + const MONEY_TYPE_MP_PLAT_NEW_STORE = 12; // 服务商发展新商户 + const MONEY_TYPE_MP_OL_ORDER = 13; // 服务商线上订单分账(线上订单完成) const MONEY_TYPE_USER_OFL_ORDER = 100; // 用户线下支付订单 const MONEY_TYPE_USER_OL_ORDER = 101; // 用户线上支付订单 + const MONEY_TYPE_MP_WITHDRAW = 102; // 服务商提现类型 + const MONEY_TYPE_MM_WITHDRAW = 103; // 市场经理提现类型 + const MONEY_TYPE_CS_WITHDRAW = 104; // 社区提现类型 + const MONEY_TYPE_STORE_WITHDRAW = 105; // 商户提现类型 /** * 状态 diff --git a/app/Service/v3/Implementations/FinancialRecordService.php b/app/Service/v3/Implementations/FinancialRecordService.php index 97fc31c..b09920d 100644 --- a/app/Service/v3/Implementations/FinancialRecordService.php +++ b/app/Service/v3/Implementations/FinancialRecordService.php @@ -333,4 +333,22 @@ class FinancialRecordService implements FinancialRecordServiceInterface return bcadd($sumAmount, '0', 2); } + + /** + * @inheritDoc + */ + public function storeWithdrawByWx( + $user_id, + $source_id, + $money, + $user_type = UserType::STORE, + $source_type = FinancialRecord::SOURCE_TYPE_NONE, + $money_type = FinancialRecord::MONEY_TYPE_STORE_WITHDRAW, + $desc = '商户提现', + $comment = '商户提现打款' + ) + { + $this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment); + + } } \ No newline at end of file diff --git a/app/Service/v3/Interfaces/FinancialRecordServiceInterface.php b/app/Service/v3/Interfaces/FinancialRecordServiceInterface.php index 6958fb2..c0c5932 100644 --- a/app/Service/v3/Interfaces/FinancialRecordServiceInterface.php +++ b/app/Service/v3/Interfaces/FinancialRecordServiceInterface.php @@ -3,7 +3,7 @@ namespace App\Service\v3\Interfaces; use App\Constants\v3\UserType; -use App\Model\FinancialRecord; +use App\Model\v3\FinancialRecord; interface FinancialRecordServiceInterface { @@ -263,4 +263,27 @@ interface FinancialRecordServiceInterface $money_type = [] ); + /** + * 商户微信提现流水 + * @param $user_id + * @param $source_id + * @param $money + * @param int $user_type + * @param int $source_type + * @param int $money_type + * @param string $desc + * @param string $comment + * @return mixed + */ + public function storeWithdrawByWx( + $user_id, + $source_id, + $money, + $user_type = UserType::STORE, + $source_type = FinancialRecord::SOURCE_TYPE_NONE, + $money_type = FinancialRecord::MONEY_TYPE_STORE_WITHDRAW, + $desc='商户提现', + $comment='' + ); + } \ No newline at end of file From 6c6fa58e783e3bb1717c3c31ad7ad1f4852a9cc3 Mon Sep 17 00:00:00 2001 From: weigang Date: Wed, 9 Sep 2020 14:46:34 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E6=8F=90=E7=8E=B0=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/v3/WithdrawController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Controller/v3/WithdrawController.php b/app/Controller/v3/WithdrawController.php index 207eb6a..9a6f99f 100644 --- a/app/Controller/v3/WithdrawController.php +++ b/app/Controller/v3/WithdrawController.php @@ -171,9 +171,11 @@ class WithdrawController extends BaseController $withdraw->name, '商户提现打款' ); + // 更新打款金额,审核时间等 $withdraw->check_time = time(); $withdraw->real_cash = $money; + $withdraw->state = 2; $withdraw->save(); // 打款成功,写流水 From f32c8588f3751cdbb15f7093dfad1d57a6e291b3 Mon Sep 17 00:00:00 2001 From: weigang Date: Wed, 9 Sep 2020 15:23:15 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Model/v3/Goods.php | 15 +++++++++++++++ app/Model/v3/GoodsActivity.php | 15 +++++++++++++++ app/Model/v3/OrderGoods.php | 10 ++++++++++ 3 files changed, 40 insertions(+) diff --git a/app/Model/v3/Goods.php b/app/Model/v3/Goods.php index 452d025..1e6a60e 100644 --- a/app/Model/v3/Goods.php +++ b/app/Model/v3/Goods.php @@ -133,4 +133,19 @@ class Goods extends Model return $this->morphMany(ShoppingCart::class, 'goods'); } + public function setSpecAttribute($value) + { + $this->attributes['spec'] = json_encode($value); + } + + public function setTagsAttribute($value) + { + $this->attributes['tags'] = json_encode($value); + } + + public function setDetailsImgsAttribute($value) + { + $this->attributes['details_imgs'] = json_encode($value); + } + } \ No newline at end of file diff --git a/app/Model/v3/GoodsActivity.php b/app/Model/v3/GoodsActivity.php index 4eea067..497a6da 100644 --- a/app/Model/v3/GoodsActivity.php +++ b/app/Model/v3/GoodsActivity.php @@ -99,4 +99,19 @@ class GoodsActivity extends Model { return $this->morphMany(ShoppingCart::class, 'goods'); } + + public function setSpecAttribute($value) + { + $this->attributes['spec'] = json_encode($value); + } + + public function setTagsAttribute($value) + { + $this->attributes['tags'] = json_encode($value); + } + + public function setDetailsImgsAttribute($value) + { + $this->attributes['details_imgs'] = json_encode($value); + } } \ No newline at end of file diff --git a/app/Model/v3/OrderGoods.php b/app/Model/v3/OrderGoods.php index b8290d0..b1e1035 100644 --- a/app/Model/v3/OrderGoods.php +++ b/app/Model/v3/OrderGoods.php @@ -52,4 +52,14 @@ class OrderGoods extends Model { return Goods::query()->where(['id' => $this->attributes['goods_id']])->value('tags'); } + + public function setSpecAttribute($value) + { + $this->attributes['spec'] = json_encode($value); + } + + public function setTagsAttribute($value) + { + $this->attributes['tags'] = json_encode($value); + } } \ No newline at end of file From 1c22e50074c507c80d100fea7ef7cbf1d5de37e8 Mon Sep 17 00:00:00 2001 From: weigang Date: Wed, 9 Sep 2020 15:27:59 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E5=85=A8=E5=B1=80=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Commons/LanzuRequest.php | 61 ------------------- app/Middleware/Auth/ApiMiddleware.php | 15 ++++- app/Middleware/CorsMiddleware.php | 54 ++++++++-------- .../v3/Implementations/CouponRecService.php | 5 ++ .../Implementations/GoodsActivityService.php | 5 -- 5 files changed, 46 insertions(+), 94 deletions(-) delete mode 100644 app/Commons/LanzuRequest.php diff --git a/app/Commons/LanzuRequest.php b/app/Commons/LanzuRequest.php deleted file mode 100644 index 38e4ce0..0000000 --- a/app/Commons/LanzuRequest.php +++ /dev/null @@ -1,61 +0,0 @@ -storeParsedData(function () { - // $request = $this->getRequest(); - // if (is_array($request->getParsedBody())) { - // $data = $request->getParsedBody(); - // } else { - // $data = []; - // } - - // return array_merge($data, $request->getQueryParams()); - // }); - // } - - protected function storeParsedData(callable $callback) - { - if (! Context::has($this->contextkeys['parsedData'])) { - return Context::set($this->contextkeys['parsedData'], call($callback)); - } - - // var_dump(Context::get($this->contextkeys['parsedData'])); - - $preDatas = Context::get($this->contextkeys['parsedData']); - - if(isset($preDatas['market_id'])){ - if($preDatas['market_id']==-1){ - $preDatas['market_id'] = 0; - unset($preDatas['sign']); - $sign = $this->signature($preDatas); - $preDatas['sign'] = $sign; - Context::set($this->contextkeys['parsedData'],$preDatas); - } - } - - return Context::get($this->contextkeys['parsedData']); - } - - private function signature($params) - { - ksort($params); - - $http_query = []; - foreach ($params as $key => $value) { - $http_query[] = $key.'='.$value; - } - - return sha1(md5(implode('&', $http_query)).config('auth.api.sign.secret_key')); - } -} diff --git a/app/Middleware/Auth/ApiMiddleware.php b/app/Middleware/Auth/ApiMiddleware.php index 826203c..271d20c 100644 --- a/app/Middleware/Auth/ApiMiddleware.php +++ b/app/Middleware/Auth/ApiMiddleware.php @@ -85,10 +85,23 @@ class ApiMiddleware implements MiddlewareInterface if ($exists) { $hashIds = ApplicationContext::getContainer()->get(Hashids::class); $user = $hashIds->decode($userToken); - $this->request->user = User::query()->find($user[0]); + $userModel = User::query()->find($user[0]); + $userModel->userToken = $userToken; + $this->request->user = $userModel; } } + // 处理全局默认值 + $request = \Hyperf\Utils\Context::override(ServerRequestInterface::class, function (ServerRequestInterface $request) + { + $preDatas = $request->getParsedBody(); + if (isset($preDatas['market_id']) && $preDatas['market_id'] == -1) { + $preDatas['market_id'] = 1; + } + + return $request->withParsedBody($preDatas); + }); + return $handler->handle($request); } diff --git a/app/Middleware/CorsMiddleware.php b/app/Middleware/CorsMiddleware.php index 45479a6..71c5530 100644 --- a/app/Middleware/CorsMiddleware.php +++ b/app/Middleware/CorsMiddleware.php @@ -29,35 +29,35 @@ class CorsMiddleware implements MiddlewareInterface return $response; } - $request = \Hyperf\Utils\Context::override(ServerRequestInterface::class, function (ServerRequestInterface $request) - { - $preDatas = $request->getParsedBody(); - if(isset($preDatas['market_id'])){ - if($preDatas['market_id']==-1){ - $preDatas['market_id'] = 0; - - if (env('APP_ENV') == 'prod') { - unset($preDatas['sign']); - $sign = $this->signature($preDatas); - $preDatas['sign'] = $sign; - } - } - } - return $request->withParsedBody($preDatas); - }); + // $request = \Hyperf\Utils\Context::override(ServerRequestInterface::class, function (ServerRequestInterface $request) + // { + // $preDatas = $request->getParsedBody(); + // if(isset($preDatas['market_id'])){ + // if($preDatas['market_id']==-1){ + // $preDatas['market_id'] = 0; + // + // if (env('APP_ENV') == 'prod') { + // unset($preDatas['sign']); + // $sign = $this->signature($preDatas); + // $preDatas['sign'] = $sign; + // } + // } + // } + // return $request->withParsedBody($preDatas); + // }); return $handler->handle($request); } - private function signature($params) - { - ksort($params); - - $http_query = []; - foreach ($params as $key => $value) { - $http_query[] = $key.'='.$value; - } - - return sha1(md5(implode('&', $http_query)).config('auth.api.sign.secret_key')); - } + // private function signature($params) + // { + // ksort($params); + // + // $http_query = []; + // foreach ($params as $key => $value) { + // $http_query[] = $key.'='.$value; + // } + // + // return sha1(md5(implode('&', $http_query)).config('auth.api.sign.secret_key')); + // } } \ No newline at end of file diff --git a/app/Service/v3/Implementations/CouponRecService.php b/app/Service/v3/Implementations/CouponRecService.php index f61a37c..c1870fa 100644 --- a/app/Service/v3/Implementations/CouponRecService.php +++ b/app/Service/v3/Implementations/CouponRecService.php @@ -79,6 +79,11 @@ class CouponRecService implements CouponRecServiceInterface /** * 用户优惠券列表 + * @param $userId + * @param $type + * @param int $page + * @param int $pagesize + * @return array */ public function getListByUser($userId,$type,$page = 1,$pagesize = 5) { diff --git a/app/Service/v3/Implementations/GoodsActivityService.php b/app/Service/v3/Implementations/GoodsActivityService.php index 798497d..7f1cf60 100644 --- a/app/Service/v3/Implementations/GoodsActivityService.php +++ b/app/Service/v3/Implementations/GoodsActivityService.php @@ -91,10 +91,8 @@ class GoodsActivityService implements GoodsActivityServiceInterface $expireTime = 0; if ($goods->time_limit_days >= 1) { $expireTime += strtotime(date('Y-m-d 23:59:59')) - time(); - var_dump('ex1', $expireTime); } $expireTime += ($goods->time_limit_days-1) * 86400; - var_dump('ex2', $expireTime); $ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); @@ -112,19 +110,16 @@ class GoodsActivityService implements GoodsActivityServiceInterface $goods = GoodsActivity::query() ->where('id', $goodsId) ->first(); - var_dump('$goods', $goods, $goodsId); if (empty($goods)) { return true; } $ssdbKey = SsdbKeys::ACTIVITY_GOODS_BUY_RECORD.$userId.'_'.$goods->type.'_'.$goodsId; - var_dump('ssdbkey', $ssdbKey); $ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); if (!$ssdb->exec('exists', $ssdbKey)) { } else { $res = $ssdb->exec('incr', $ssdbKey, -1*$num); - var_dump('res', $res, -1*$num); } } From 23d70b425d007f80befa06a87e5dc968bdf5b122 Mon Sep 17 00:00:00 2001 From: weigang Date: Wed, 9 Sep 2020 15:39:12 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=95=86=E5=93=81?= =?UTF-8?q?=E8=A1=A8spec=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Model/v3/Goods.php | 15 --------------- app/Model/v3/GoodsActivity.php | 14 -------------- app/Model/v3/OrderGoods.php | 10 ---------- .../v3/Implementations/OrderOnlineService.php | 2 +- 4 files changed, 1 insertion(+), 40 deletions(-) diff --git a/app/Model/v3/Goods.php b/app/Model/v3/Goods.php index 1e6a60e..452d025 100644 --- a/app/Model/v3/Goods.php +++ b/app/Model/v3/Goods.php @@ -133,19 +133,4 @@ class Goods extends Model return $this->morphMany(ShoppingCart::class, 'goods'); } - public function setSpecAttribute($value) - { - $this->attributes['spec'] = json_encode($value); - } - - public function setTagsAttribute($value) - { - $this->attributes['tags'] = json_encode($value); - } - - public function setDetailsImgsAttribute($value) - { - $this->attributes['details_imgs'] = json_encode($value); - } - } \ No newline at end of file diff --git a/app/Model/v3/GoodsActivity.php b/app/Model/v3/GoodsActivity.php index 497a6da..9e59936 100644 --- a/app/Model/v3/GoodsActivity.php +++ b/app/Model/v3/GoodsActivity.php @@ -100,18 +100,4 @@ class GoodsActivity extends Model return $this->morphMany(ShoppingCart::class, 'goods'); } - public function setSpecAttribute($value) - { - $this->attributes['spec'] = json_encode($value); - } - - public function setTagsAttribute($value) - { - $this->attributes['tags'] = json_encode($value); - } - - public function setDetailsImgsAttribute($value) - { - $this->attributes['details_imgs'] = json_encode($value); - } } \ No newline at end of file diff --git a/app/Model/v3/OrderGoods.php b/app/Model/v3/OrderGoods.php index b1e1035..b8290d0 100644 --- a/app/Model/v3/OrderGoods.php +++ b/app/Model/v3/OrderGoods.php @@ -52,14 +52,4 @@ class OrderGoods extends Model { return Goods::query()->where(['id' => $this->attributes['goods_id']])->value('tags'); } - - public function setSpecAttribute($value) - { - $this->attributes['spec'] = json_encode($value); - } - - public function setTagsAttribute($value) - { - $this->attributes['tags'] = json_encode($value); - } } \ No newline at end of file diff --git a/app/Service/v3/Implementations/OrderOnlineService.php b/app/Service/v3/Implementations/OrderOnlineService.php index 7e421e5..cdc2e36 100644 --- a/app/Service/v3/Implementations/OrderOnlineService.php +++ b/app/Service/v3/Implementations/OrderOnlineService.php @@ -207,7 +207,7 @@ class OrderOnlineService implements OrderOnlineServiceInterface 'name' => $goods->name, 'goods_unit' => $goods->goods_unit, 'cover_img' => $goods->cover_img, - 'spec' => $goods->spec, + 'spec' => json_encode($goods->spec), ]; } From 885eead7a61e5027e4f6ea6642653cca2900ea77 Mon Sep 17 00:00:00 2001 From: weigang Date: Wed, 9 Sep 2020 16:40:56 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E5=BD=93=E9=9D=A2=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v3/Implementations/CouponRecService.php | 23 ++++++++++++++++--- .../Implementations/OrderOfflineService.php | 12 ++++++++-- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/app/Service/v3/Implementations/CouponRecService.php b/app/Service/v3/Implementations/CouponRecService.php index c1870fa..ac57d12 100644 --- a/app/Service/v3/Implementations/CouponRecService.php +++ b/app/Service/v3/Implementations/CouponRecService.php @@ -2,17 +2,24 @@ namespace App\Service\v3\Implementations; -use App\Model\ShopCar; use App\Model\v3\Coupon; use App\Model\v3\CouponRec; use App\Service\v3\Interfaces\CouponRecServiceInterface; +use App\Service\v3\Interfaces\ShopCartServiceInterface; use Hyperf\DbConnection\Db; use Hyperf\Redis\Redis; use Hyperf\Utils\ApplicationContext; +use Hyperf\Di\Annotation\Inject; class CouponRecService implements CouponRecServiceInterface { + /** + * @Inject + * @var ShopCartServiceInterface + */ + protected $shopCartService; + public function do() { // TODO: Implement do() method. @@ -148,12 +155,22 @@ class CouponRecService implements CouponRecServiceInterface * 2、筛选出其中当日使用过的优惠券 * 3、筛选出其中活动商品不可用的优惠券(订单中有活动商品且活动商品不可使用优惠券) * 4、筛选出其中活动商品可用但商品的活动类型不符合优惠券活动使用类型的要求(订单中有活动商品可以用优惠券,但是活动类型type和优惠券中的available活动类型不可用) - * @param $cartIds * @param $userId * @param $marketId */ - public function allForOnlineOrderAvailable($cartIds, $userId, $marketId) + public function allForOnlineOrderAvailable($userId, $marketId) { + // 获取购物车数据 + $carts = $this->shopCartService->allForUser($userId, $marketId); + $totalAmount = $carts['total']; + + // 获取用户可用优惠券(1) + $coupons = CouponRec::query() + ->join('lanzu_coupon as coupon', 'coupon.id', '=', '') + ->where(['user_id' => $userId]) + ->where('number_remain', '>', 0) + ->whereIn('status', [0,1]) + ->get(); } diff --git a/app/Service/v3/Implementations/OrderOfflineService.php b/app/Service/v3/Implementations/OrderOfflineService.php index 4fdc741..f0e76e5 100644 --- a/app/Service/v3/Implementations/OrderOfflineService.php +++ b/app/Service/v3/Implementations/OrderOfflineService.php @@ -2,6 +2,7 @@ namespace App\Service\v3\Implementations; +use App\Commons\Log; use App\Constants\v3\ErrorCode; use App\Constants\v3\LogLabel; use App\Constants\v3\OrderState; @@ -26,6 +27,12 @@ class OrderOfflineService implements OrderOfflineServiceInterface */ protected $paymentService; + /** + * @Inject + * @var Log + */ + protected $log; + public function do($storeId, $userId, $money, $plat ='') { try { @@ -62,8 +69,9 @@ class OrderOfflineService implements OrderOfflineServiceInterface // 店铺今天的订单数 $count = Order::query() - ->where(['store_id' => $storeId, 'type' => OrderType::OFFLINE]) - ->whereBetween('created_at', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]) + ->join('lanzu_order_main as main', 'main.id', '=', 'lanzu_order.order_main_id') + ->where(['lanzu_order.store_id' => $storeId, 'main.type' => OrderType::OFFLINE]) + ->whereBetween('lanzu_order.created_at', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]) ->count(); // 子订单数据 From 504698328f80a699aec3ce828f7437256491fdd1 Mon Sep 17 00:00:00 2001 From: weigang Date: Wed, 9 Sep 2020 16:43:56 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AD=97=E6=AE=B5=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Service/v3/Implementations/SearchService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Service/v3/Implementations/SearchService.php b/app/Service/v3/Implementations/SearchService.php index 660d9dd..9caf6e1 100644 --- a/app/Service/v3/Implementations/SearchService.php +++ b/app/Service/v3/Implementations/SearchService.php @@ -44,7 +44,7 @@ class SearchService implements \App\Service\v3\Interfaces\SearchServiceInterface } } - $builder->select(['id', 'store_id', 'cover_img', 'name', 'spec', 'tags', 'original_price', 'price', 'inventory', 'sales as total_sales']); + $builder->select(['*'])->addSelect(['sales as total_sales']); $paginate = $builder->paginate($params['pagesize']); $goods = $paginate->toArray(); return ['has_more_pages' => $paginate->hasMorePages(), 'goods' => $goods['data']]; @@ -55,7 +55,7 @@ class SearchService implements \App\Service\v3\Interfaces\SearchServiceInterface $builder = Store::query() ->with(['goods' => function($query) { return $query->limit(5) - ->select(['id', 'store_id', 'cover_img', 'name', 'spec', 'tags', 'original_price', 'price', 'inventory', 'sales as total_sales']); + ->select(['*'])->addSelect(['sales as total_sales']); }]) ->where(['market_id' => $params['market_id']]);