root 5 tahun lalu
induk
melakukan
47ee1d745d

+ 28 - 0
addons/zh_jdgjb/init.php

xqd
@@ -0,0 +1,28 @@
+<?php
+
+defined('IN_IA') or exit('Access Denied');
+function checkOrder() {
+    global $_GPC, $_W;
+    $where=" where uniacid = :uniacid and status = :status and is_out_time = :is_out_time";
+    $data[':uniacid'] = $_W['uniacid'];
+    $data[':status'] = 10;
+    $data[':is_out_time'] = 0;
+    $sql = "select *  from " . tablename("zh_jdgjb_order") . $where . " order by id desc ";
+    $list = pdo_fetchall($sql, $data);
+    if (count($list) > 0) {
+        foreach ($list as $keyOrder => $order) {
+            if (time() > strtotime($order['departure_time'])) {
+                pdo_update('zh_jdgjb_order', array('is_out_time' => 1), array('id' => $order['id']));
+                $orderData[':uniacid'] = $_W['uniacid'];
+                $orderData[':user_id'] = $order['user_id'];
+                $orderData[':is_out_time'] = 1;
+                $orderData[':is_re_pay'] = 0;
+                $sqlOrder = "select *  from " . tablename("zh_jdgjb_order") . " where uniacid = :uniacid and user_id = :user_id and is_out_time = :is_out_time and is_re_pay = :is_re_pay order by id desc ";
+                $result = pdo_fetchall($sqlOrder, $orderData);
+                if (count($result) >= 2) {
+                    pdo_update('zh_jdgjb_user', array('level_id' => 0, 'type' => 1), array('id' => $order['user_id']));
+                }
+            }
+        }
+    }
+}

+ 9 - 0
addons/zh_jdgjb/payment/wechat/notify.php

xqd
@@ -55,6 +55,15 @@ if($res['return_code'] == 'SUCCESS' && $res['result_code'] == 'SUCCESS' ){
         exit;
     }
 
+    if (substr($res['out_trade_no'], 0, 1) == 'R') {
+        $order = pdo_get('zh_jdgjb_re_order',array('out_trade_no' => $res['out_trade_no']));
+        if ($order['status'] == 1) {
+            pdo_update('zh_jdgjb_re_order',array('status'=>2),array('out_trade_no'=>$logno));
+            //获取用户消费金额
+            pdo_update('zh_jdgjb_order',array('is_re_pay' => 1),array('id'=>$order['order_id']));
+        }
+        exit;
+    }
 
 	$str=$_W['siteroot'];
 	$n = 0;

+ 6 - 0
addons/zh_jdgjb/template/web/addhotel.html

xqd
@@ -303,6 +303,12 @@
     <input type="text"  name="zd_money" value="{$list['zd_money']}" class="form-control" id="inputEmail3" placeholder="请填写最低金额">
   </div>
 </div>
+                  <div class="form-group">
+                      <label for="rePayMoney" class="col-sm-2 control-label">消除违约所需金额</label>
+                      <div class="col-sm-10">
+                          <input type="text"  name="re_pay_money" value="{$list['re_pay_money']}" class="form-control" id="rePayMoney" placeholder="请填写违约金">
+                      </div>
+                  </div>
 <div class="form-group">
     <label for="inputEmail3" class="col-sm-2 control-label">酒店政策</label>
     <div class="col-sm-10">

+ 65 - 4
addons/zh_jdgjb/wxapp.php

xqd xqd xqd
@@ -13,12 +13,17 @@
  */
 
 defined('IN_IA') or exit('Access Denied');
