From: Aleksey Filippov Date: Wed, 14 May 2025 09:12:29 +0000 (+0300) Subject: отладка начисления бонусов за прохождение опроса X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=a5d3a46d778877f88d3e77f6858c65660f9fea90;p=erp24_rep%2Fyii-erp24%2F.git отладка начисления бонусов за прохождение опроса --- diff --git a/erp24/api2/controllers/BonusController.php b/erp24/api2/controllers/BonusController.php index 6acd83a3..d993d9b0 100644 --- a/erp24/api2/controllers/BonusController.php +++ b/erp24/api2/controllers/BonusController.php @@ -1662,57 +1662,57 @@ class BonusController extends BaseController try { $result = Json::decode($request); - file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . implode(',', __LINE__)); + file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . ',' . __LINE__); } catch (\Exception $ex) { return $this->asJson(['error' => ['code' => 400, 'message' => 'Json body invalid']]); - file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . implode(',', __LINE__)); + file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . ',' . __LINE__); } $__API_PARAMS = ['phone', 'description', 'tip_sale', 'bonus', 'date_end']; foreach ($__API_PARAMS as $paramName) { if (!isset($result[$paramName])) { - file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . implode(',', __LINE__)); + file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . ',' . __LINE__); if ($paramName != 'phone') { - file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . implode(',', __LINE__)); + file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . ',' . __LINE__); LogService::apiErrorLog(json_encode(["error_id" => 1, "error" => "$paramName is required"], JSON_UNESCAPED_UNICODE)); } - file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . implode(',', __LINE__)); + file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . ',' . __LINE__); return $this->asJson(["error_id" => 1, "error" => "$paramName is required"]); } } - file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . implode(',', __LINE__)); + file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . ',' . __LINE__); // if (!in_array($result['tip_sale'], ['podarok', 'senat', 'nino802', 'sale', '14feb', '23feb', '8mar', 'quest001'])) { - file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . implode(',', __LINE__)); + file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . ',' . __LINE__); return $this->asJson(["error_id" => 1.1, "error" => "tip_sale не разрешён (podarok, senat, nino802)"]); } $phone = ClientHelper::phoneClear($result['phone']); - file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . implode(',', __LINE__)); + file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . ',' . __LINE__); if (!ClientHelper::phoneVerify($phone)) { - file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . implode(',', __LINE__)); + file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . ',' . __LINE__); return $this->asJson(["error_id" => 1.2, "error" => "phone is required"]); } $result['phone'] = $phone; $stop = UsersStopList::find()->select(['phone'])->where(['phone' => $result['phone']])->one(); - file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . implode(',', __LINE__)); + file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . ',' . __LINE__); if ($stop) { - file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . implode(',', __LINE__)); + file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . ',' . __LINE__); return $this->asJson(["error_id" => 4, "error" => 'Номер телефона числится в стоп листе']); } $bonus = min((int)$result['bonus'], 1000); - file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . implode(',', __LINE__)); + file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . ',' . __LINE__); $found = UsersBonus::find()->where(['phone' => $phone])->andWhere(['>=', 'date_start', date('Y-m-d H:i:s', time() - self::$YEAR_PERIOD * 86400)]) ->andWhere(['tip_sale' => $result['tip_sale']])->andWhere(['tip' => 'plus'])->andWhere(['bonus' => $bonus])->one(); - file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . implode(',', __LINE__)); + file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . ',' . __LINE__); if ($found) { - file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . implode(',', __LINE__)); + file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . ',' . __LINE__); return $this->asJson(["error_id" => 3, "error" => 'Бонусы уже начисляли']); } - file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . implode(',', __LINE__)); + file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . ',' . __LINE__); $userBonus = new UsersBonus; $userBonus->phone = $phone; $userBonus->name = $result['description']; @@ -1725,13 +1725,13 @@ class BonusController extends BaseController $userBonus->date_start = $result['date_start'] ?? $userBonus->date; $userBonus->date_end = $result['date_end']; $userBonus->save(); - file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . implode(',', __LINE__)); + file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . ',' . __LINE__); if ($userBonus->getErrors()) { - file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . implode(',', __LINE__)); + file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . ',' . __LINE__); LogService::apiErrorLog(json_encode(["error_id" => 2, "error" => $userBonus->getErrors()], JSON_UNESCAPED_UNICODE)); return $this->asJson(["error_id" => 2, "error" => $userBonus->getErrors()]); } - file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . implode(',', __LINE__)); + file_put_contents(self::OUT_DIR . '/add_bonuses_' . $fl . '_log.json', PHP_EOL . ',' . __LINE__); return $this->asJson(['response' => true]); } }