diff --git a/app/Controller/v3/CouponController.php b/app/Controller/v3/CouponController.php index 5b6ad2e..4ba427c 100644 --- a/app/Controller/v3/CouponController.php +++ b/app/Controller/v3/CouponController.php @@ -67,17 +67,9 @@ class CouponController extends BaseController /** * $type unused 未使用 used 已使用 expired已失效 */ - switch ($type){ - case 'unused': - $res = $this->couponRecService->getUnusedListByUser($userId,$page,$pagesize); - break; - case 'used': - $res = $this->couponRecService->getUsedListByUser($userId,$page,$pagesize); - break; - case 'expired': - $res = $this->couponRecService->getExpiredListByUser($userId,$page,$pagesize); - break; - } + + $res = $this->couponRecService->getListByUser($userId,$type,$page,$pagesize); + return $this->success($res); } diff --git a/app/Controller/v3/GoodsController.php b/app/Controller/v3/GoodsController.php index 280eca7..ed9eddc 100644 --- a/app/Controller/v3/GoodsController.php +++ b/app/Controller/v3/GoodsController.php @@ -56,7 +56,7 @@ class GoodsController extends BaseController if(isset($params['user_id'])) { $res['shopcart']['count'] = $this->shopCartService->check(111); $res['shopcart']['total'] = $this->shopCartService->getTotal(); - $res['detail']->store->is_collected = (bool)$this->collectService->check($params['user_id'], $params['store_id']); + $res['detail']->store->is_collected = (bool)$this->collectService->check($params['user_id'], $res['detail']->store->id); }else{ $res['shopcart'] = ''; $res['detail']->store->is_collected = ''; diff --git a/app/Controller/v3/UserAddressController.php b/app/Controller/v3/UserAddressController.php index 961b051..f95d097 100644 --- a/app/Controller/v3/UserAddressController.php +++ b/app/Controller/v3/UserAddressController.php @@ -4,6 +4,7 @@ namespace App\Controller\v3; use App\Controller\BaseController; +use App\Request\v3\UserAddressUpdateRequest; use App\Service\v3\Interfaces\UserAddressServiceInterface; use Hyperf\Di\Annotation\Inject; class UserAddressController extends BaseController @@ -14,7 +15,7 @@ class UserAddressController extends BaseController */ protected $userAddressService; - public function update() + public function update(UserAddressUpdateRequest $request) { $userAddressId = $this->request->input('user_address_id',0); $user_id = $this->request->input('user_id',''); diff --git a/app/Request/v3/UserAddressUpdateRequest.php b/app/Request/v3/UserAddressUpdateRequest.php new file mode 100644 index 0000000..382a2f5 --- /dev/null +++ b/app/Request/v3/UserAddressUpdateRequest.php @@ -0,0 +1,53 @@ + 'required|nonempty|integer', + 'user_name' => 'required|nonempty', + 'address' => 'required|nonempty', + 'doorplate' => 'required|nonempty', + 'gender' => 'required|nonempty|integer|between:1,2', + 'lat' => 'required|nonempty', + 'lng' => 'required|nonempty', + 'tel' => 'required|nonempty' + ]; + } + + /** + * @return array + */ + public function messages(): array + { + return [ + 'user_id.*' => ':attribute无效', + 'gender.*' => ':attribute无效', + ]; + } + + public function attributes(): array + { + return [ + 'user_id' => '用户id', + 'user_name' => '用户名', + 'address' => '地址', + 'doorplate' => '门牌号', + 'gender' => '性别', + 'lat' => '纬度', + 'lng' => '经度', + 'tel' => '电话', + ]; + } +} diff --git a/app/Service/v3/Implementations/CollectStoreService.php b/app/Service/v3/Implementations/CollectStoreService.php index 6ef94c1..f4ba533 100644 --- a/app/Service/v3/Implementations/CollectStoreService.php +++ b/app/Service/v3/Implementations/CollectStoreService.php @@ -37,7 +37,7 @@ class CollectStoreService implements CollectStoreServiceInterface //用户收藏数量自减 $userIncr = $ssdb->exec('incr', SsdbKeys::COUNT_COLLECT_STORE_USER.$userId,'-1'); //店铺被收藏数自减 - $storeIncr = $ssdb->exec('incr', SsdbKeys::COUNT_COLLECT_STORE.$userId,'-1'); + $storeIncr = $ssdb->exec('incr', SsdbKeys::COUNT_COLLECT_STORE.$storeId,'-1'); return $userDel && $userIncr && $storeIncr; } //获取用户收藏店铺数量 diff --git a/app/Service/v3/Implementations/CouponRecService.php b/app/Service/v3/Implementations/CouponRecService.php index eb4c764..f24e871 100644 --- a/app/Service/v3/Implementations/CouponRecService.php +++ b/app/Service/v3/Implementations/CouponRecService.php @@ -78,102 +78,48 @@ class CouponRecService implements CouponRecServiceInterface } /** - * 用户未使用优惠券列表 + * 用户优惠券列表 */ - public function getUnusedListByUser($userId,$page = 1,$pagesize = 5) + public function getListByUser($userId,$type,$page = 1,$pagesize = 5) { - //查询可用优惠券 + //查询优惠券 $builder = CouponRec::query()->join('lanzu_coupon', 'lanzu_coupon.id', '=', 'lanzu_coupon_receive.coupon_id') ->where([ ['lanzu_coupon_receive.user_id' ,'=', $userId], - ['lanzu_coupon.usable_end_time' ,'>', time()], - ['lanzu_coupon_receive.number_remain' ,'>', 0] ]); - $builder = $builder->whereIn('lanzu_coupon_receive.status',[0,1]) - ->select( - 'lanzu_coupon.title', - 'lanzu_coupon.discounts', - 'lanzu_coupon.full_amount', - 'lanzu_coupon.discount_type', - 'lanzu_coupon.introduce', - 'lanzu_coupon.usable_end_time', - 'lanzu_coupon_receive.number', - 'lanzu_coupon_receive.number_remain' - ) - ->orderBy('lanzu_coupon.weigh','desc'); - $paginate = $builder->paginate($pagesize); - $couponList = $paginate->toArray(); - foreach ($couponList['data'] as $key => &$coupon) { - //拼接满减文字提示 - $coupon['full_amount_text'] = '满' . $coupon['full_amount'] . "可用"; - //判断是折扣优惠券还是满减优惠券 - if($coupon['discount_type'] == 1){ - $coupon['discounts_text'] = '¥'.$coupon['discounts']; - }elseif($coupon['discount_type'] == 2){ - $coupon['discounts_text'] = floatval($coupon['discounts'])."折"; - } + /** + * $type unused 未使用 used 已使用 expired 已失效 + */ + switch ($type){ + case 'unused': + $builder = $builder->where([ + ['lanzu_coupon.usable_end_time' ,'>', time()], + ['lanzu_coupon_receive.number_remain' ,'>', 0] + ]) + ->whereIn('lanzu_coupon_receive.status',[0,1]); + break; + case 'used': + $builder = $builder->whereIn('lanzu_coupon_receive.status',[1,2]); + break; + case 'expired': + $builder = $builder->where(function ($query) { + $query->where('lanzu_coupon.usable_end_time', '<', time()) + ->orWhere('lanzu_coupon.status', '<>', 1); + }); + break; } - return ['has_more_pages' => $paginate->hasMorePages(), 'coupon_list' => $couponList['data']]; - } - - /** - * 用户已使用 - */ - public function getUsedListByUser($userId,$page = 1,$pagesize = 5) - { - //查询已使用优惠券 - $builder = CouponRec::query()->join('lanzu_coupon', 'lanzu_coupon.id', '=', 'lanzu_coupon_receive.coupon_id') - ->where('lanzu_coupon_receive.user_id' ,$userId) - ->whereIn('lanzu_coupon_receive.status',[1,2]) - ->select( - 'lanzu_coupon.title', - 'lanzu_coupon.discounts', - 'lanzu_coupon.full_amount', - 'lanzu_coupon.discount_type', - 'lanzu_coupon.introduce', - 'lanzu_coupon.usable_end_time', - 'lanzu_coupon_receive.number', - 'lanzu_coupon_receive.number_remain' - ) - ->orderBy('lanzu_coupon_receive.updated_at','desc'); - $paginate = $builder->paginate($pagesize); - $couponList = $paginate->toArray(); - foreach ($couponList['data'] as $key => &$coupon) { - //拼接满减文字提示 - $coupon['full_amount_text'] = '满' . $coupon['full_amount'] . "可用"; - //判断是折扣优惠券还是满减优惠券 - if($coupon['discount_type'] == 1){ - $coupon['discounts_text'] = '¥'.$coupon['discounts']; - }elseif($coupon['discount_type'] == 2){ - $coupon['discounts_text'] = floatval($coupon['discounts'])."折"; - } - } - return ['has_more_pages' => $paginate->hasMorePages(), 'coupon_list' => $couponList['data']]; - } - - /** - * 用户已失效 - */ - public function getExpiredListByUser($userId,$page = 1,$pagesize = 5) - { - //查询失效优惠券 - $builder = CouponRec::query()->join('lanzu_coupon', 'lanzu_coupon.id', '=', 'lanzu_coupon_receive.coupon_id') - ->where('lanzu_coupon_receive.user_id',$userId) - ->where(function ($query) { - $query->where('lanzu_coupon.usable_end_time', '<', time()) - ->orWhere('lanzu_coupon.status', '<>', 1); - }) - ->select( + $builder = $builder->select( 'lanzu_coupon.title', 'lanzu_coupon.discounts', 'lanzu_coupon.full_amount', 'lanzu_coupon.discount_type', 'lanzu_coupon.introduce', + 'lanzu_coupon.usable_start_time', 'lanzu_coupon.usable_end_time', 'lanzu_coupon_receive.number', 'lanzu_coupon_receive.number_remain' - ) - ->orderBy('lanzu_coupon.weigh','desc'); + ) + ->orderBy('lanzu_coupon.weigh','desc'); $paginate = $builder->paginate($pagesize); $couponList = $paginate->toArray(); foreach ($couponList['data'] as $key => &$coupon) { @@ -185,6 +131,8 @@ class CouponRecService implements CouponRecServiceInterface }elseif($coupon['discount_type'] == 2){ $coupon['discounts_text'] = floatval($coupon['discounts'])."折"; } + //拼接时间文字提示 + $coupon['time_text'] = date("Y-m-d H:i:s",$coupon['usable_start_time']). ' - ' .date("Y-m-d H:i:s",$coupon['usable_end_time']); } return ['has_more_pages' => $paginate->hasMorePages(), 'coupon_list' => $couponList['data']]; } diff --git a/app/Service/v3/Implementations/UserCenterBlockService.php b/app/Service/v3/Implementations/UserCenterBlockService.php index f3944d8..f7cf039 100644 --- a/app/Service/v3/Implementations/UserCenterBlockService.php +++ b/app/Service/v3/Implementations/UserCenterBlockService.php @@ -24,15 +24,27 @@ class UserCenterBlockService implements UserCenterBlockServiceInterface public function all() { + + // + $img_host = config('alioss.img_host').'/'; + return [ [ 'type' => 'user', 'title' => '我的', 'items' => [ - ['name' => '收货地址', 'icon' => '', 'type' => 'page', 'path' => ''], - ['name' => '商家入口', 'icon' => '', 'type' => 'page', 'path' => ''], - ['name' => '在线客服', 'icon' => '', 'type' => 'page', 'path' => ''], - ['name' => '当面付订单查询', 'icon' => '', 'type' => 'page', 'path' => ''], + ['name' => '收货地址', 'icon' => $img_host . 'user_icons/user_addr.png', 'type' => 'page', 'path' => '/pages/address/userAddress/userAddress','command'=>'user_addr'], + ['name' => '当面付订单查询', 'icon' => $img_host . 'user_icons/offline_orders.png', 'type' => 'page', 'path' => '/pages/faceOrderList/faceOrderList','command'=>'offline_orders'], + ['name' => '在线客服', 'icon' => $img_host . 'user_icons/online_kf.png', 'type' => 'page', 'path' => '','command'=>'online_kf'], + ['name' => '联系服务站', 'icon' => $img_host . 'user_icons/contact_fwz.png', 'type' => 'page', 'path' => '/pages/contactMarket/contactMarket','command'=>'contact_fwz'], + ['name' => '关于懒族', 'icon' => $img_host . 'user_icons/about_lz.png', 'type' => 'page', 'path' => '/pages/aboutUs/aboutUs','command'=>'about'], + ] + ], + [ + 'type' => 'store_user', + 'title' => '我的', + 'items' => [ + ['name' => '商家入口', 'icon' => $img_host . 'user_icons/shop_enter.png', 'type' => 'page', 'path' => '/pages/shopLogin/shopLogin','command'=>'store_login'] ] ] ]; diff --git a/app/Service/v3/Interfaces/CouponRecServiceInterface.php b/app/Service/v3/Interfaces/CouponRecServiceInterface.php index c0e5743..34ebfaa 100644 --- a/app/Service/v3/Interfaces/CouponRecServiceInterface.php +++ b/app/Service/v3/Interfaces/CouponRecServiceInterface.php @@ -8,7 +8,5 @@ interface CouponRecServiceInterface public function check(); public function undo(); public function allForOrderOlAvailable($totalAmount,$userId,$marketId,$type,$storeTypeId); - public function getUnusedListByUser($userId,$page = 1,$pagesize = 5); - public function getUsedListByUser($userId,$page = 1,$pagesize = 5); - public function getExpiredListByUser($userId,$page = 1,$pagesize = 5); + public function getListByUser($userId,$type,$page = 1,$pagesize = 5); } \ No newline at end of file