-
+require_once 'init.php';
 
 
 class Zh_jdgjbModuleWxapp extends WeModuleWxapp {
 
-	public function doPageTest(){
+    public function __construct()
+    {
+        checkOrder();
+    }
+
+    public function doPageTest(){
 		global $_GPC, $_W;
 		$errno = 0;
 		$message = '返回消息';
@@ -460,7 +465,36 @@ public function doPageReceiveCoupons(){
         echo json_encode(['code'=> 1, 'data' => $order_id]);
     }
 
+    public function doPageAddRePayOrder(){
+        global $_W, $_GPC;
+        $data['user_id']=$_GPC['user_id'];
+        $data['order_id']=$_GPC['order_id'];
+        $level = pdo_get('zh_jdgjb_order',array('id' => $_GPC['order_id']));
+        if (!$level) {
+            echo json_encode(['code'=> -1, 'msg' => '该订单不存在']);
+            exit;
+        }
+        if ($level['is_re_pay'] == 1) {
+            echo json_encode(['code'=> -1, 'msg' => '该订单已支付']);
+            exit;
+        }
+        $data['order_no']='R' . date('YmdHis').rand(0,9999);
+        $data['status']=1;
+        $data['time']=time();
+        $data['price']=$level['value'];
+        $data['tel']=$_GPC['tel'];
+        $data['name']=$_GPC['name'];
+        $data['total_cost']=$level['value'];
+        $data['uniacid']=$_W['uniacid'];
+        $data['out_trade_no']='R' . time().rand(1000,9999).$_GPC['user_id'];
+
 
+        // $data['out_trade_no']=$_GPC['out_trade_no'];//预定订单
+        $data['from_id']=$_GPC['from_id'];
+        $res=pdo_insert('zh_jdgjb_re_order',$data);
+        $order_id=pdo_insertid();
+        echo json_encode(['code'=> 1, 'data' => $order_id]);
+    }
 //生成订单
 public function doPageAddOrder(){
 	global $_W, $_GPC;
@@ -813,11 +847,38 @@ public function doPageMyOrder(){
 	$select_sql=$sql." LIMIT " .($pageindex - 1) * $pagesize.",".$pagesize;
 	$list=pdo_fetchall($select_sql,$data);
 	foreach($list as $key=>$val){
-	$list[$key]['count']=pdo_fetchcolumn("SELECT count(*) FROM ".tablename('zh_jdgjb_order') .$where.' and id<='.$val['id'].' and user_id='.$val['user_id'] ,$data)?:0;	
-}
+        $list[$key]['count']=pdo_fetchcolumn("SELECT count(*) FROM ".tablename('zh_jdgjb_order') .$where.' and id<='.$val['id'].' and user_id='.$val['user_id'] ,$data)?:0;
+    }
 	echo json_encode($list);
 }
 
+
+//我的订单
+    public function doPageMyOverdueOrder(){
+        global $_GPC, $_W;
+        $pageindex = max(1, intval($_GPC['page']));
+        $pagesize=10;
+        if (!$_GPC['seller_id']) {
+            echo '酒店id必填!';
+        }
+        $data[':uniacid']=$_W['uniacid'];
+        $data[':user_id']=$_GPC['user_id'];
+        $where=" where uniacid=:uniacid and user_id=:user_id  ";
+        if($_GPC['status']){
+            $where.=" and status = :status and is_out_time = :is_out_time";
+            $data[':status'] = 10;
+            $data[':is_out_time'] = 1;
+        }
+        $sql="select *  from " . tablename("zh_jdgjb_order") .$where." order by id desc ";
+        $select_sql=$sql." LIMIT " .($pageindex - 1) * $pagesize.",".$pagesize;
+        $list=pdo_fetchall($select_sql,$data);
+        foreach($list as $key=>$val){
+            $list[$key]['count']=pdo_fetchcolumn("SELECT count(*) FROM ".tablename('zh_jdgjb_order') .$where.' and id<='.$val['id'].' and user_id='.$val['user_id'] ,$data)?:0;
+        }
+        $list = pdo_get('zh_jdgjb_seller',array('id'=>$_GPC['seller_id']));
+        echo json_encode(['data' => $list, 're_pay_money' => $list['re_pay_money']]);
+    }
+
 //订单详情
 public function doPageOrderDetails(){
 	global $_GPC, $_W;

+ 5 - 1
web/index.php

xqd
@@ -51,7 +51,11 @@ if (!empty($handle)) {
 if (!in_array($controller, $controllers)) {
 	$controller = 'home';
 }
-
+if ($_GPC['m'] == 'zh_jdgjb') {
+    $construct = IA_ROOT . "/addons/zh_jdgjb/init.php";
+    require $construct;
+    checkOrder();
+}
 $init = IA_ROOT . "/web/source/{$controller}/__init.php";
 if (is_file($init)) {
 	require $init;