0] : $map = []; if ($status) { $map['status'] = 1; } $query = $this->app->db->name('ChannelList'); return $query->where($map)->order('id desc')->column('id,name,status,suoka_status,cancel_status,is_deleted', 'id'); } /** * 获取订单商户数据 * @return array */ public function getMerchantList($where = false, $status = true) { $where ? $map = ['is_deleted' => 0] : $map = []; if ($status) { $map['status'] = 1; } $query = $this->app->db->name('MerchantList'); return $query->where($map)->order('id desc')->column('id,name,status,is_deleted,merchant_type,cancel_support', 'id'); } /** * 获取订单商品数据 * @return array */ public function getProductList($where = false, $status = true) { $where ? $map = ['is_deleted' => 0] : $map = []; if ($status) { $map['status'] = 1; } $query = $this->app->db->name('ChannelProduct'); return $query->where($map)->order('id desc')->column('key,id,name,cid,status,is_deleted', 'id'); } /** * 获取订单商品数据 * @return array */ public function getServiceList() { $query = $this->app->db->name('service_info'); return $query->order('id desc')->column('key,id,name', 'key'); } /** * 获取订单商品数据 * @return array */ public function getProductKeyList($where = false) { $where ? $map = ['is_deleted' => 0] : $map = []; $map['status'] = 1; $query = $this->app->db->name('ChannelProduct'); return $query->where($map)->order('id desc')->group('key')->column('key,id,name,cid,status,is_deleted', 'id'); } /** * 获取订单关联数据 * @return array */ public function getOrderInfo($cid,$mid,$pid) { $data = []; $field = 'id,name,status,is_deleted'; $data['c'] = $this->app->db->name('ChannelList')->where('id',$cid)->field($field)->find(); $data['m'] = $this->app->db->name('MerchantList')->where('id',$mid)->field($field)->find(); $data['p'] = $this->app->db->name('ChannelProduct')->where('id',$pid)->field($field)->find(); return $data; } # 获取错误的订单数据 public function getOtherList($order_id) { return $this->app->db->name('merchant_order_auto_error')->where('order_id',$order_id)->order('id asc')->select()->toArray(); } public function total() { $data_type = input('data_type', 1); if ($data_type == 2) { $this->table = 'merchant_order_history'; }else if ($data_type == 5) { $this->table = 'merchant_order_last_history'; }else if ($data_type == 6) { $this->table = 'merchant_order_two_history'; }else if ($data_type == 7) { $this->table = 'merchant_order_lastweek_history'; } $where = array(); $mid = input('mid'); if ($mid) { $where['mid'] = $mid; } $cid = input('cid'); if ($cid) { $where['cid'] = $cid; } $pid = input('pid'); if ($pid) { $where['pid'] = $pid; } $cash = input('cash'); if ($cash) { $where['cash'] = $cash; } $status = input('status'); if ($status) { $where['status'] = $status; } $product_key = input('product_key'); if ($product_key) { $where['product_key'] = $product_key; } $isp = input('isp'); if ($isp) { $where['isp'] = $isp; } $create_at = input('create_at'); $col = 'create_at'; $channel_callback_at = input('channel_callback_at'); if ($channel_callback_at) { $create_at = $channel_callback_at; $col = 'channel_callback_at'; } $kami_hinged = input('kami_hinged'); if (($kami_hinged == 1 ) && !empty($kami_hinged)) { // 如果变量等于0或1,并且不为空,执行这里的代码 $where[]= ['response','Like', "%is_kami%" ]; }elseif ($kami_hinged == 2) { # 无流水的 $where[]= ['response','not Like', "%is_kami%" ]; } if ($create_at) { $temp = explode(' - ', $create_at); $begin = $temp[0] . ' 00:00:00'; $after = $temp[1] . ' 23:59:59'; $time = [$begin, $after]; } else { $time = false; } //$result['num'] = $this->getDb($where, $time); if ($data_type == 2) { $result['dong_num'] = 0; } else { $result['dong_num'] = Order::instance()->getDong(false, $time, $col, 'cash', $where); } $where['status'] = 3; $result['no_num'] = $this->getDb($where, $time); unset($where['status']); $result['act_yes_num'] = $this->getDb($where, $time, 'actual_cash', '2,5'); $result['yes_num'] = $this->getDb($where, $time, 'cash', '2,5'); $result['num'] = $result['dong_num'] + $result['yes_num'] + $result['no_num']; $result['order_num'] = $result['order_dong_num'] = $result['order_no_num'] = $result['order_yes_num'] = $result['order_ys_num'] = 0; if ($data_type == 2) { $result['order_dong_num'] = 0; } else { $result['order_dong_num'] = Order::instance()->getDong(false, $time, $col, '*', $where); } $where['status'] = 2; $result['order_yes_num'] = $this->getDb($where, $time, '*'); $where['status'] = 3; $result['order_no_num'] = $this->getDb($where, $time, '*'); $where['status'] = 5; $result['order_ys_num'] = $this->getDb($where, $time, '*'); $result['order_num'] = $result['order_dong_num'] + $result['order_yes_num'] + $result['order_no_num'] + $result['order_ys_num']; $result['order_yes_lv'] = $result['order_num'] > 0 ? round(($result['order_yes_num']/$result['order_num']) * 100, 2) . '%' : '0%'; // $result['kami'] = '1'; // if($vo['product_key'] =='cardbuy' && isset($vo['channel_callback_msg'])){ //// $tempMsg=json_decode($vo['channel_callback_msg']); //// if($tempMsg['']) // } return $result; } private function getDb($where, $time, $col = 'cash', $status = false) { $db = $this->db()->where($where); if ($status) { $db->whereRaw(' status in('.$status.')'); } if ($time) { $channel_callback_at = input('channel_callback_at'); if ($channel_callback_at) { $time_col = 'channel_callback_at'; } else { $time_col = 'create_at'; } $db = $db->whereBetween($time_col, $time); } $order_id = input('order_id'); if ($order_id) { $db = $db->whereLike('order_id', "%{$order_id}%"); } $channel_order_id = input('channel_order_id'); if ($channel_order_id) { $db = $db->whereLike('channel_order_id', "%{$channel_order_id}%"); } $merchant_order_id = input('merchant_order_id'); if ($merchant_order_id) { $db = $db->whereLike('merchant_order_id', "%{$merchant_order_id}%"); } $is_number = input('is_number'); if ($is_number == 1) { # 有流水号的 $db->whereRaw(' channel_callback_msg like("%s_number%")'); } elseif ($is_number == 2) { # 无流水号的 $db->whereRaw(' channel_callback_msg not like("%s_number%")'); } if ($col == '*') { return round($db->count($col), 2); } return round($db->sum($col), 2); } public function getOrder($data_type, $order_id) { $where = array(); if (strstr($order_id, ',')) { $where[] = array('id', 'in', $order_id); } elseif (is_numeric($order_id)) { $where['id'] = $order_id; } else { $where['order_id'] = $order_id; } if ($data_type == 5) { $this->table = 'merchant_order_last_history'; }else if ($data_type == 6) { $this->table = 'merchant_order_two_history'; }else if ($data_type == 7) { $this->table = 'merchant_order_lastweek_history'; }elseif ($data_type == 2) { $this->table = 'merchant_order_history'; }elseif ($data_type == 3) { $this->table = 'merchant_order_auto_error'; } $info = $this->db()->where($where)->find(); return $info; } # 设置回调订单 public function setCallback($data_type, $order_id, $status = 2, $msg = '', $s_nubmer = '') { $where = array(); if (strstr($order_id, ',')) { $where[] = array('id', 'in', $order_id); } elseif (is_numeric($order_id)) { $where['id'] = $order_id; } else { $where['order_id'] = $order_id; } if ($data_type == 2) { $this->table = 'merchant_order_history'; } else if($data_type == 5){ $this->table='merchant_order_last_history'; }else if($data_type == 6){ $this->table='merchant_order_two_history'; }else if($data_type == 7){ $this->table='merchant_order_lastweek_history'; }elseif ($data_type == 3) { $this->table = 'merchant_order_auto_error'; } $info = $this->db()->where($where)->find(); if (!$info) { return false; } if ($info && !$info['channel_callback_msg']) { $data['channel_callback_msg'] = '{}'; $info['channel_callback_msg'] = $data['channel_callback_msg']; } if ($info && !$info['channel_callback_at']) { $data['channel_callback_at'] = date('Y-m-d H:i:s'); } $data['status'] = $status; $data['merchant_callback_error'] = 2; if ($msg) { $data['channel_callback_msg'] = json_decode($info['channel_callback_msg'], true); $data['channel_callback_msg']['msg'] = $msg; $data['channel_callback_msg'] = json_encode($data['channel_callback_msg']); } elseif ($s_nubmer) { $data['channel_callback_msg'] = json_decode($info['channel_callback_msg'], true); $data['channel_callback_msg']['s_nubmer'] = $s_nubmer; $data['channel_callback_msg'] = json_encode($data['channel_callback_msg']); } return $this->db()->where($where)->update($data); } # 检测某个商户是否限额; public function countMerchantCash($mid,$product = '') { // return true; $where = [ 'mid' => $mid, ]; if($product){ $where['product_key'] = $product; } $begin = date("Y-m-d") . ' 00:00:00'; $after = date("Y-m-d") . ' 23:59:59'; $time = [$begin, $after]; $total = $this->getDb($where, $time, 'actual_cash', '2,5'); return $total; } }