dever 3 years ago
parent
commit
c301f5dcf3
4 changed files with 167 additions and 1 deletions
  1. 37 1
      app/mshop/src/Data.php
  2. 55 0
      app/shop/lib/Cron.php
  3. 28 0
      app/shop/lib/Refund.php
  4. 47 0
      app/shop/src/Main.php

+ 37 - 1
app/mshop/src/Data.php

@@ -64,7 +64,7 @@ class Data extends Core
         $info = Dever::db('shop/sell_order')->find(array('id' => $order_id));
 
         if ($info && $info['shop_id'] == $this->shop_id && $info['status'] < 3) {
-
+            $config = Dever::db('shop/sell_order')->config;
             $state = Dever::db('shop/sell_order')->update(array('where_id' => $info['id'], 'status' => 3, 'operdate' => time()));
 
             # 给用户发消息
@@ -77,12 +77,48 @@ class Data extends Core
                 if ($info['method'] == 1) {
                     $msg = '您有一件自提商品已完成配货,请尽快到指定门店使用取件码取货,取件码:' . $info['code'];
                     $name = '取货通知';
+                    $wechat_msg = '您有一件自提商品已完成配货,请尽快到指定门店使用取货号取货';
                 } else {
                     $msg = '您有一件外送商品已开始配送,收货时请将取件码提供给配送员核实货品信息,取件码::' . $info['code'];
                     $name = '配送通知';
+                    $wechat_msg = '您有一件外送商品已开始配送,收货时请将取货号提供给配送员核实货品信息';
                 }
                 
                 Dever::load('message/lib/data')->push(-1, $info['uid'], $name, $msg, 1, 1, false, $msg_param);
+
+                if (Dever::load('wechat_applet')) {
+                    $user = Dever::db('passport/wechat')->one(array('uid' => $info['uid'], 'system_id' => 1, 'system_source' => 5));
+                    if ($user && $user['openid']) {
+                        $info['status_name'] = $config['status'][$info['status']];
+                        $send = array
+                        (
+                            'character_string6' => array
+                            (
+                                'value' => $info['order_num'],
+                            ),
+                            
+                            'phrase7' => array
+                            (
+                                'value' => $info['status_name'],
+                            ),
+                            'thing8' => array
+                            (
+                                'value' => $info['code'],
+                            ),
+                            'amount1' => array
+                            (
+                                'value' => $info['price'] . '元',
+                            ),
+                            'thing5' => array
+                            (
+                                'value' => $wechat_msg,
+                            ),
+                        );
+
+                        $send = Dever::json_encode($send);
+                        Dever::load('wechat_applet/subscribe')->sendOne('order_process', 1, $user['openid'], 'pages/app/order/order?id=' . $info['id'], $send, Dever::config('base')->wechat_applet);
+                    }
+                }
             }
             if ($info['method'] == 2) {
                 Dever::load('shop/lib/sell')->updatePs($info, 2);

+ 55 - 0
app/shop/lib/Cron.php

@@ -24,6 +24,31 @@ class Cron
                 $msg_param['coupon_id'] = $v['coupon_id'];
                 $msg_param = Dever::json_encode($msg_param);
                 Dever::load('message/lib/data')->push(-1, $v['uid'], '优惠劵到期提醒', $msg, 2, 1, false, $msg_param);
+
+
+                if (Dever::load('wechat_applet') && $v['uid'] && $v['uid'] > 0) {
+                    $user = Dever::db('passport/wechat')->one(array('uid' => $v['uid'], 'system_id' => 1, 'system_source' => 5));
+                    if ($user && $user['openid']) {
+                        $send = array
+                        (
+                            'thing1' => array
+                            (
+                                'value' => $coupon_info['name'],
+                            ),
+                            'time2' => array
+                            (
+                                'value' => date('Y-m-d H:i', $v['edate']),
+                            ),
+                            'thing3' => array
+                            (
+                                'value' => '您有一张优惠券即将到期,请尽快使用',
+                            ),
+                        );
+
+                        $send = Dever::json_encode($send);
+                        Dever::load('wechat_applet/subscribe')->sendOne('act_2', 1, $user['openid'], 'pages/app/order/order?id=' . $v['id'], $send, Dever::config('base')->wechat_applet);
+                    }
+                }
             }
         }
     }
