public function overdueproceess() { $time = 2100; //过期时间 $db = new Core(); /** * 查询与订单号相关的商品,订单中相关信息如积分等 */ $query = "SELECT \n \t g.*,\n \t o.order_id as new_order_id,\n \t o.pay_credits as pay_credits,\n \t o.user_id as user_id,\n \t\t o.integral_status as integral_status\n \t FROM " . DB_PREFIX . "goodslist g\n LEFT JOIN " . DB_PREFIX . "order o\n ON g.order_id=o.id\n WHERE o.pay_status = 1 \n and o.create_time<" . (time() - $time) . " limit 0,100"; $goodses = $db->query($query); if (!$goodses) { return; } $ids = array(); $newgoodses = array(); foreach ($goodses as $goods) { $newgoodses[$goods['bundle_id']]['goods'][$goods['goods_id']]['id'] = $goods['goods_id']; $newgoodses[$goods['bundle_id']]['goods'][$goods['goods_id']]['goods_number'] += $goods['goods_number']; $newgoodses[$goods['bundle_id']]['goods'][$goods['goods_id']]['bundle_id'] = $goods['bundle_id']; $ids[] = $goods['order_id']; $credits[$goods['user_id']]['id'] = $goods['order_id']; $credits[$goods['user_id']]['order_id'] = $goods['new_order_id']; $credits[$goods['user_id']]['credit'] = $goods['pay_credits']; $credits[$goods['user_id']]['integral_status'] = $goods['integral_status']; //积分的状态 } $this->BundleGoods = $newgoodses; foreach ($newgoodses as $bundle_id => $bundlegoodses) { $curl = $bundle_id . "curl"; $this->{$curl} = $this->create_curl_obj($bundle_id); $this->init_curl($bundle_id); //$Re_Minus_updateStores = $this -> opBundle('updateStore', array('operation' => 'plus')); } $Re_Minus_updateStores = $this->opBundle('updateStore', array('operation' => 'plus')); $orderids = implode(",", $ids); if (!$orderids) { return false; } require_once CUR_CONF_PATH . 'lib/sms.class.php'; require_once ROOT_PATH . 'lib/class/members.class.php'; $members = new members(); foreach ($credits as $user => $v) { if (!$v['credit']) { continue; } $re = $members->return_credit($user, $v['credit'], $v['order_id'], 'payments', 'OrderUpdate', 'cancle', '订单:' . $v['order_id'] . '被系统取消:' . $v['title'], $v['integral_status'], '取消订单'); if (!$re['logid']) { return false; } } $query = "UPDATE " . DB_PREFIX . "order \n SET order_status=24,pay_status=3,is_completed=23\n WHERE pay_status=1 and id in(" . $orderids . ")"; $result = $db->query_update($query); }
public function cancel_order() { $this->checklogin(); $id = intval($this->input['id']); if (!$id) { $this->errorOutput(NO_ID); } $query = "SELECT g.* \n FROM " . DB_PREFIX . "goodslist g\n LEFT JOIN " . DB_PREFIX . "order o \n ON g.order_id=o.id\n WHERE\n o.is_cancel=22 \n and g.order_id={$id} \n and g.user_id=" . $this->user['user_id']; $goodses = $this->obj->query($query); $query = "SELECT *\n FROM " . DB_PREFIX . "order o \n WHERE\n o.id={$id} \n and o.user_id=" . $this->user['user_id']; $order = $this->obj->query($query, ''); if (!$goodses) { $this->addItem(0); $this->Output(); } foreach ($goodses as $key => $goods) { $bundle_goods[$goods['bundle_id']]['goods'][$goods['goods_id']]['id'] = $goods['goods_id']; $bundle_goods[$goods['bundle_id']]['goods'][$goods['goods_id']]['goods_number'] += $goods['goods_number']; $bundle_goods[$goods['bundle_id']]['goods'][$goods['goods_id']]['bundle_id'] = $goods['bundle_id']; } $bundle_goods[$goods['bundle_id']]['order_info']['id'] = $order[0]['id']; $bundle_goods[$goods['bundle_id']]['order_info']['order_id'] = $order[0]['order_id']; $bundle_goods[$goods['bundle_id']]['order_info']['create_time'] = $order[0]['create_time']; $this->BundleGoods = $bundle_goods; foreach ($bundle_goods as $bundleid => $onebundle_datas) { $curl = $bundleid . "curl"; $this->{$curl} = $this->create_curl_obj($bundleid); $this->init_curl($bundleid); $Re_Minus_updateStores = $this->opBundle('updateStore', array('operation' => 'plus')); if ($Re_Minus_updateStores['status']) { $status = 2; $this->addItem(0); $this->Output(); } } require_once ROOT_PATH . 'lib/class/members.class.php'; //echo json_encode($order[0]);exit(); //echo json_encode($order);exit(); $members = new members(); if ($order[0]['pay_credits']) { $creditLogTitle = $this->input['creditLogTitle'] ? $this->input['creditLogTitle'] : '取消订单'; if ($order[0]['pay_credits']) { $re = $members->return_credit($this->user['user_id'], $order[0]['pay_credits'], $order[0]['order_id'], 'payments', 'OrderUpdate', 'cancle', $order[0]['title'], $order[0]['integral_status'], $creditLogTitle); //echo json_encode($re);exit(); if (@(!$re['logid'])) { $this->errorOutput("NO_NET"); } } } $cond = " where 1 and id={$id} and user_id=" . $this->user['user_id']; $params['is_cancel'] = 21; $params['order_status'] = 22; $params['is_completed'] = 23; $re = $this->obj->update('order', $params, $cond); $this->addItem(1); $this->Output(); }