|
|
|
|
|
|
|
|
public function processLinkPointSale(User $modelUser) |
|
|
public function processLinkPointSale(User $modelUser) |
|
|
{ |
|
|
{ |
|
|
$posts = Yii::$app->request->post(); |
|
|
$posts = Yii::$app->request->post(); |
|
|
|
|
|
$userPointSaleManager = $this->getUserPointSaleManager(); |
|
|
|
|
|
$pointSaleManager = $this->getPointSaleManager(); |
|
|
|
|
|
|
|
|
UserPointSale::deleteAll([ |
|
|
UserPointSale::deleteAll([ |
|
|
'id_user' => $modelUser->id |
|
|
'id_user' => $modelUser->id |
|
|
]); |
|
|
]); |
|
|
if (is_array($modelUser->points_sale) && count($modelUser->points_sale) > 0) { |
|
|
if (is_array($modelUser->points_sale) && count($modelUser->points_sale) > 0) { |
|
|
foreach ($modelUser->points_sale as $pointSaleId) { |
|
|
foreach ($modelUser->points_sale as $pointSaleId) { |
|
|
$userPointSale = UserPointSale::searchOne([ |
|
|
|
|
|
'id_user' => $modelUser->id, |
|
|
|
|
|
'id_point_sale' => $pointSaleId |
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
$pointSale = $pointSaleManager->findOnePointSaleById($pointSaleId); |
|
|
|
|
|
$userPointSale = $userPointSaleManager->findOneUserPointSale($modelUser, $pointSale); |
|
|
|
|
|
|
|
|
if (!$userPointSale) { |
|
|
if (!$userPointSale) { |
|
|
$userPointSale = new UserPointSale; |
|
|
$userPointSale = new UserPointSale; |
|
|
$userPointSale->id_user = $modelUser->id; |
|
|
$userPointSale->id_user = $modelUser->id; |