@@ -42,6 +67,7 @@ class Cron
         $order = Dever::db('shop/sell_order')->getDataByTime($where);
 
         if ($order && Dever::project('message')) {
+            $config = Dever::db('shop/sell_order')->config;
             foreach ($order as $k => $v) {
                 if ($time - $v['cdate'] >= 900) {
                     Dever::db('shop/sell_order')->update(array('where_id' => $v['id'], 'status' => 11));
@@ -53,6 +79,35 @@ class Cron
                     $msg_param['name'] = $shop['name'];
                     $msg_param = Dever::json_encode($msg_param);
                     Dever::load('message/lib/data')->push(-1, $v['uid'], '订单待支付提醒', $msg, 2, 1, false, $msg_param);
+
+                    if (Dever::load('wechat_applet') && $v['uid'] && $v['uid'] > 0) {
+                        $user = Dever::db('passport/wechat')->one(array('uid' => $v['uid'], 'system_id' => 1, 'system_source' => 5));
+                        if ($user && $user['openid']) {
+                            $v['status_name'] = $config['status'][$v['status']];
+                            $send = array
+                            (
+                                'character_string5' => array
+                                (
+                                    'value' => $v['order_num'],
+                                ),
+                                'amount11' => array
+                                (
+                                    'value' => $v['price'] . '元',
+                                ),
+                                'phrase13' => array
+                                (
+                                    'value' => $v['status_name'],
+                                ),
+                                'thing12' => array
+                                (
+                                    'value' => '您有一笔待付款订单,请及时付款。',
+                                ),
+                            );
+
+                            $send = Dever::json_encode($send);
+                            Dever::load('wechat_applet/subscribe')->sendOne('order_pay', 1, $user['openid'], 'pages/app/order/order?id=' . $v['id'], $send, Dever::config('base')->wechat_applet);
+                        }
+                    }
                 }
             }
         }

+ 28 - 0
app/shop/lib/Refund.php

@@ -334,6 +334,34 @@ class Refund
             Dever::load('message/lib/data')->push(-1, $data['uid'], '退款成功通知', $msg, 2, 1, false, $msg_param);
 
             # 退款到原支付账户 待处理
+
+
+            if (Dever::load('wechat_applet')) {
+                $config = Dever::db($this->order_table)->config;
+                $user = Dever::db('passport/wechat')->one(array('uid' => $data['uid'], 'system_id' => 1, 'system_source' => 5));
+                if ($user && $user['openid']) {
+                    $data['status_name'] = $config['status'][$data['status']];
+                    $msg = '';
+                    $send = array
+                    (
+                        'character_string1' => array
+                        (
+                            'value' => $data['order_num'],
+                        ),
+                        'amount3' => array
+                        (
+                            'value' => $info['cash'] . '元',
+                        ),
+                        'thing7' => array
+                        (
+                            'value' => $msg,
+                        ),
+                    );
+
+                    $send = Dever::json_encode($send);
+                    Dever::load('wechat_applet/subscribe')->sendOne('order_refund', 1, $user['openid'], 'pages/app/order/order?id=' . $data['id'], $send, Dever::config('base')->wechat_applet);
+                }
+            }
         }
     }
 }

+ 47 - 0
app/shop/src/Main.php

@@ -13,6 +13,53 @@ class Main extends Core
         //$this->checkLogin();
     }
 
+    public function test()
+    {
+        $data = array
+        (
+            'character_string6' => array
+            (
+                'value' => '111111112',
+            ),
+            'phrase7' => array
+            (
+                'value' => '已发货',
+            ),
+            'thing8' => array
+            (
+                'value' => '货号',
+            ),
+            'amount1' => array
+            (
+                'value' => '100元',
+            ),
+            'thing5' => array
+            (
+                'value' => '提示',
+            ),
+        );
+
+        $data = array
+        (
+            'thing3' => array
+            (
+                'value' => '111111112',
+            ),
+            'thing6' => array
+            (
+                'value' => date('Y-m-d H:i:s'),
+            ),
+            'thing7' => array
+            (
+                'value' => '提示',
+            ),
+        );
+
+        $data = Dever::json_encode($data);
+
+        return $data;
+    }
+
     # 获取当前登录的信息
     public function user()
     {