|
- <?php
-
- /**
- * 司机端 订单特殊备注
- * ============================================================================
- * * 版权所有 蜘蛛出行 * *
- * 网站地址: http://www.zhizhuchuxing.com
- * ----------------------------------------------------------------------------
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
- * 使用;不允许对程序代码以任何形式任何目的的再发布。
- * ============================================================================
- * Author By: 倪宗锋
- * PhpStorm orderUnusual.class.php
- * Create By 2017/1/17 10:22 $
- */
- class orderUnusual extends base
- {
- /**
- * Des:修改标记状态
- * Name: editFlag
- * @param $param
- * @return array
- * @author 倪宗锋
- */
- public function editFlag($param)
- {
- //获取参数
- $order_id = isset($param['order_id']) ? trim($param['order_id']) : '';//订单号
- $status = isset($param['status']) ? trim($param['status']) : '';//状态
- //参数校验
- if (preg_match('/^[1-9][0-9]{0,10}$/', $order_id) == false) {//校验订单单号
- $json['code'] = '2';
- $json['info'] = '参数错误';
- return $json;
- }
- if (in_array($status, array(1, 2)) == false) {//校验参数
- $json['code'] = '2';
- $json['info'] = '参数错误';
- return $json;
- }
- //获取标记订单数据
- $orderUnusual = $this->getOrderUnusual($order_id);
- //如果订单在特殊记录表没有记录 则添加特殊表记录
- if (isset($orderUnusual[0]['status']) == false) {
- $addFlag = $this->addOrderUnusual($order_id, $status);
- if ($addFlag['code'] == 0) {
- return $addFlag;
- }
- }
- //如果已经存在记录 则修改状态和处理人
- $editFlag = $this->editOrderUnusual($order_id, $status);
- return $editFlag;
- }
-
- /**
- * Des:修改特殊记录表信息
- * Name: editOrderUnusual
- * @param $order_id
- * @param $status
- * @return mixed
- * @author 倪宗锋
- */
- public function editOrderUnusual($order_id, $status)
- {
- $base = new \Base();
- $user_id = $base->user_id;
- if(empty($base->user_id)) {
- $user_id = 0;
- }
- $sql = '' . "UPDATE order_unusual_process
- set `status` = {$status}, opera_user_id={$user_id}, process_time = NOW()
- where order_id = {$order_id}";
- if ($this->edit($sql)) {
- $json['code'] = '0';
- $json['info'] = '设置成功!';
- } else {
- $json['code'] = '3';
- $json['info'] = '设置异常!';
- }
- return $json;
- }
-
- /**
- * Des:添加特殊表记录
- * Name: addOrderUnusual
- * @param $order_id
- * @param $status
- * @return mixed
- * @author 倪宗锋
- */
- private function addOrderUnusual($order_id, $status)
- {
- $time = date('Y-m-d H:i:s');
- $sql = '' . "INSERT INTO `order_unusual_process`
- ( `order_id`, `special_state`, `submitter_phone`, `create_time`, `status`, `opera_user_id`, `process_time`)
- VALUES ( '{$order_id}', '', '', '{$time}', '{$status}', '{$_SESSION['user_id']}', '{$time}');";
- if ($this->insert($sql)) {
- $json['code'] = '0';
- $json['info'] = '设置成功!';
- } else {
- $json['code'] = '3';
- $json['info'] = '设置异常!';
- }
- return $json;
- }
-
- /**
- * Des:根据订单ID获取 订单特殊记录数据
- * Name: getOrderUnusual
- * @param $order_id
- * @return int
- * @author 倪宗锋
- */
- private function getOrderUnusual($order_id)
- {
- $sql = '' . "SELECT * from order_unusual_process where order_id = {$order_id} LIMIT 1";
- $result = $this->query($sql);
- return $result;
- }
-
- }
|