Browse Source

Merge branch 'master' of http://git.huaml.com/zhh/huahuibao

shish 5 years ago
parent
commit
5eeb048c5e
2 changed files with 191 additions and 10 deletions
  1. 179 1
      app/ghs/controllers/TestController.php
  2. 12 9
      app/ghs/views/main/index.php

+ 179 - 1
app/ghs/controllers/TestController.php

@@ -6,7 +6,10 @@ use bizTy\sj\services\MerchantService;
 use biz\message\classes\InformAdminClass;
 use biz\message\services\InformAdminService;
 use biz\order\services\OrderService;
+use biz\wx\classes\WxOpenClass;
+use bizGhs\express\services\MiniExpressService;
 use bizGhs\product\classes\ProductClass;
+use common\components\miniUtil;
 use common\components\wxUtil;
 use Yii;
 use common\components\util;
@@ -16,11 +19,186 @@ class TestController extends BaseController
 
 	public $withoutLoginAction = ['inform', 'notice','order-query','add-order'];
 
-	public function actionIndex()
+
+
+    //获取已支持的配送公司列表接口
+    public function actionGetAllDelivery()
+    {
+        $data = MiniExpressService::getAllImmeDelivery();
+        util::success($data);
+    }
+
+    //即时配送
+    /*
+     * Array
+(
+    [resultcode] => 0
+    [resultmsg] => OK
+    [shop_list] => Array
+        (
+            [0] => Array
+                (
+                    [shopid] => 1588714266
+                    [delivery_id] => SFTC
+                    [audit_result] => 0
+                    [create_time] => 1612172838
+                    [remark] =>
+                    [delivery_name] => 顺丰同城急送
+                )
+
+        )
+)
+     */
+    public function actionGetBindAccount()
+    {
+        $merchant = WxOpenClass::getGhsWxInfo();
+        $isOpen = 2;
+        $r = miniUtil::getBindAccount($merchant, $isOpen);
+        dd($r);
+    }
+
+
+    //下单 (沙箱)
+    /**
+     * Array
+    (
+    [resultcode] => 0
+    [resultmsg] => ok
+    [fee] => 10
+    [waybill_id] => test_shop_id1612365974_waybillid
+    [order_status] => 101
+    [dispatch_duration] => 300
+    )
+     */
+    public function actionCreateWaybill()
+    {
+        $merchant = WxOpenClass::getGhsWxInfo();
+        $isOpen = 2;
+        $shopId = 'test_shop_id';
+        $shopOrderId = 'test_shop_id'.time();
+        $appSecret = 'test_app_secrect';
+        $data = [
+            'shopid'=>$shopId,
+            'shop_order_id'=>$shopOrderId,
+            'shop_no'=>'1',
+            'delivery_sign'=>miniUtil::getDeliverySign($shopId,$shopOrderId,$appSecret), //,则delivery_sign=SHA1(shopid + shop_order_id + AppSecret)
+            'delivery_id'=>"TEST",
+            'openid'=>'oGKMp45YLxewOTWEbpMFzWoVqdW0',
+            'sender'=>[
+                'name'=>'test',
+                'city'=>'厦门市',
+                'address'=>'思明区',
+                'address_detail'=>'软件园二期',
+                'phone'=>'19959271111',
+                'lng'=>118.134343,
+                'lat'=>24.483566,
+                'coordinate_type'=>0,
+            ],
+            'receiver'=>[
+                'name'=>'test',
+                'city'=>'厦门市',
+                'address'=>'思明区',
+                'address_detail'=>'软件园二期',
+                'phone'=>'19959271111',
+                'lng'=>118.134343,
+                'lat'=>24.493566,
+                'coordinate_type'=>0,
+            ],
+            'cargo'=>[
+                'goods_value'=>1,
+                'goods_weight'=>0.1,
+                'cargo_first_class'=>'鲜花',
+                'cargo_second_class'=>'鲜花',
+            ],
+            'order_info'=>[
+                'order_type'=>0,
+            ],
+            'shop'=>[
+                'wxa_path'=>'/shop',
+                'img_url'=>'http://www.baidu.com/test.png',
+                'goods_name'=>'test',
+                'goods_count'=>1,
+            ],
+
+        ];
+
+        $r = miniUtil::addOrder($data,$merchant, $isOpen);
+        dd($r);
+
+    }
+
+    //获取运单数据
+
+    /**
+     * Array
+    (
+    [resultcode] => 0
+    [resultmsg] => ok
+    [order_status] => 101
+    [agent_info] => Array
+    (
+    )
+
+    [waybill_id] => test_shop_id1612365974_waybillid
+    [rider_name] =>
+    [rider_phone] =>
+    [order_token] => NsXweKCKhSyAEIhAdnX3TYZsVDES0-t-tymHDONG0MpRsF31dQvVxiP_JJvLFaKS-kwXuOG3D0hzKkl7o-gzew
+    )
+     */
+    public function actionGetOrder()
+    {
+        $shopId = 'test_shop_id';
+        $shopOrderId ='test_shop_id1612365974';
+        $appSecret = 'test_app_secrect';
+        $merchant = WxOpenClass::getGhsWxInfo();
+        $isOpen = 2;
+        $data = [
+            'shopid'=>$shopId,
+            'shop_order_id'=>$shopOrderId,
+            'shop_no'=>'1',
+            'delivery_sign'=>MiniExpressService::getDeliverySign($shopId,$shopOrderId,$appSecret),
+        ];
+        $r = miniUtil::getOrder($data,$merchant, $isOpen);
+        dd($r);
+    }
+
+
+    //沙盒 更新快递状态
+    public function actionMockUpdateOrder()
+    {
+        $merchant = WxOpenClass::getGhsWxInfo();
+        $isOpen = 2;
+        /**
+         * {
+        "shopid": "test_shop_id",
+        "shop_order_id": "xxxxxxxxxxx",
+        "waybill_id": "xxxxxxxxxxxxx",
+        "action_time": 12345678,
+        "order_status": 101,
+        "action_msg": "",
+        }
+         */
+        $shopId = 'test_shop_id';
+        $shopOrderId ='test_shop_id1612365974';
+        $data = [
+            'shop_order_id'=>$shopOrderId,
+            "shopid"=>$shopId,
+            "action_time"=>time(),
+            "order_status"=>302,
+            'action_msg'=>'状态变更',
+        ];
+        $r = miniUtil::mockUpdateOrder($data,$merchant, $isOpen);
+        dd($r);
+    }
+
+    public function actionTest()
     {
 
+
     }
 
