瀏覽代碼

广州电信

zealerChina 1 年之前
父節點
當前提交
cae9577395

+ 54 - 9
application/admin/controller/Produce.php

@@ -3,6 +3,8 @@
 namespace app\admin\controller;
 
 use app\common\controller\Backend;
+use app\common\model\ProduceGzdx;
+use app\common\service\ProduceOrderService;
 
 /**
  * 产品信息管理
@@ -18,11 +20,11 @@ class Produce extends Backend
      */
     protected $model = null;
 
-    protected $operatorData = [
-        'cucc' => '联通',
-        'cmcc' => '移动',
-        'ctcc' => '电信',
-    ];
+    // protected $operatorData = [
+    //     'cucc' => '联通',
+    //     'cmcc' => '移动',
+    //     'ctcc' => '电信',
+    // ];
 
     protected $homeLocationType = [
         'address' => '根据收货地址自动选择(该选项无需单独填写号码归属地)',
@@ -39,7 +41,8 @@ class Produce extends Backend
     {
         parent::_initialize();
         $this->model = new \app\common\model\Produce;
-        $this->assign('operatorData', $this->operatorData);
+
+        $this->assign('operatorData', ProduceOrderService::PRODUCE_TYPE);
         $this->assign('homeLocationType', $this->homeLocationType);
         $this->assign('numSelectType', $this->numSelectType);
     }
@@ -74,9 +77,10 @@ class Produce extends Backend
                 ->order($sort, $order)
                 ->paginate($limit);
 
-            foreach ($list as $row) {
-                $row->operator_name = $this->operatorData[$row->operator] ?? '未知';
-            }
+            // $operatorData = ProduceOrderService::PRODUCE_TYPE;
+            // foreach ($list as $row) {
+            //     $row->operator_name = $operatorData[$row->operator] ?? '未知';
+            // }
 
             $result = array("total" => $list->total(), "rows" => $list->items());
 
@@ -84,5 +88,46 @@ class Produce extends Backend
         }
         return $this->view->fetch();
     }
+    
+    /**
+     * 查看
+     */
+    public function select_index()
+    {
+        //设置过滤方法
+        $produceType = $this->request->request('produce_type');
+        $model = $this->model;
+        $field = '';
+        if ($produceType == 'cucc') {
+            $model = $this->model;
+            $field = 'id as value, local_code as name';
+        } else if ($produceType == 'gz_ctcc') {
+            $model = new ProduceGzdx();
+            $field = 'id as value, upstream_no as name';
+        }
+
+        $list = $model->field($field)->select();
+
+        return $this->success('', '', $list);
+    }
+
+    /**
+     * 产品类型
+     *
+     * @return void
+     */
+    public function produce_type()
+    {
+        $operatorData = ProduceOrderService::PRODUCE_TYPE;
+        $result = [];
+        foreach ($operatorData as $key => $value) {
+            $result[] = [
+                'value' => $key,
+                'name' => $value,
+            ];
+        }
+        
+        return $this->success('', '', $result);
+    }
 
 }

+ 7 - 1
application/admin/controller/Produceorder.php

@@ -620,7 +620,9 @@ class Produceorder extends Backend
                     }
 
                     // $params['city'] = implode('/', Area::getTreeId($params['city']));
-                    $params['city'] = implode(',',Area::getTreeId(explode('/',$params['city'])[2]));
+                    if (!empty($params['city'])) {
+                        $params['city'] = implode(',',Area::getTreeId(explode('/',$params['city'])[2]));
+                    }
                     $params['status'] = 10;
                     $params['pay_time'] = strtotime($params['pay_time']);
                     $params['create_time'] = time();
