Esempio n. 1
0
 function sendDetail()
 {
     if (IS_GET) {
         $map['mobile'] = I('mobile');
         $user = D('Common/shop_address')->where($map)->find();
         $map['uid'] = $user['id'];
         $orderLists = D('Order')->where($map)->order('id desc')->select();
         foreach ($orderLists as $order) {
             $result['order_id'] = $order['id'];
             $result['order_number'] = $order['order_number'];
             $result['order_date'] = time_format($order['cTime']);
             // 如果尚未付款,显示付款状态;如果已经付款,显示订单跟踪状态
             if ($order['pay_status'] != 1) {
                 $result['order_status'] = getNamebyPayStatus($order['pay_status']);
             } else {
                 $result['order_status'] = getNamebyOrderStatus($order['status_code']);
             }
             $result['status_code'] = $order['status_code'];
             $result['goods'] = json_decode($order['goods_datas'], true);
             $result['total_price'] = $order['total_price'];
             $address_info = D('Shop')->getInfo($order['address_id']);
             $result['fetch_address'] = $address_info['intro'];
             $result['fetch_contact'] = $address_info['mobile'];
             $result['id'] = $order['order_number'];
             $results[] = $result;
         }
         $this->assign('userInfo', $user);
         $this->assign('lists', $results);
         $this->display();
     }
 }
Esempio n. 2
0
 function asynNoticeFromQianFang()
 {
     if (IS_POST) {
         $orderInfo = D('Addons://Shop/Order')->getInfoByOrderNumber(I('post.out_sn'));
         // Qian Fang: 1 未支付 2 完成(已支付) 3 关闭
         switch (I('post.status')) {
             case 1:
                 $save['pay_status'] = 3;
                 break;
             case 2:
                 $save['pay_status'] = 1;
                 break;
             case 3:
                 $save['pay_status'] = 2;
                 break;
         }
         $save['pay_type'] = I('post.pay_type');
         $save['qianfang_number'] = I('post.order_id');
         $pay_time = strtotime(I('post.pay_time'));
         $save['pay_time'] = $pay_time;
         $res = D('Addons://Shop/Order')->update($orderInfo[0]["id"], $save);
         switch (I('post.status')) {
             case 2:
                 D('Addons://Shop/Order')->setStatusCode($orderInfo[0]["id"], 2);
                 D('Addons://Shop/Order')->add_order_log($orderInfo[0]["id"], 2, json_encode(I('post.')), '钱方异步:订单状态' . getNamebyOrderStatus(2));
                 break;
             case 3:
                 D('Addons://Shop/Order')->setStatusCode($orderInfo[0]["id"], -1);
                 D('Addons://Shop/Order')->add_order_log($orderInfo[0]["id"], -1, json_encode(I('post.')), '钱方异步:订单状态' . getNamebyOrderStatus(-1));
                 break;
             case 1:
                 D('Addons://Shop/Order')->setStatusCode($orderInfo[0]["id"], 1);
                 D('Addons://Shop/Order')->add_order_log($orderInfo[0]["id"], 1, json_encode(I('post.')), '钱方异步:订单状态' . getNamebyOrderStatus(1));
                 break;
         }
         D('Addons://Shop/Order')->add_order_log($orderInfo[0]["id"], I('post.status'), json_encode(I('post.')), '钱方异步:支付状态' . getNamebyPayStatus(I('post.status')));
         // 支付成功,发送短信提醒
         if (I('post.status') == 2) {
             $map['id'] = $orderInfo[0]['address_id'];
             $address_info = D('Shop')->where($map)->find();
             $customerId = $orderInfo[0]['uid'];
             $accountInfo = D('Addons://Shop/ShopUser')->getAccount($customerId);
             // 短信报备模板:@@您已付款成功,请于@@,到@@根据手机号提货。客服电话@@。【好之味鲜果超市】
             $content = $accountInfo['truename'] . ':您已付款成功,请于明日早10点-晚19:00点,到' . $address_info['intro'] . '根据手机号提货。客服电话' . $address_info['mobile'] . '。【好之味鲜果超市】';
             $result = sendSMS($accountInfo['mobile'], $content);
             D('Addons://Shop/Order')->add_order_log($orderInfo[0]["id"], I('post.status'), $content . $accountInfo['mobile'], '短信通知' . getNamebyPayStatus(I('post.status')));
             D('Addons://Shop/Order')->add_order_log($orderInfo[0]["id"], I('post.status'), $result, '短信通知' . getNamebyPayStatus(I('post.status')));
         }
         echo 'SUCCESS';
     }
 }