+
+
 	//新增订单
 	public function actionAddOrder()
 	{

+ 12 - 9
app/ghs/views/main/index.php

@@ -4,7 +4,12 @@
     var clientId;
     var ws;
     function openMsg() {
-        ws = new WebSocket("ws://<?= Yii::$app->params['host'] ?>:8282");
+        ws = new WebSocket("wss://api.ghs.huaml.com:8282");
+        ws.onopen = function(){
+            //当WebSocket创建成功时,触发onopen事件
+            console.log("open");
+        }
+
         //服务端主动推送消息时会触发这里
         ws.onmessage = function (e) {
             var data = eval("(" + e.data + ")");
@@ -13,18 +18,16 @@
                 case 'init':
                     clientId = data.client_id;
                     //当前发起的会话与平台绑定关系
-                    $.post('<?= Yii::$app->params['ghsHost'] ?>/chat/bind-console', {clientId: clientId}, function (data) {
+                    $.post('http://api.ghs.huaml.com/ws/bind', {clientId: clientId}, function (data) {
                     }, 'json');
-                case 'newMessage':
-                    if (data.status == 1) {
-                        console.log('您有新消息,请注意查收');
-                    } else {
-                        console.log('消息已读');
-                    }
+                    break;
+                case 'money':
+                    console.log(data)
                     break;
                 default :
+                    console.log("default")
             }
         };
     }
 
-</script>
+</script>