@@ -824,6 +826,7 @@ class Produceorder extends Backend
         }else{
             $data=input('row/a');
             $order->produce_id = $data['produce_id'] ?? 0;
+            $order->produce_type = $data['produce_type'] ?? '';
             $order->remark = $data['remark'] ?? '';
             $order->flag = $data['flag'] ?? '';
             $order->save();
@@ -1065,6 +1068,9 @@ class Produceorder extends Backend
             if(!empty($tempData['produce_id'])){
                 $data['produce_id']=$tempData['produce_id'];
             }
+            if(!empty($tempData['produce_type'])){
+                $data['produce_type']=$tempData['produce_type'];
+            }
             if(!empty($tempData['remark'])){
                 $data['remark']=$tempData['remark'];
             }

+ 10 - 1
application/admin/view/produceorder/add.html

@@ -13,12 +13,21 @@
     <!--    </div>-->
     <!--</div>-->
     
-    <div class="form-group">
+    <!-- <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('产品ID')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-produce_id" min="0" data-rule="required" data-source="produce/index" class="form-control selectpage" name="row[produce_id]" type="text" value="" data-field="local_code" >
        </div>
     </div>
+     -->
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('产品')}:</label>
+        <div class="form-inline col-xs-12 col-sm-8" data-toggle="cxselect" data-selects="produce_type,produce_id">
+            <select class="produce_type form-control" name="row[produce_type]" data-url="produce/produce_type"></select>
+            <select class="produce_id form-control" name="row[produce_id]" data-url="produce/select_index" data-query-name="produce_type"></select>
+        </div>
+    </div>
+
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('下单号码')}:</label>
         <div class="col-xs-12 col-sm-8">

+ 8 - 1
application/admin/view/produceorder/multi_edit.html

@@ -1,9 +1,16 @@
 <form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
-    <div class="form-group">
+    <!-- <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('产品ID')}:</label>
         <div class="col-xs-12 col-sm-8">
             <input id="c-produce_id" min="0" data-source="produce/index" class="form-control selectpage" name="row[produce_id]" type="text" value="" data-field="local_code">
         </div>
+    </div> -->
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('产品')}:</label>
+        <div class="form-inline col-xs-12 col-sm-8" data-toggle="cxselect" data-selects="produce_type,produce_id">
+            <select class="produce_type form-control" name="row[produce_type]" data-url="produce/produce_type"></select>
+            <select class="produce_id form-control" name="row[produce_id]" data-url="produce/select_index" data-query-name="produce_type"></select>
+        </div>
     </div>
 
 

+ 8 - 1
application/admin/view/produceorder/sub_remark.html

@@ -1,9 +1,16 @@
 <form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="" disable-refresh="1">
-    <div class="form-group">
+    <!-- <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('产品ID')}:</label>
         <div class="col-xs-12 col-sm-8">
             <input id="c-produce_id" min="0" data-source="produce/index" class="form-control selectpage" name="row[produce_id]" type="text" value="{$row.produce_id|htmlentities}" data-field="local_code">
         </div>
+    </div> -->
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('产品')}:</label>
+        <div class="form-inline col-xs-12 col-sm-8" data-toggle="cxselect" data-selects="produce_type,produce_id">
+            <select class="produce_type form-control" name="row[produce_type]" data-url="produce/produce_type"></select>
+            <select class="produce_id form-control" name="row[produce_id]" data-url="produce/select_index" data-query-name="produce_type"></select>
+        </div>
     </div>
 
 

+ 4 - 0
application/api/controller/MobileController.php

@@ -30,6 +30,7 @@ use app\service\id\IdVerify;
 use think\App;
 use think\Db;
 use think\db\Query;
