From: Alexander Smirnov Date: Fri, 4 Oct 2024 11:42:45 +0000 (+0300) Subject: [ERP-207] Добавлен phone в create_checks из orders_amo X-Git-Tag: 1.6~50^2~1 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=790ef708e0248cd6a5758c1bae8fe73fc0519c1a;p=erp24_rep%2Fyii-erp24%2F.git [ERP-207] Добавлен phone в create_checks из orders_amo --- diff --git a/erp24/api2/controllers/DataController.php b/erp24/api2/controllers/DataController.php index 75935bca..708d2d33 100644 --- a/erp24/api2/controllers/DataController.php +++ b/erp24/api2/controllers/DataController.php @@ -88,8 +88,10 @@ class DataController extends BaseController { // $createChecks = CreateChecks::find()->where(['status' => '0'])->andWhere(['>', 'date', date('Y-m-d H:i:s', time() - 3 * 86400)]) ->orderBy(['date' => SORT_DESC])->limit(10)->all(); foreach ($createChecks as $createCheck) { + /** @var $createCheck CreateChecks */ if (!empty($createCheck->kkm_id)) { $mess["create_checks"][] = [ + "phone" => $createCheck->phone, "kkm_id" => $createCheck->kkm_id, "store_id" => $createCheck->store_id, "seller_id" => $createCheck->seller_id, diff --git a/erp24/inc/checks.php b/erp24/inc/checks.php index 94975215..84c67194 100644 --- a/erp24/inc/checks.php +++ b/erp24/inc/checks.php @@ -371,8 +371,8 @@ $payments2[]=$pays_arr; $payments2 = json_encode($payments2, JSON_UNESCAPED_UNICODE); $items2 = json_encode($items2, JSON_UNESCAPED_UNICODE); try{ -$db::sql("INSERT IGNORE INTO create_checks (date,kkm_id,seller_id, store_id, type, order_id,items,payments) VALUES (NOW(),?,?,?,?,?,?,?)", -[$kkm_id, $seller_id ,$store_id, "Продажа", $lid_id, $items2, $payments2 ]); +$db::sql("INSERT IGNORE INTO create_checks (date,kkm_id,seller_id, store_id, type, order_id,items,payments,phone) VALUES (NOW(),?,?,?,?,?,?,?,?)", +[$kkm_id, $seller_id ,$store_id, "Продажа", $lid_id, $items2, $payments2, $row['phone'] ]); } catch (Exception $e0) { echo 'Выброшено исключение: ', $e0->getMessage(), "\n"; @@ -429,11 +429,12 @@ if(empty($error)) { $param["check_id"]=create_guid_my("11","$id"); $param["sales_check"]=$data["check_id"]; $param["items"]=$data["items"]; - $param["payments"]=$data["payments"]; + $param["payments"]=$data["payments"]; + $param["phone"]=$data["phone"]; if(!empty($param["sales_check"])) { - $sql="INSERT INTO create_checks (`date`,`status`,type,kkm_id,seller_id,store_id,order_id, check_id,sales_check,items, payments) - VALUES (NOW(), '0', 'Возврат',:kkm_id,:seller_id,:store_id,:order_id,:check_id,:sales_check,:items,:payments)"; + $sql="INSERT INTO create_checks (`date`,`status`,type,kkm_id,seller_id,store_id,order_id, check_id,sales_check,items, payments,phone) + VALUES (NOW(), '0', 'Возврат',:kkm_id,:seller_id,:store_id,:order_id,:check_id,:sales_check,:items,:payments,:phone)"; echo $sql; $db::sql($sql,$param); @@ -580,7 +581,7 @@ elseif(empty($empty_guid)) { if(!empty($_POST["create_check"]) and $_POST["create_check"]==2) { $check_id=create_guid_my("01","$lid_id"); -$db::sql("INSERT IGNORE INTO create_checks (check_id,date,kkm_id,seller_id, store_id, type, order_id,items,payments) VALUES (?,NOW(),?,?,?,?,?,?,?)",[$check_id,$kkm_id, $seller_id ,$store_id, "Продажа", $lid_id, $items2, $payments2 ]); +$db::sql("INSERT IGNORE INTO create_checks (check_id,date,kkm_id,seller_id, store_id, type, order_id,items,payments,phone) VALUES (?,NOW(),?,?,?,?,?,?,?,?)",[$check_id,$kkm_id, $seller_id ,$store_id, "Продажа", $lid_id, $items2, $payments2, $row['phone'] ]); //$db::sql("INSERT IGNORE INTO create_checks2 (check_id,date,kkm_id,seller_id, store_id, type, order_id,items,payments) VALUES (?,NOW(),?,?,?,?,?,?,?)",[$check_id,$kkm_id, $seller_id ,$store_id, "Продажа", $lid_id, $items2, $payments2 ]); //$db2::sql("INSERT IGNORE INTO create_checks (check_id,date,kkm_id,seller_id, store_id, type, order_id,items,payments) VALUES (?,NOW(),?,?,?,?,?,?,?)",[$check_id,$kkm_id, $seller_id ,$store_id, "Продажа", $lid_id, $items2, $payments2 ]); mess("Чек добавлен Сумма чека $summ "); diff --git a/erp24/migrations/m241004_112411_add_column_phone_to_table_create_checks.php b/erp24/migrations/m241004_112411_add_column_phone_to_table_create_checks.php new file mode 100755 index 00000000..ddef693f --- /dev/null +++ b/erp24/migrations/m241004_112411_add_column_phone_to_table_create_checks.php @@ -0,0 +1,27 @@ +addColumn(self::TABLE_NAME, 'phone', + $this->string(20)->null()->after('comments')->comment('Телефон клиента')); + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + $this->dropColumn(self::TABLE_NAME, 'phone'); + } +} diff --git a/erp24/records/CreateChecks.php b/erp24/records/CreateChecks.php index 37f45874..473b0149 100644 --- a/erp24/records/CreateChecks.php +++ b/erp24/records/CreateChecks.php @@ -3,6 +3,7 @@ namespace yii_app\records; use Yii; +use yii_app\api3\core\validators\PhoneValidator; /** * This is the model class for table "create_checks". @@ -25,6 +26,7 @@ use Yii; * @property string|null $delivery_date Дата доставки * @property string|null $date_up дата обновления из 1с * @property string $comments комментарий к чеку- номер телефона клиента + * @property string|null $phone Телефон клиента */ class CreateChecks extends \yii\db\ActiveRecord { @@ -44,10 +46,12 @@ class CreateChecks extends \yii\db\ActiveRecord return [ [['kkm_id', 'store_id', 'order_id', 'check_id', 'guid', 'name', 'sales_check', 'items', 'payments', 'held', 'date', 'comments'], 'required'], [['order_id', 'held', 'status'], 'integer'], - [['type', 'items', 'payments'], 'string'], - [['date', 'delivery_date', 'date_up'], 'safe'], + [['type', 'items', 'payments', 'phone'], 'string'], + [['date', 'delivery_date', 'date_up', 'phone'], 'safe'], [['kkm_id', 'seller_id', 'store_id', 'check_id', 'guid', 'sales_check'], 'string', 'max' => 36], [['name', 'comments'], 'string', 'max' => 255], + [['phone'], 'string', 'max' => 20], + ['phone', PhoneValidator::class], [['order_id', 'check_id', 'type', 'date'], 'unique', 'targetAttribute' => ['order_id', 'check_id', 'type', 'date']], ]; }