/** * 记录支付日志 */ private function addPayLog($openid, $order_id, \WxPayUnifiedOrder $input) { $data = ['openid' => $openid, 'order_id' => intval($order_id), 'order_sn' => $input->GetOut_trade_no(), 'body' => $input->GetBody(), 'total_fee' => $input->GetTotal_fee(), 'attach' => $input->GetAttach(), 'time_start' => strtotime($input->GetTime_start()), 'time_expire' => strtotime($input->GetTime_expire()), 'pay_time' => 0, 'status' => 0, 'wx_pay_sn' => '', 'is_send' => 0, 'created_at' => time()]; $M = M("wx_pay_log"); $rel = $M->where(["openid" => $openid, 'order_sn' => $data['order_sn']])->select(); if (empty($rel)) { $M->add($data); } else { $M->where(["openid" => $openid, 'order_sn' => $data['order_sn']])->save($data); } }