]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-207] Добавлен phone в create_checks из orders_amo
authorAlexander Smirnov <fredeom@mail.ru>
Fri, 4 Oct 2024 11:42:45 +0000 (14:42 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Fri, 4 Oct 2024 11:42:45 +0000 (14:42 +0300)
erp24/api2/controllers/DataController.php
erp24/inc/checks.php
erp24/migrations/m241004_112411_add_column_phone_to_table_create_checks.php [new file with mode: 0755]
erp24/records/CreateChecks.php

index 75935bca94209091e4512a69ea95fcf7db412be8..708d2d332eddb6f81e27c02e77025b51191743d5 100644 (file)
@@ -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,
index 94975215b0860dd920fb296fa0862db2ed2b9342..84c67194d628866887112d3b8fcdb93062012b9e 100644 (file)
@@ -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 (executable)
index 0000000..ddef693
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Class m241004_112411_add_column_phone_to_table_create_checks
+ */
+class m241004_112411_add_column_phone_to_table_create_checks extends Migration
+{
+    const TABLE_NAME = "erp24.create_checks";
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    {
+        $this->addColumn(self::TABLE_NAME, 'phone',
+            $this->string(20)->null()->after('comments')->comment('Телефон клиента'));
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeDown()
+    {
+        $this->dropColumn(self::TABLE_NAME, 'phone');
+    }
+}
index 37f45874502f72fded7112b8999b347afb469115..473b014945238016994bc5bfca7fc36ff976aaa5 100644 (file)
@@ -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']],
         ];
     }