Esempio n. 3
0
 public function run()
 {
     while (1) {
         $localtime_assoc = localtime(time(), true);
         if (in_array($localtime_assoc['tm_min'], array('5', '15', '25', '35', '45', '55'))) {
             $orderDao = D('Addons://Shop/Order');
             $filter_order['pay_status'] = '0';
             $orderLists = $orderDao->where($filter_order)->select();
             foreach ($orderLists as $order) {
                 $caller = 'server';
                 $app_code = 'C921FF5C81381E203BAE6D9AC2E90C0F';
                 $data = array('caller' => $caller, 'app_code' => $app_code, 'order_id' => $order['order_number'], 'sign' => '');
                 $sign_str = getQianfangSign($data);
                 $data['sign'] = $sign_str;
                 while (list($key, $value) = each($data)) {
                     $item[] = $key . '=' . $value;
                 }
                 $orderQuery = implode('&', $item);
                 $server_url = 'https://qtapi.qfpay.com/order/v1/query?' . $orderQuery;
                 $curl = curl_init();
                 curl_setopt($curl, CURLOPT_URL, $server_url);
                 curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
                 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
                 curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
                 $info_json = curl_exec($curl);
                 if (!curl_errno($curl)) {
                     $info = json_decode($info_json);
                     $pay_status = $info->data['order_info']['status'];
                     // Qian Fang: 1 未支付 2 完成(已支付) 3 关闭
                     switch ($pay_status) {
                         case 1:
                             $save['pay_status'] = 3;
                             break;
                         case 2:
                             $save['pay_status'] = 1;
                             break;
                         case 3:
                             $save['pay_status'] = 2;
                             break;
                     }
                     $save['pay_type'] = $info->data['order_info']['pay_type'];
                     $save['qianfang_number'] = $info->data['order_info']['order_id'];
                     $pay_time = strtotime($info->data['order_info']['pay_time']);
                     $save['pay_time'] = $pay_time;
                     $res = D('Addons://Shop/Order')->update($order["id"], $save);
                     switch ($info->data['order_info']['status']) {
                         case 2:
                             D('Addons://Shop/Order')->setStatusCode($order["id"], 2);
                             D('Addons://Shop/Order')->add_order_log($order["id"], 2, $info, '订单状态' . getNamebyOrderStatus(2));
                             break;
                         case 3:
                             D('Addons://Shop/Order')->setStatusCode($order["id"], -1);
                             D('Addons://Shop/Order')->add_order_log($order["id"], -1, $info, '订单状态' . getNamebyOrderStatus(-1));
                             break;
                         case 1:
                             D('Addons://Shop/Order')->setStatusCode($order["id"], 1);
                             D('Addons://Shop/Order')->add_order_log($order["id"], 1, $info, '订单状态' . getNamebyOrderStatus(1));
                             break;
                     }
                     D('Addons://Shop/Order')->add_order_log($order["id"], $pay_status, $info, '支付状态' . getNamebyPayStatus($save['pay_status']));
                 } else {
                     $err = '访问服务器出错:' . curl_error($curl);
                     trace($err, "order status query error", 'user');
                 }
                 curl_close($curl);
             }
         }
     }
 }