public function do_verify() { $order_item_id = intval($_REQUEST['order_item_id']); $coupon_id = intval($_REQUEST['coupon_id']); if ($order_item_id) { $oi = $order_item_id; $data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order_item where id = " . $order_item_id); $order_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order where id = " . $data['order_id']); $delivery_notice = $GLOBALS['db']->getRow("select n.* from " . DB_PREFIX . "delivery_notice as n left join " . DB_PREFIX . "deal_order as o on n.order_id = o.id where n.order_item_id = " . $order_item_id . " and o.id = " . $data['order_id'] . " and is_arrival <> 1 order by delivery_time desc"); if ($delivery_notice) { require_once APP_ROOT_PATH . "system/model/deal_order.php"; $res = confirm_delivery($delivery_notice['notice_sn'], $order_item_id); if ($res) { send_msg($order_info['user_id'], "订单经管理员审核,确认收货", "orderitem", $oi); $data['status'] = true; $data['info'] = "操作收货成功"; ajax_return($data); } else { $data['status'] = 0; $data['info'] = "操作收货失败"; ajax_return($data); } } else { $data['status'] = 0; $data['info'] = "订单已收货"; ajax_return($data); } } elseif ($coupon_id) { $data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_coupon where id = " . $coupon_id); if ($data['refund_status'] == 2) { $this->error("已退款", 1); } if ($data) { $oi = $data['order_deal_id']; $order_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order_item where id = " . $data['order_deal_id']); $order_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order where id = " . $order_item['order_id']); require_once APP_ROOT_PATH . "system/model/deal_order.php"; $rs = use_coupon($data['password'], 0, 0, true, true); if ($rs) { $this->success("验证成功", 1); } else { $this->error("验证失败", 1); } } else { $this->error("非法操作", 1); } } }
/** * 团购全超级验证的使用, 使用全的数量= 当前输入的券+随机取出的券 * @param unknown_type $s_account_info * @param unknown_type $location_id * @param unknown_type $pwd * @param unknown_type $coupon_use_count * @return boolean */ function biz_super_use_coupon($s_account_info, $location_id, $pwd, $coupon_use_count) { $now = NOW_TIME; require_once APP_ROOT_PATH . "system/model/biz_verify.php"; $s_account_info = es_session::get("account_info"); $location_id = intval($_REQUEST['location_id']); $pwd = strim($_REQUEST['coupon_pwd']); $result = biz_super_check_coupon($s_account_info, $pwd, $location_id); if ($result['count'] == 0) { $data['status'] = 0; $data['msg'] = "没有可以使用的团购券"; ajax_return($data); } if ($coupon_use_count > $result['count']) { $data['status'] = 0; $data['msg'] = "超出使用条数"; ajax_return($data); } $coupon_pwd_list = $GLOBALS['db']->getAll("select c.password as password from " . DB_PREFIX . "deal_coupon as c where c.deal_id=" . $result['coupon_data']['deal_id'] . " and c.order_id=" . $result['coupon_data']['order_id'] . " and c.order_deal_id = " . $result['coupon_data']['order_deal_id'] . " and c.is_valid = 1 and c.refund_status=0 and c.is_delete = 0 and c.confirm_time='' and c.begin_time <" . $now . " and (c.end_time = 0 or c.end_time>'" . $now . "') limit 0," . $coupon_use_count); require_once APP_ROOT_PATH . "system/model/deal_order.php"; foreach ($coupon_pwd_list as $k => $v) { $f_coupon_pwd_list[] = $v['password']; } if (!in_array($pwd, $f_coupon_pwd_list)) { //输入验证的一定要使用 $f_coupon_pwd_list = array_shift($f_coupon_pwd_list); $f_coupon_pwd_list = array_unshift($f_coupon_pwd_list, $pwd); } foreach ($f_coupon_pwd_list as $k => $v) { $temp['pwd'] = $v; $temp['send_status'] = use_coupon($v, $location_id, $s_account_info['id'], true, true); $send_log[] = $temp; } //已经成功执行 $data['status'] = 1; $data['send_data'] = $send_log; return $data; }