You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
<?php
namespace App\Service;
use App\Model\Order;use App\Model\OrderMain;use App\Model\Users;
class UserService implements UserServiceInterface{
/** * 是否平台新用户 * 在很多奖励的地方会需要用到这个查询 * 判定条件: * 没有在平台下过单(包括线上和线下) * @param $user_id * @return mixed|void */ public function isStageNewUser($user_id): bool { $exist = OrderMain::query() ->where(['user_id' => $user_id]) ->where(function ($query){ $query->where('state', 'in', [4,5,10]) ->orWhere('dm_state', 'in', [2,3]); }) ->exists();
return !$exist; } /** * 根据用户的openid更新unionid信息 * 如果没有找到用户,则不做任何处理 * @param $openid * @param $unionid * @return array */ public function saveUserUnionid($openid,$unionid) { $result = [ 'status' => false, 'msg' => '用户不存在或者已存在相同unionid' ];
// 查询用户是否存在
$userinfo = Users::select('id','unionid')->where('openid',$openid)->first(); if($userinfo && $userinfo->unionid != $unionid){ $userinfo->unionid = $unionid; if($res = $userinfo->save()){ $result['status'] = true; $result['msg'] = '更改用户unionid信息成功'; $result['res'] = $res; }else{ $result['msg'] = '更改用户unionid信息失败'; } }
return $result; }
/** * @inheritDoc */ public function isStoreFirstOrderToday($user_id, $store_id, $current_order_id, $limit_amount = 3) { return !Order::query() ->where(['user_id' => $user_id, 'store_id' => $store_id, 'dm_state' => 2]) ->where('time_add', '>=', date('Y-m-d 00:00:00')) ->where('time_add', '<=', date('Y-m-d 23:59:59')) ->where('money', '>=', $limit_amount) ->where('id', '!=', $current_order_id) ->exists(); }}
|