+use think\Log;
 
 /**
  * 靓号管理
@@ -362,6 +363,9 @@ class MobileController extends UserApi
 
         if(!empty($data['sort'])){
             if($data['sort']=='price_asc'){
+                if (!isset($data['price_min']) || !is_numeric($data['price_min'])) {
+                    $query['query']['bool']['should'][0]['bool']['must'][]['range']['total']['gte']=3;
+                }
                 $query['sort']['total']['order']='asc';
             }elseif($data['sort']=='price_desc'){
                 $query['sort']['total']['order']='desc';

+ 21 - 5
application/common/model/MobileOrder.php

@@ -6,6 +6,7 @@ use app\admin\model\Mobile;
 use app\admin\model\Admin;
 use app\admin\model\MobileOrderAdmin;
 use app\common\library\MobileConstant;
+use app\common\service\ProduceOrderService;
 use app\common\service\Refund;
 use app\common\service\SmsSend;
 use app\service\byte_dance\ByteDanceOrderPush;
@@ -139,11 +140,6 @@ class MobileOrder extends Model
         unset($columns['password']);
         return $this->belongsTo(Admin::class)->field($columns);
     }
-    // 和产品信息多对一的关系
-    public function produce()
-    {
-        return $this->belongsTo(Produce::class, 'produce_id', 'id');
-    }
 
     public function getAddressAttr($a,$b){
         return Area::getNameString($b['city']).$a;
@@ -485,4 +481,24 @@ class MobileOrder extends Model
         }
         return $status[$this['status']];
     }
+    // // 和产品信息多对一的关系
+    // public function produce()
+    // {
+    //     return $this->belongsTo(Produce::class, 'produce_id', 'id');
+    // }
+
+    /**
+     * 和产品多态的关系
+     *
+     * @return void
+     */
+    public function produce()
+    {
+        $models = ProduceOrderService::PRODUCE_TYPE_MODEL;
+
+        return $this->morphTo([
+            'produce_type',
+            'produce_id'
+        ], $models);
+    }
 }

+ 20 - 0
application/common/service/GzdxCtccService.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace app\common\service;
+
+/**
+ * 广州电信服务类
+ */
+class GzdxCtccService
+{
+    /**
+     * 生成签名
+     *
+     * @param array $params
+     * @return void
+     */
+    public static function sign($params = [])
+    {
+
+    }
+}

+ 11 - 0
application/common/service/ProduceOrderService.php

@@ -5,6 +5,7 @@ namespace app\common\service;
 use app\admin\model\Area;
 use app\common\model\MobileOrder;
 use app\common\model\Produce;
+use app\common\model\ProduceGzdx;
 use app\common\model\ProduceOrderUpload;
 use Exception;
 use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
@@ -19,6 +20,16 @@ use think\Db;
  */
 class ProduceOrderService
 {
+    const PRODUCE_TYPE = [
+        'cucc' => '联通',
+        'gz_ctcc' => '广州电信',
+    ];
+
+    const PRODUCE_TYPE_MODEL = [
+        'cucc' => Produce::class,
+        'gz_ctcc' => ProduceGzdx::class,
+    ];
+
     /**
      * 保存上传文件
      *

+ 18 - 2
application/common/service/ZopOrderService.php

@@ -5,6 +5,7 @@ namespace app\common\service;
 use app\common\model\Area;
 use app\common\model\MobileOrder;
 use app\common\model\Produce;
+use app\common\model\ProduceGzdx;
 
 /**
  * 联通商城zop订单统一接入文档
@@ -43,9 +44,10 @@ class ZopOrderService extends ZopBaseService
         }
 
         // 根据商品类型, 调用不同的推送方法
-        $operator = $produce->operator ?? '';
+        // $operator = $produce->operator ?? '';
+        $produceType = $order->produce_type ?? '';
         $result = [];
-        switch ($operator) {
+        switch ($produceType) {
             case 'cucc':
                 $result = self::cuccPush($order, $produce);
                 break;
@@ -53,6 +55,8 @@ class ZopOrderService extends ZopBaseService
                 break;
             case 'ctcc':
                 break;
+            case 'gz_ctcc':
+                $result = self::gzCtccPush($order, $produce);
             default:
                 $result = self::error('运营商类型错误');
         }
@@ -61,6 +65,18 @@ class ZopOrderService extends ZopBaseService
     }
 
     /**
+     * 广州电信推送
+     *
+     * @param MobileOrder $order
+     * @param ProduceGzdx $produce
+     * @return void
+     */
+    public static function gzCtccPush(MobileOrder $order, ProduceGzdx $produce)
+    {
+        
+    }
+
+    /**
      * 联通推送
      *
      * @param MobileOrder $order