getNotify(); if ($notify['result_code'] == 'SUCCESS' && $notify['return_code'] == 'SUCCESS') { if ($this->update($notify['out_trade_no'], $notify['transaction_id'], $notify['cash_fee'] / 100, 'wechat')) { return $wechat->getNotifySuccessReply(); } } else return $wechat->getNotifySuccessReply(); } /** * 订单状态更新 * @param string $order_no 订单号 * @param string $pay_no 交易号 * @param string $pay_price 交易金额 * @param string $type 支付类型 * @return boolean * @throws \think\Exception * @throws \think\exception\PDOException */ private function update($order_no, $pay_no, $pay_price, $type = 'wechat') { // 检查订单支付状态 $where = ['order_no' => $order_no, 'pay_state' => '0', 'status' => '2']; $order = Db::name('StoreOrder')->where($where)->find(); if (empty($order)) return false; // 更新订单支付状态 $result = Db::name('StoreOrder')->where($where)->update([ 'pay_type' => $type, 'pay_no' => $pay_no, 'status' => '3', 'pay_price' => $pay_price, 'pay_state' => '1', 'pay_at' => date('Y-m-d H:i:s'), ]); // 调用会员升级机制 Order::update($order['order_no']); return $result !== false; } }